Friday, July 14, 2006

Evaluation of Steel Grades

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 (1) and (2) are met
Grade is 8 if (2) and (3) are met
Grade is 7 if (1) and (3) are met
Grade is 6 if only one condition is met
Grade is 5 if none of the conditions is met

Write a program which will require the user to give the values of hardness,
carbon content and tensile strength of the steel under consideration and output
the grade of the steel.


#include<stdio.h>
main()
{
int hardness, ts, grade;

float carbon;

printf("Enter the values of hardness, tensile strength and carbon content in the steel:");
scanf("%d %d %f", &hardness, &ts, &carbon);

if ((hardness>50) && (carbon<0.7) && (ts>5600))

printf("Grade 10");
else if ((hardness>50) && (carbon<0.7))

printf("Grade 9");
else if ((carbon<0.7) && (ts>5600))

printf("Grade 8");
else if ((hardness>50) && (ts>5600))

printf("Grade 7");
else if ((hardness>50) || (carbon<0.7) || (ts>5600))

printf("Grade 6");
else
printf("Grade 5");

}



The file can be downloaded at:
Download File

No comments: