Home > front end >  Infinite for loop? ()in c
Infinite for loop? ()in c

Time:12-20

the value of i resets after it reachers 7

#include <stdio.h>
int main(){

    char marks[10];
    int i;

    printf("enter the numbers:\n");
    printf("-------------------\n");
    
    for (i=0;i<10;i  )
    {
        printf("%d\n",i);
        printf("element %d-",i);
        scanf("%d", &marks[i]);
    }

    printf("\n all %d",marks);
    printf("\n second %d\n",marks[1]);
return 0;
}

enter image description here

Also I didn't understand the use of all so I couldn't find a solution for it. If you want to print a specific number then you have to specify it like you have done it for second or if you want to display the total you want to add a furthermore code to calculate the sum of elements in the array.

  • Related