You are here:   HomeC Programming (Theory)Control Structures in CAdd numbers until a negative or zero is encountered

# Write a C 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.

by Dinesh Thakur Category: Control Structures

```A certain grade of steel is graded according to the following conditions:

(1) Hardness must be greater than 50

(2) Carbon content must be less than 0.7

(3) Tensile strength must be greater than 5600

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 one condition is met

Grade is 5 if none of the conditions are met

#include<stdio.h>

#include<conio.h>

void main()

{

float hard, carbon, tensile;

clrscr();

printf("Hardness of steel:");

scanf("%f",&hard);

printf(“Carbon content:");

scanf("%f",&carbon);

printf("Tensile strength:");

scanf("%f",&hard);

if(hard>50&&carbon<0.7&& tensile>5600)

{

printf("\nPress any key to exit.");

getch();

exit();

}

if(hard>50&&carbon<0.7&&tensile<=5600)

{

printf("\n Press any key to exit.");

getch();

exit();

}

if(hard<= 50&&carbon<0.7&&tensile>5600)

{

printf("\n press any key to exit.");

getch();

exit();

}

If(hard>50&&carbon>=0.7&&tensile>5600)

{

printf("\n press any key to exit.");

getch();

exit();

}

if(hard>50||carbon<0.7||tensile>5600)

{

printf("\n press any key to exit.”);

getch();

exit();

}

printf("\nPress any key to exit.");

getch();

}

OUTPUT:

Hardness of steel: 37

Carbon content: 0.4

Tensile strength: 4000

Press any key to exit.
```

 Name E-mail

Dinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.

What's New and Popular

Popular Article

Search Content

Basic Courses