Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###### ####### ###### # # # ####### ### # # #
- # # # # # # # # # # # # # ## #
- # # # # # # # # # # # # # # # #
- ###### ##### ###### ####### # # # # # # # # #
- # # # # # # ####### # # ####### # # #
- # # # # # # # # # # # # # ##
- # ####### # # # # # # # ### # # # #
- Coding ini dibuat hanya untuk rujukan.Bukannya untuk ditiru bulat².
- Sila buat tutorial anda sendiri.Usaha tangga kejayaan.
- /*Ingat yer,kalau nak print simbol "%" dalam C,kena buat mcm ni "%%" sebab nnti takut codeblock salah paham,nnti codeblock igt korg nak buat something mcm %i,%f,%c,%s pulak...*/
- Question 1
- #include<stdio.h>
- int main(void)
- {
- float weight,height,BMI;
- printf("Please enter your weight(kg) : ");
- scanf("%f",&weight);
- printf("\nPlease enter your height (m) : ");
- scanf("%f",&height);
- BMI=weight/(height*height);
- if (BMI<18.5)
- printf("\n\nYour BMI is %.2f.You are underweight",BMI);
- else if (BMI<25)
- printf("\nYour BMI is %.2f.You are normal",BMI);
- else if (BMI<30)
- printf("\nYour BMI is %.2f.You are overweight",BMI);
- else
- printf("Your BMI is %.2f.You are obese",BMI);
- printf("\n\n _____ _ _ _ _ _____ _ ");
- printf("\n/ ___| | (_) | | (_) ___| | |");
- printf("\n\\ `--.| |__ _ _ _ ___| |__ _\\ `--. _ _ __ _ __| |");
- printf("\n `--. \\ '_ \\| | | | |/ __| '_ \\| |`--. \\ | | |/ _` |/ _` |");
- printf("\n/\\__/ / | | | |_| | | (__| | | | /\\__/ / |_| | (_| | (_| |");
- printf("\n\\____/|_| |_|\\__,_|_|\\___|_| |_|_\\____/ \\__, |\\__,_|\\__,_|");
- printf("\n __/ | ");
- printf("\n |___/ ");
- printf("\n ");
- return 0;
- }
- Question 2
- #include<stdio.h>
- int main(void)
- {
- int teacher;
- float total_purchase,tax,new_total,final_total,teacher_disc;
- printf("Is the buyer a teacher ? Enter \"1\" for true and \"0\" for false : ");
- scanf("%i",&teacher);
- printf("\nPlease enter the total purchase : ");
- scanf("%f",&total_purchase);
- //The printing starts here
- printf("\nTotal Purchase %20.2f",total_purchase);
- if (teacher==1)
- {
- if (total_purchase>=100)
- {
- teacher_disc=0.12*total_purchase;
- printf("\nTeacher's discount (12%%) %10.2f",teacher_disc);
- }
- else
- {
- teacher_disc=0.1*total_purchase;
- printf("\nTeacher's discount (10%%) %10.2f",teacher_disc);
- }
- new_total=total_purchase-teacher_disc;
- }
- else
- new_total=total_purchase;
- tax=0.05*new_total;
- printf("\nSales tax (5%%) %20.2f",tax);
- final_total=new_total-tax;
- printf("\nTotal %29.2f",final_total);
- printf("\n\n _____ _ _ _ _ _____ _ ");
- printf("\n/ ___| | (_) | | (_) ___| | |");
- printf("\n\\ `--.| |__ _ _ _ ___| |__ _\\ `--. _ _ __ _ __| |");
- printf("\n `--. \\ '_ \\| | | | |/ __| '_ \\| |`--. \\ | | |/ _` |/ _` |");
- printf("\n/\\__/ / | | | |_| | | (__| | | | /\\__/ / |_| | (_| | (_| |");
- printf("\n\\____/|_| |_|\\__,_|_|\\___|_| |_|_\\____/ \\__, |\\__,_|\\__,_|");
- printf("\n __/ | ");
- printf("\n |___/ ");
- printf("\n ");
- return 0;
- }
- Question 3
- #include<stdio.h>
- int main(void)
- {
- char initial1,initial2,initial3;
- float amount_due,days_due;
- printf("Please enter your initials (3) : \n");
- scanf("%c%c%c",&initial1,&initial2,&initial3);
- printf("\nPlease enter your amount due : ");
- scanf("%f",&amount_due);
- printf("\nPlease enter the number of days overdue : ");
- scanf("%f",&days_due);
- printf("\n\n%c%c%c,",initial1,initial2,initial3);
- if (days_due<=30)
- printf("your penalty is 5%% hence, you have to pay %.2f",1.05*amount_due);
- else if (days_due<=60)
- printf("your penalty is 12%% hence, you have to pay %.2f",1.12*amount_due);
- else
- printf("your penalty is 21%% hence, you have to pay %.2f",1.21*amount_due);
- printf("\n\n _____ _ _ _ _ _____ _ ");
- printf("\n/ ___| | (_) | | (_) ___| | |");
- printf("\n\\ `--.| |__ _ _ _ ___| |__ _\\ `--. _ _ __ _ __| |");
- printf("\n `--. \\ '_ \\| | | | |/ __| '_ \\| |`--. \\ | | |/ _` |/ _` |");
- printf("\n/\\__/ / | | | |_| | | (__| | | | /\\__/ / |_| | (_| | (_| |");
- printf("\n\\____/|_| |_|\\__,_|_|\\___|_| |_|_\\____/ \\__, |\\__,_|\\__,_|");
- printf("\n __/ | ");
- printf("\n |___/ ");
- printf("\n ");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement