Whats wrong with this C program?
Posted
by Prab
on Stack Overflow
See other posts from Stack Overflow
or by Prab
Published on 2010-05-15T10:42:37Z
Indexed on
2010/05/15
10:44 UTC
Read the original article
Hit count: 156
Filed under:
c
It should give me the number of inputs entered by the user. But it gives 100. I compiled with gcc.
#include <stdio.h>
int arr[100];
int count=0;
int max=100;
int main(){
int i, input;
printf("Enter integer values one by one, q to quit.\n");
for(i=0;i<max;i++){
scanf("%d",&input);
arr[i]=input;
if(input=='q')break;
count++;
}
printf("You entered %d values.\n",count);
return 0;
}
© Stack Overflow or respective owner