Need help....

This is a discussion on Need help.... within the C Programming forums, part of the General Programming Boards category; This program is about to make any table by ging the table number ,its starting number & ending number .I ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    12

    Need help....

    This program is about to make any table by ging the table number ,its starting number & ending number .I need a help that when the computer finished his output it shows a message
    i.e "Do you want to Continue or Not [Y----N].

    After showing this message if the user press "Y" the program again start & if the user press "N" then it quit .
    Please can u tell me how can i do this . The source code is as under.

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int t,s,e;
    clrscr();
    printf("\n\tPlease enter the Table Number : ");
    scanf("%d",&t);
    printf("\n\tPlease enter the starting Number : ");
    scanf("%d",&s);
    printf("\n\tPlease enter the Ending Number : ");
    scanf("%d",&e);

    while(s<=e)
    {

    printf("\n%d * %d = %d",t,s,t*s);
    s++;
    }
    getch();
    }

    The out put of my program is suppose the table number is 2,starting number 1 & ending is 10.

    2 * 1 = 2
    2 * 2 = 4
    2 * 3 = 6
    2 * 4 = 8
    2 * 5 = 10
    2 * 6 = 12
    2 * 7 = 14
    2 * 8 = 16
    2 * 9 = 18
    2 * 10= 20

  2. #2
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    Thumbs up

    This should do the trick...

    Code:
    #include<stdio.h>
    #include<conio.h>
    
    main() 
     {
       int t,s,e;
       char continue;  
    
       do {        
         clrscr();
         printf("\n\tPlease enter the Table Number : ");
         scanf("%d",&t);
         printf("\n\tPlease enter the starting Number : ");
         scanf("%d",&s);
         printf("\n\tPlease enter the Ending Number : ");
         scanf("%d",&e);
         while(s<=e) {
            printf("\n%d * %d = %d",t,s,t*s);
            s++;
         }
         printf("Do you want to Continue or Not [Y----N].");
       } while (((continue=getch())=='y')||(continue=='Y'));  
     }
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    char continue;
    Should you really be naming your variables after keywords?

    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768
    oh yeah, I totaly forgot this one... oh well, I think he got the idea.
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21