1.WAP in C++ to enter marks in 3 subject and calculate percentage and grade.cond given below (Using Ternary operator)
Per Grade
90-100 A
80-90 B
70-80 C
0-70 D
2. WAP to enter 3 no.s in and print them in ascending and descending order .(Using Ternary operator)
No thanks OP, we've already gone through the basics ourselves. If you have some code you want help with then we will gladly take a look. Otherwise if you want someone to write it for you then you're looking for the Jobs section.
//1st program
#include<iostream.h>
void main()
{
int m1,m2,m3,p;
cin>>m1>>m2>>m3; //m1,m2,m3 are marks p is %age
p=(m1+m2+m3)/3;
(p>90)?((cout<<'A'):((P>80)?(cout<<'B'):(P>70)?(cout<<'C')):cout<<'D';
}
The line with bold is the one i am facing problem with.
As mentioned by kbw you are not doing what you are required.
90-100 A
80-90 B
70-80 C
0-70 D
You say if p > 90 to output 'A' but you need it to be greater than or equal to 90 so either >= 90 or > 89 you will also have to do this with the other cases.