Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
11 views11 pages

Conditional Statementslevel3

Uploaded by

munikumarsvec143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views11 pages

Conditional Statementslevel3

Uploaded by

munikumarsvec143
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

1. #include<stdio.

h>
int main()

float weight,height,result;

scanf("%f %f",&weight,&height);

result=(weight/height)/height;

result=result*10000;

if(result<18.5)

printf("Underweight");

else if(result>=18.5&&result<=24.9)

printf("Healthyweight");

else if(result>=25.0&&result<=29.9)

printf("Overweight");

else

printf("Obesity");

2.

#include<stdio.h>

#include<math.h>

int main()

float hip_circumference,height,BAI;

char ch;

int age;

scanf("%f %f",&hip_circumference,&height);

scanf("%d\n",&age);

scanf("%c",&ch);

BAI=((hip_circumference/(pow(height/100,1.5)))-18);

if(ch=='f')

switch(age)

case 20 ... 39:

if(BAI<21)

printf("Underweight");

else if(BAI>=21&&BAI<=33)

printf("Healthyweight");

else if(BAI>=34&&BAI<=39)

printf("Overweight");

else

printf("Obesity");

break;

case 40 ... 59:

if(BAI<23)

printf("Underweight");
else if(BAI>=23&&BAI<=35)

printf("Healthyweight");

else if(BAI>=36&&BAI<=41)

printf("Overweight");

else

printf("Obesity");

break;

case 60 ... 79:

if(BAI<25)

printf("Underweight");

else if(BAI>=25&&BAI<=38)

printf("Healthyweight");

else if(BAI>=39&&BAI<=43)

printf("Overweight");

else

printf("Obesity");

break;

else if(ch=='m')

switch(age)

case 20 ... 39:

if(BAI<8)

printf("Underweight");

else if(BAI>=8&&BAI<=21)

printf("Healthyweight");

else if(BAI>=22&&BAI<=26)

printf("Overweight");

else

printf("Obesity");

break;

case 40 ... 59:

if(BAI<11)

printf("Underweight");

else if(BAI>=11&&BAI<=23)

printf("Healthyweight");

else if(BAI>=24&&BAI<=29)

printf("Overweight");

else

printf("Obesity");

break;
}

case 60 ... 79:

if(BAI<13)

printf("Underweight");

else if(BAI>=13&&BAI<=25)

printf("Healthyweight");

else if(BAI>=26&&BAI<=31)

printf("Overweight");

else

printf("Obesity");

break;

3.

#include<stdio.h>

int main()

int waist_inches,hip_inches;

scanf("%d %d\n",&waist_inches,&hip_inches);

char gender;

scanf("%c",&gender);

float WHR;

WHR=(float)waist_inches/hip_inches;

switch(gender)

case 'm':

if(WHR<0.90)

printf("Normalweight");

else if(WHR>=0.90&&WHR<=0.99)

printf("Overweight");

else

printf("Obesity");

break;
}

case 'f':

if(WHR<0.80)

printf("Normalweight");

else if(WHR>=0.80&&WHR<=0.84)

printf("Overweight");

else

printf("Obesity");

break;

4.

include<stdio.h>

int main()

int month_num,room_type,no_of_rooms,total_days,total;

scanf("%d %d %d %d",&month_num,&room_type,&no_of_rooms,&total_days);

if(room_type==1)

total=(1000*no_of_rooms)*total_days;

else if(room_type==2)

total=(2000*no_of_rooms)*total_days;

else if(room_type==3)

total=(5000*no_of_rooms)*total_days;

else if(room_type==4)

total=(8000*no_of_rooms)*total_days;

switch(month_num)

case 1 ... 3:

printf("Rs.%.2f",total-(total*0.05));

break;
}

case 4 ... 5:

printf("Rs.%.2f",total-(total*0.10));

break;

case 6 ... 9:

printf("Rs.%.2f",total-(total*0.20));

break;

case 10 ... 11:

printf("Rs.%.2f",total-(total*0.15));

break;

case 12:

printf("Rs.%.2f",total-(total*0.05));

break;

5.

#include<stdio.h>

int main()

int day_of_week,no_of_persons_Veg,no_of_persons_NonVeg,veg_amount,nonveg_amount;

float amount,offer;

scanf("%d %d %d",&day_of_week,&no_of_persons_Veg,&no_of_persons_NonVeg);

int no_of_persons=no_of_persons_Veg+no_of_persons_NonVeg;

if(no_of_persons>=8)

no_of_persons=no_of_persons-(no_of_persons/8);
if(day_of_week==1 || day_of_week==7)

veg_amount=no_of_persons_Veg*850;

nonveg_amount=no_of_persons_NonVeg*950;

else

veg_amount=no_of_persons_Veg*750;

nonveg_amount=no_of_persons_NonVeg*850;

amount=veg_amount+nonveg_amount;

if(day_of_week!=4)

printf("%.2f",amount);

else

offer=amount-(amount*0.10);

printf("%.2f",offer);

6.

#include<stdio.h>

#include<math.h>

int main()

int start_hour,start_min;

int end_hour,end_min;

scanf("%d %d",&start_hour,&start_min);

scanf("%d %d",&end_hour,&end_min);

int total_sec1,result,hour,min;

int total_sec2;

total_sec1=(start_hour*3600)+(start_min*60);

total_sec2=(end_hour*3600)+(end_min*60);
if(total_sec1==total_sec2)

printf("On time");

else if(total_sec1<total_sec2)

result=abs(total_sec1-total_sec2);

hour=result/3600;

min=(result%3600)/60;

if(hour>0)

printf("Late\n");

printf("%d:%02d hours after the start",hour,min);

else

printf("Late\n");

printf("%d minutes after the start",min);

else

result=abs(total_sec1-total_sec2);

hour=result/3600;

min=(result%3600)/60;

if(hour>0)

printf("Early\n");

printf("%d:%02d hours before the start",hour,min);

else if(hour==0 && min<=30)

printf("On time\n");

printf("%d minutes before the start",min);


}

else

printf("Early\n");

printf("%d minutes before the start",min);

7.

#include<stdio.h>

int main()

int kilometer,day_night;

scanf("%d %d",&kilometer,&day_night);

if(kilometer<20)

if(day_night==1)

printf("Rs.%d",kilometer*79);

else

printf("Rs.%d",kilometer*90);

else if(kilometer>=20&&kilometer<=99)

printf("Rs.%d",kilometer*9);

else

printf("Rs.%d",kilometer*6);

8.

include<stdio.h>
int main()

int screening,total_adult,total_children,total;

float amount_after_gst;

scanf("%d %d %d",&screening,&total_adult,&total_children);

if(screening==1)

total=((total_adult+total_children)*350)-(total_children*50);

else

total=((total_adult+total_children)*150)-(total_children*50);

amount_after_gst=total+(total*0.075);

printf("%.2f",amount_after_gst);

9.

#include<stdio.h>

int main()

int hours,days,workers,total_days;

scanf("%d %d %d",&hours,&days,&workers);

total_days=(10*days)*0.1;

total_days=(days*10-total_days)*workers;

if(total_days-hours>0)

printf("Yes! %d hours left",total_days-hours);

else

printf("Not enough time! %d hours needed",hours-total_days);

#include<stdio.h>

int main()

int hours,days,workers,total_days;
scanf("%d %d %d",&hours,&days,&workers);

total_days=(10*days)*0.1;

total_days=(days*10-total_days)*workers;

if(total_days-hours>0)

printf("Yes! %d hours left",total_days-hours);

else

printf("Not enough time! %d hours needed",hours-total_days);

10.

include<stdio.h>

int main()

int no_of_holidays,working_days,total,difference;

scanf("%d",&no_of_holidays);

working_days=365-no_of_holidays;

total=(working_days * 63 + no_of_holidays * 127);

difference=30000-total;

if(difference>0)

printf("Tom sleeps well\n%d hours and %d minutes more for play",difference/60,difference%60);

else

printf("Tom will run away\n%d hours and %d minutes less for play",(difference/60)*-1,(difference%60)*-1);

You might also like