Newbie in problem with looping
hii all,
i am a total newbie here and also a BRAND NEW learner of C
as a part of my first assignment in class i have done the following
coding. but having problem wth this. is there any one who wishes
to help me??
Code:
#include <stdio.h>
void main()
{
char line;
clrscr();
printf("Choose your initial state:");
line=getchar();
switch(line) {
case '1':
printf("Step 1:\t L==Red\t\t\t\tGreen\n");
case '2':
printf("Step 2:\t L==Red\t\t\t\tAmber\n");
case '3':
printf("Step 3:\t L==Red+Amber\t\t\tRed\n");
case '4':
printf("Step 4:\t L==Green\t\t\tRed\n");
case '5':
printf("Step 5:\t L==Amber\t\t\tRed\n");
case '6':
printf("Step 6:\t L==Red\t\t\t\tRed+Amber\n");
}
getch();
}
My problems are:
1. I want to use looping , but unfortunately both while and for loops are failed.
2. I want to run the loops depending on user demand.
Is there any 1 to help this newbie???
JUST TELL ME IF I NEED TO PRACTICE OR ADD ANY SPECIFIC FUNCTION
IF Any 1 can suggest any good pdf to learn switch & loops with example, I will be grateful