Thread: [HELP]While Loop

  1. #1
    Registered User hustlerism's Avatar
    Join Date
    Dec 2010

    [HELP]While Loop

    Can someone help me with while loop? my output is wrong. actually everything seems wrong. Pls help me ASAP.

    #include <stdio.h>

    int main()
    int group,nopeople,noticket,n=1,num=0;
    float totalprice=0;

    printf("How many group you want to process:");

    printf("Enter how many people in group#:",group);
    printf("Group #\t# of Participants\tTotal Price\n");
    printf("========================================== =============\n");


    if (noticket>=1 && noticket<=20)
    printf("%d\t\t%d\t\t%0.2f\n",group,nopeople,5.20*n opeople);

    else if (noticket>=21 && noticket<=30)
    printf("%d\t\t%d\t\t%0.2f\n",group,nopeople,4.85*n opeople);

    else if (noticket>=31 && noticket<=50)
    printf("%d\t\t%d\t\t%0.2f\n",group,nopeople,4.20*n opeople);

    else if (noticket>=51 && noticket<=100)
    printf("%d\t\t%d\t\t%0.2f\n",group,nopeople,3.85*n opeople);

    printf("%d\t\t%d\t\t%0.2f\n",group,nopeople,3.00*n opeople);


    return 0;
    n the real output should be like this

    How many groups you want to process ? 2

    Enter how many people in group#1: 9

    Group# # of Participants Total Price
    1 9 RM46.80

    Enter how many people in group#2: 45

    Group# # of Participants Total Price
    2 45 RM189.00
    ===================== ==========
    TOTAL 54 RM235.80

    n The price ticket is as below;
    #of tickets Price per ticket
    1-20 RM5.20
    21-30 RM4.85
    31-50 RM4.20
    51-100 RM3.85
    Above 100 RM3.00

    *Note RM is the currency of Malaysia

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Tip - it's [code][/code], not [quote][/quote]
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    So what are you getting that you don't want to be getting? (Apart from the overall total at the bottom, since you never add up the individual line items, or even try to print the total.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Poll event loop
    By rogster001 in forum C++ Programming
    Replies: 2
    Last Post: 09-17-2009, 04:28 AM
  2. need help with a loop
    By Darkw1sh in forum C Programming
    Replies: 19
    Last Post: 09-13-2009, 09:46 PM
  3. funny-looking while loop
    By Aisthesis in forum C++ Programming
    Replies: 3
    Last Post: 08-30-2009, 11:54 PM
  4. nested loop, simple but i'm missing it
    By big_brother in forum C Programming
    Replies: 19
    Last Post: 10-23-2006, 10:21 PM
  5. loop issues
    By kristy in forum C Programming
    Replies: 3
    Last Post: 03-05-2005, 09:14 AM