Answer to Question #172166 in C++ for Raj

Question #172166

Develop a C++ program to get the CGPA and print the following status according to the given CGPA by using else if ladder statement. [Note: Use call by value]


1. CGPA < 50 "FAIL"


2. 50 >= CGPA <=60 "FIRST"


3. 60 > CGPA <=70 "SECOND"


4. 70 > CGPA <=80 "THIRD"


5. CGPA >80 "DISTINCTION"


1
Expert's answer
2021-03-18T03:30:12-0400
#include <iostream>
#include <string>
using namespace std;

string  getstatus(int arg) {
   string result;
    if (arg < 50) {
        result =  "FAIL";
    }
    else if (arg >= 50 && arg <= 60) {
        result  = "FIRST";
    }
    else if (arg >60 && arg <=70) {
        result = "SECOND";
    }
    else if (arg >70 && arg <= 80) {
        result = "THIRD";
    }
    else if (arg > 80) {
        result = "DISTINCTION";
    }
    return result;
}
int main()
{
 int  cpgaCount;
    string cpgaStatus;
    std::cout << "Enter an integer number of CGPA points: ";
    std::cin >> cpgaCount;
    cpgaStatus = "Current status: " + getstatus(cpgaCount);
    std::cout << cpgaStatus << std::endl;
}

 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS