How to "scanf" many times with for?

+3 votes
asked Jan 2 by (190 points)

6 Answers

0 votes
answered Jan 2 by anonymous
for(int i=0;i<10;i++){
scanf("%d",&a[i]);}
+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 (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 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 by (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 5 days ago 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.
...