You are on page 1of 5

#include<stdio.h> #include<conio.

h> void main() { char gender; int i,j,k,price,age_group,price1,price2,price3,price4,price5,price6,price7,qty_b anana,qty_tofu,qty_wheatbread,qty_roastedchicken,qty_peanutbutter,qty_ricekrispi es,qty_lowfatmilk,temp,max_price,a[7]; float crbs,fats,proteins,sodium,calories,calories1,calories2,calories3,calories4 ,calories5,calories6,calories7,max_calorie; void p();void c(); printf("enter ur budget , age group,gender if male M ,female F "); scanf("%d %d %c",&age,&age_group,&gender); if(gender=M) { if((age_group>16)&&(age_group<18)) { calories=2520; } else if((age_group>=18)&&(age_group<=30)) { calories=2800; } else if((age_group>30)&&(age_group<=50)) { calories=2500; } else if((age_group>50) { calories=2000; } } else { if((age_group>16)&&(age_group<18)) { calories=2200; } else if((age_group>18)&&(age_group<=30)) { calories=2200; } else if((age_group>30)&&(age_group<50)) { calories=2000; } else if((age_group>50) { calories=1800; } crbs=(.74)*calories; fats= (.04)*calories; protien=(.24)*calories; sodium=(.001)*calories;

printf(" "); printf( "srno. Foods Price in Rs. /Serving Calories Total_Fat g Sodium mg Carbohydrates g "); printf(" 1. Banana 25.00 104.9 0.5 1.1 26.7 ); printf(" 2. Tofu 31.00 88.2 5.5 8.1 2.2 "); printf(" 3. Wheat Bread 41.00 65 1 134.5 12.4 "); printf(" 4. 2% Lowfat Milk 30.00 121.2 4.7 121.8 11.7 "); printf(" 5. Roasted Chicken 79.00 277.4 10.8 125.6 0 "); printf(" 6. Peanut Butter 17.00 188.5 16 155.5 6.9 "); printf(" 7. Rice Krispies 27.00 112.2 0.2 340.8 24.8 ");

menu Serving Size Protein g 1 Fruit,Wo/Skn&Seeds 1.2 1/4 block 9.4 1 Sl 2.2 1 C 8.1 1 lb chicken 42.2 2 Tbsp 7.7 1 Oz 1.9

here :printf("enter serial number"); scanf("%d",&n); switch(n) { case 1 : printf("you have selected banana & enter qty"); scanf("%d",&qty_banana); price1=qty_banana*25 ; calories1=qty_banana*104.9; price=price-price1; calories=calories-calories1; if(price<=17) goto price_problem; else if(calories<=65) goto calories_problem printf("do you want to continue , if yes then print 'y' else 'n' for no "); else if goto here; case 2 : printf("you have selected tofu & enter qty"); scanf("%d",&qty_tofu); price2=qty_tofu*31 ; calories2=qty_tofu*88.2; price=price-price2; calories=calories-calories2; if(price<=17) goto price_problem; else if(calories<=65) goto calories_problem printf("do you want to continue , if yes then print 'y' else 'n' for no

"); else if goto here; case 3 : printf("you have selected wheat bread & enter qty"); scanf("%d",&qty_wheatbread); price3=qty_wheatbread*38 ; calories3=qty_wheatbread*65; price=price-price3; calories=calories-calories1; if(price<=17) goto price_problem; else if(calories<=65) goto calories_problem printf("do you want to continue , if yes then print 'y' else 'n' for no "); else if goto here; case 4 : printf("you have selected low fat milk & enter qty"); scanf("%d",&qty_lowfatmilk); price4=qty_lowfatmilk*25 ; calories4=qty_lowfatmilk*104.9; price=price-price4; calories=calories-calories4; if(price<=17) goto price_problem; else if(calories<=65) goto calories_problem printf("do you want to continue , if yes then print 'y' else 'n' for no "); else if goto here; case 5 : printf("you have selected roated chicken enter qty"); scanf("%d",&qty_roastedchicken); price5=qty_roatedchicken*79 ; calories5=qty_banana*277.4; price=price-price5; calories=calories-calories5; if(price<=17) goto price_problem; else if(calories<=65) goto calories_problem printf("do you want to continue , if yes then print 'y' else 'n' for no "); else if goto here; case 6: printf("you have selected peanut butter & enter qty"); scanf("%d",&qty_peanutbutter); price6=qty_peanutbutter*17 ; calories6=qty_banana*188.5; price=price-price6; calories=calories-calories6;

if(price<=17) goto price_problem; else if(calories<=65) goto calories_problem printf("do you want to continue , if yes then print 'y' else 'n' for no "); else if goto here; case 7: printf("you have selected rice krispies & enter qty"); scanf("%d",&qty_ricekrispies); price7=qty_ricekrispies*17 ; calories7=qty_ricekrispies*188.5; price=price-price7; calories=calories-calories7; if(price<=17) goto price_problem; else if(calories<=65) goto calories_problem printf("do you want to continue , if yes then print 'y' else 'n' for no "); else if goto here; price problem : p() { for(int i=0;i<7;i++) { a[i]=price(i+1); } for(int j=o;j<7;j++) { for(int k=j+1;k<j;k++) { if(a[j]>a[i]) { temp=a[k]; a[k]=a[j]; a[j]=temp; } } } max_price=a[6]; printf("maximum price is =%d",max_price); } calorie problem : c() { for(int i=0;i<7;i++) { a[i]=price(i+1); } for(int j=o;j<7;j++) { for(int k=j+1;k<j;k++) { if(a[j]>a[i])

{ temp=a[k]; a[k]=a[j]; a[j]=temp; } } } max_calorie=a[6]; printf("maximum calorie is =%d",max_calorie); } printf("banana %d %d %f",&price1,&qty_banana,&calories1); printf("tofu %d %d %f",&price2,&qty_tofu,&calories2); printf("wheat bread %d %d %f",&price3,&qty_wheatbread,&calories3); printf("low fat milk %d %d %f",&price4,&qty_lowfatmilk,&calories4); printf("roasted chicken %d %d %f",&price5,&qty_roastedchicken,&calories5); printf("peanut butter %d %d %f",&price6,&qty_peanutbutter,&calories6); printf("rice krsipies %d %d %f",&price7,&qty_ricekrispies,&calories7); getch(); }

You might also like