Monday, 23 December 2013

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. (c++ code)

 
#include<iostream>
using namespace std;
#include<conio.h>
int main ()
{
int hd,grade,ts;
float cc;
int c1,c2,c3;

cout<<"enter hardness,carbon content and tensile strength";
cin>>hd>>cc>>ts;

c1= hd>50;
c2= cc<0.7;
c3= ts>5600;

if( c1&&c2&&c3 )
grade= 10;

else if( c1&&c2 )
grade= 9;
else if( c2&&c3 )
grade= 8;
else if( c1&&c3 )
grade= 7;
else if( c1 && c2 && c3 )
grade=6;
else
grade= 5;
cout<<"grade of steel="<<grade;
getch();
return 0;

/*  Letuswithc:

       this page is designed to help you learn C or C++.
  Understandable C and C++ programming tutorials, compiler reviews, source code, tips and tricks. 
         */
         }

4 comments: