Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed How to "scanf" many times with for?

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

2 Answers

+1 vote
answered Jan 2, 2020 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, 2020 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.
...