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.

How to "scanf" many times with for?

+3 votes
asked Jan 2, 2020 by Teepisit Sintukhate (210 points)

6 Answers

0 votes
answered Jan 2, 2020 by anonymous
for(int i=0;i<10;i++){
scanf("%d",&a[i]);}
+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 Vvinayak (140 points)
# include<stdio.h>

int main()

{

int i,n=10,a;

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

{

scanf("%d",&a)

}

return 0;

}
0 votes
answered Jan 6, 2020 by anonymous

Answer with pointers:

char *ptr;

char str[100]="";

for(ptr=str;ptr<str+100;ptr++){

scanf("%c",*ptr);

}

0 votes
answered Jan 14, 2020 by Chandra Sagar (260 points)
//this for loop is to read many times upto n numbers

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

{

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

}
0 votes
answered Jan 21, 2020 by anonymous
int main()

{

int i;

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

{

int a[10];

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

}

return 0;

}
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.
...