hi guys, I am a new student in learning C, I have about a month of experience on it and i am learning now how to use loops.
I wanted to write a program using loops in which i ask them to guess a password to a question i ask. (THis was a story of Ali baba , the person just needs to write open sesame to have the right answer
(!Bear with me if my programming is really bad: i know the highlighted area is wrong, any critics harsh or good will be appreciated thanks)
#include<stdio.h>
void main()
{
char KEY = 'a';
char Guess;
char answer;
printf("You have traveled the World's Deserts and you have finally found the cave\n"
"of Ali Baba. You see the cave shut, and you shout the secret words:"
);
scanf("%s",&Guess);
do
{
if (Guess==KEY)
printf( "%s You have opened the Cave and took all the riches of the Bandits, Well Done \n",Guess);
//else if( Guess!=KEY)
//printf( "You hear the sound of hooves closing in on you its the bandits, Please hurry and try again:");
//scanf("%s", &Guess);
}while(Guess!=KEY);
printf( "You hear the sound of hooves closing in on you its the bandits, Please hurry and try again:");
scanf("%s", &Guess);
system("PAUSE");
return 0;
}