Here it is:
Code:
#include<stdio.h>
#include<conio.h>
main()
{
char a, b,c,d;
clrscr();
do {
printf("LATEST NEWS \n type W for weather or S for Sports or L for local\n");
scanf("%c", &a);
if (a == 'W' || a == 'w')
{ printf("\nSunny!");
}
else if (a == 'L' || a=='l')
{
printf("\nMan gets head stuck in rabbit hole");
}
else if (a == 'S' || a=='s')
{
printf("\nNo matches currently. \nPress y to check\n");
scanf(" %c",&b);
if (b == 'y' || b=='Y' )
printf("Don't be impatient! This isn't a game you know!");
}
else
printf("\nInvalid input!!!");
printf("\n\nDo you want to check the News again?(y/n)\n");
scanf(" %c",&c);
} while (c=='y' || c=='Y');
}
The variable c accepts 'y' or 'n' and the do loop runs through the block again but the value given for var c is taken for var a also and so I get "Invalid input!!! "
Is it possible to reset the var a and var c?