Turn Desktop View Off
You are here:   HomeC Programming (Theory)Control Structures in CAdd numbers until a negative or zero is encountered
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
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 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("\nGrade l0");
printf("\nPress any key to exit.");
getch();
exit();
}
if(hard>50&&carbon<0.7&&tensile<=5600)
{
printf ("\nGrade 9");
printf("\n Press any key to exit.");
getch();
exit();
}
if(hard<= 50&&carbon<0.7&&tensile>5600)
{
printf("\nGrade 8");
printf("\n press any key to exit.");
getch();
exit();
}
If(hard>50&&carbon>=0.7&&tensile>5600)
{
printf("\nGrade 7");
printf("\n press any key to exit.");
getch();
exit();
}
if(hard>50||carbon<0.7||tensile>5600)
{
printf("\nGrade 6");
printf("\n press any key to exit.”);
getch();
exit();
}
printf("\nGrade 5");
printf("\nPress any key to exit.");
getch();
}
 
OUTPUT:
 
Hardness of steel: 37
Carbon content: 0.4
Tensile strength: 4000
Grade 9
Press any key to exit.


Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh 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