his shows you to how to use the do command for conditional programming in c.
Now we will concentrate on arrays: What is a flag? A flag is an algorithm that informs the program that a certain condition has occured.
Now we will concentrate on arrays: What is a flag? A flag is an algorithm that informs the program that a certain condition has occured.
example-9
void main()
{
int temp; float celsius;
char repeat; char flag;
do { flag='n";
do { if(flag=='n')
printf("Input a valid temperature :");
else
printf("input a valid temperature,stupid:");
scanf("%d",&temp);
flag='y'; }
while (temp<0||temp >100);
celsius=(5.0/9.0)*(temp-32);printf("%d degrees F is %6.2f degrees celsius\n",temp,celsius);
printf("Do you have another temperature?");
repeat=getchar();
putchar('\n');
}
while (repeat=='y' || repeat=='Y");
}
No comments:
Post a Comment