closed How to "scanf" many times with for?

0 votes
asked Jan 2 by Teepisit Sintukhate (210 points)
closed Jan 4 by Admin
closed as a duplicate of: How to "scanf" many times with for?

2 Answers

+1 vote
answered Jan 2 by anonymous
#include <stdio.h>

int main()
{
    
    int counter = 0;
    int a[10];
    
    for(counter = 0; counter < 10; counter++){
        scanf("%d", &a[counter+1]);
    }

    return 0;
}
0 votes
answered Jan 3 by anil gowda m
// Here is a simple example to demonstrate that

#include <stdio.h>

#include <stdlib.h>
 

void main()

{

           int a[10];

           int n,i;

           printf("read the number of elements\n");

           scanf("%d",&n);

           printf("read the array elements\n");

           for(i=0;i<n;i++)

           {

                     scanf("%d",a[i]);

           }

}      // print it if u need that
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...