Hello guys. Here's my code. I want to average the numbers entered by the user.
Thanks in advance.Code:#include<stdio.h> #include<ctype.h> int main(void) { int value = 0; char answer = 'n'; int total = 0; int count = 0; for( ;; ) { printf("Enter a value: "); scanf("%d", &value); total += value; count++; printf("Continue?(y/n): "); scanf("%c", &answer); // this code is getting skipped if(tolower(answer) == 'n') break; } printf("Avg. is %d", total/count); return 0; }
--Sid