I'm very new to C language, I have the following code:
Code:
#include <stdio.h>
#include <stdlib.h>
int number;
int total;
int nums=0;
int i;
char c;
int main()
{

for(;;)
{
printf("please enter number here, and character k to quit:\n");
fflush(stdin);
scanf("%d",&number);
total +=number;
nums++;

}

printf("average value: %d\n",total/nums);
return(0);
}
Now I want is that when user type 'k' from keyboard, above loop will break.
Could anyone modofy my source code so that I can learn from you?
Thanks and regards,

Last edited by shabbir; 9May2008 at 11:28.. Reason: Code block