bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

commit 900d094f0ed1b8929f96ec7a191905f900de9497
parent 76ca6d4e9798426f06fe63728f30c31a6dc5ee4b
Author: Amit Dutta <amitdutta4255@gmail.com>
Date:   Sat,  4 Oct 2025 18:19:06 +0530

new 21,22

Diffstat:
Aletusc-exercises/luc021.c | 70++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aletusc-exercises/luc022.c | 44++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/letusc-exercises/luc021.c b/letusc-exercises/luc021.c @@ -0,0 +1,69 @@ +/* A certain grade of steel is graded according to the following conditions: + (i) Hardness must be greater than 50 + (ii) Carbon content must be less than 0.7 + (iii) Tensile strength must be greater than 5600 + +The grades are as follows: + Grade is 10 if all three conditions are met + Grade is 9 if conditions (i) and (ii) are met + Grade is 8 if conditions (ii) and (iii) are met + Grade is 7 if conditions (i) and (iii) are met + Grade is 6 if only one condition is met + Grade is 5 if none of the conditions are met + +Write a program, which will require the user to give values of hardness, +carbon content and tensile strength of the steel under consideration and output +the grade of the steel. */ + +/* Author - Amit Dutta, Date - 4rd OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 71, Qn No.: D(c) */ + +#include <stdio.h> +int main() +{ + double hardness, carbon_content, tensile_strength; + printf("Enter the details of the steel below - \n"); + printf("1. Hardness : "); + scanf("%lf", &hardness); + printf("2. Carbon Content : "); + scanf("%lf", &carbon_content); + printf("3. Tensile Strength : "); + scanf("%lf", &tensile_strength); + + // storing how many conditions are met as boolean result + int condition_met, condition1, condition2, condition3; + condition1 = hardness > 50; + condition2 = carbon_content < 0.7; + condition3 = tensile_strength > 5600; + condition_met = condition1 + condition2 + condition3; + + // now grading according the result + int grade; + if (condition_met == 3) + grade = 10; + else if (condition_met == 2) + { + if (condition1 && condition2) + grade = 9; + else if (condition2 && condition3) + grade = 8; + else if (condition1 && condition3) + grade = 7; + } + else if (condition_met == 1) + grade = 6; + else + grade = 5; + + // printing the result + printf("\n------------- Result -------------"); + printf("\n1. Hardness : Condition %s", condition1 ? "MET" : "DID NOT MET"); + printf("\n2. Carbon Content : Condition %s", condition2 ? "MET" : "DID NOT MET"); + printf("\n3. Tensile Strength : Condition %s", condition3 ? "MET" : "DID NOT MET"); + printf("\nTotal Condition Met : %d", condition_met); + printf("\n\nGrade : %d\n\n", grade); + return 0; +} + +/* I did not used this long variable names. I used very short just the first letter of the word. +After writting the whole program, I just renamed the valiables. This is possible in Visual Stdio Code. */+ \ No newline at end of file diff --git a/letusc-exercises/luc022.c b/letusc-exercises/luc022.c @@ -0,0 +1,43 @@ +/* The Body Mass Index (BMI) is defined as ratio of weight of the +person (in Kilograms) to square of the height (in meters). +Write a program that receives weight and height, calculate the BMI, and reports +the BMI catagory as per the following table. + BMI Catagory BMI + Starvation < 15 + Anorexic 15.1 to 17.5 + Underweight 17.6 to 18.5 + Ideal 18.6 to 24.9 + Overweight 25 to 25.9 + Obese 30 to 39.9 + Morbidly Obese >= 40 +*/ +/* Author - Amit Dutta, Date - 4rd OCT, 2025 */ +/* Let Us C, Chap- 4, Page - 71, Qn No.: D(d) */ + +#include <stdio.h> + +int main() +{ + double weight, height, bmi; + printf("Enter your Weight (in Kilograms) and Height (in Meters) : "); + scanf("%lf %lf", &weight, &height); + bmi = weight / (height * height); + printf("\nCalculated BMI : %g", bmi); + if (bmi < 15) + printf("\nBMI Catagory : Starvation"); + else if (bmi >= 15.1 && bmi <= 17.5) + printf("\nBMI Catagory : Anorexic"); + else if (bmi >= 17.6 && bmi <= 18.5) + printf("\nBMI Catagory : Underweight"); + else if (bmi >= 18.6 && bmi <= 24.9) + printf("\nBMI Catagory : Ideal"); + else if (bmi >= 25 && bmi <= 25.9) + printf("\nBMI Catagory : Overweight"); + else if (bmi >= 30 && bmi <= 39.9) + printf("\nBMI Catagory : Obese"); + else if (bmi >= 40) + printf("\nBMI Catagory : Morbidly Obese"); + else + printf("\nBMI Catagory : Unclassified"); + return 0; +}+ \ No newline at end of file
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror