# [HELP]While Loop

• 12-13-2010
hustlerism
[HELP]While Loop
Can someone help me with while loop? my output is wrong. actually everything seems wrong. Pls help me ASAP.

Quote:

#include <stdio.h>

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

printf("How many group you want to process:");
scanf("%d",&group);

while(n<=group)
{
printf("Enter how many people in group#:",group);
scanf("%d",&nopeople);
printf("Group #\t# of Participants\tTotal Price\n");
printf("========================================== =============\n");

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);

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

}

system("pause");
return 0;
}

n the real output should be like this

Quote:

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;
Quote:

#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
• 12-13-2010
Salem
Tip - it's [code][/code], not [quote][/quote]
• 12-13-2010
tabstop
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.)