C Program :
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 that 0.7
iii) Tensile strength must be greater than 5600
The grades are as follows:
Grade= 10 if all conditions are met.
Grade =9 if conditions i) & ii) are met.
Grade =8 if conditions ii) & iii) are met.
Grade =7 if conditions i) & iii) are met.
Grade =6 if only one condition is met.
Grade =5 ifnone of the conditions is ment.
Write a prog. which will require the user to give values of hardness,
carbon content and tensile strength of steel under consideration and output the grade of steel.
C Programming -->
/* PROG. TO GRADE STEEL ACCORDING TO CRITERIA */
#include<stdio.h>
#include<conio.h>
main()
{
int hd,grade,ts;
float cc;
int c1,c2,c3;
clrscr();
printf("enter hardness,carbon content and tensile strength");
scanf("%d%flllod" ,&hd,&cc,&ts);
/* conditions given */
c1= hd>50;
c2= cc<0.7;
c3= ts>5600;
/* grading the steel */
if( c 1&&c2&&c3 )
grade= 10;
6
else if( c 1&&c2 )
grade= 9;
else if( c2&&c3 )
grade= 8;
else if( c 1&&c3 )
grade= 7;
else if( c lllc211c3 )
grade=6;
else
grade= 5;
printf("grade of steel=%d",grade);
getch();
}
|