How to implement a flag control in my loop?
Code:
int main()
{
int total_value=0;
char mychar;
int mynum;
do
{
printf("Line: ");
scanf("%c",&mychar);
mynum=mychar;
total_value=total_value+mynum;
} while(mychar!='.');
printf("Checksum %c",total_value);
return 0;
My code works fine. It does the calculations and prints out the results. However with a bit of extras.
So basically how do i implement a flag-control in this loop. Such that the program does calculations until it reachs a '.' (period)
Code:
while(flag=1)
{
}
while(mynum!='.')
{
}