Thread: Newbie in problem with looping

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    2

    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
    Last edited by nrain; 11-04-2005 at 08:19 AM. Reason: addition

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structure Array Looping Problem
    By Vitamin_C in forum C++ Programming
    Replies: 2
    Last Post: 12-17-2005, 03:22 PM
  2. Problem with looping.
    By rina in forum C Programming
    Replies: 9
    Last Post: 10-05-2005, 01:21 AM
  3. newbie Windows problem...
    By gcn_zelda in forum Windows Programming
    Replies: 9
    Last Post: 06-07-2003, 02:14 PM
  4. Looping Problem
    By simly01 in forum Windows Programming
    Replies: 1
    Last Post: 06-28-2002, 01:05 AM
  5. newbie coding problem
    By rippascal in forum C++ Programming
    Replies: 10
    Last Post: 01-08-2002, 11:45 PM