1

I'm taking input in an array. But the loops are taking values more than the condition and not storing those values in array. I'm stuck here.

When I'm taking input on x[] array, it takes 1 more input than the condition.

Here is my code

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,j,n;
    printf("How much number you have?  : ");
    scanf("%d",&n);
    float x[n];
    float FofX[n][n];
    float x_variable;

    i=0;

    printf("Enter values of x \n\n");
    while(i!=n){
        printf("When n is %d and i is x[%d]:  ",n,i);
        scanf("%f ",&x[i]);
        printf("\n");
        i++;
    }

    i=0;
    while(i!=n){
        printf("x[%d]= %d \n",i,x[i]);
        i++;
    }

    i=0;
    printf("Enter values of f(x) \n");
    while(i!=n){
        printf("When n is %d and i is [%d]:  ",n,i);
        scanf("%f",&FofX[i][0]);
        i++;
    }

    printf("\nInput value of a variable point\n");
    scanf("%d",&x_variable);
    printf("Hello world!\n");
    return 0;
}
Clifford
  • 88,407
  • 13
  • 85
  • 165
Maruf
  • 41
  • 5

0 Answers0