0% found this document useful (0 votes)
2 views4 pages

Find Largest Number and Grade

The document contains C++ code snippets for two programs: one that finds the largest of four numbers and another that finds the largest of three numbers. Additionally, it includes a program that assigns letter grades based on a user's input marks. The code demonstrates the use of conditional statements to determine outputs based on user input.

Uploaded by

rashsach1204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Find Largest Number and Grade

The document contains C++ code snippets for two programs: one that finds the largest of four numbers and another that finds the largest of three numbers. Additionally, it includes a program that assigns letter grades based on a user's input marks. The code demonstrates the use of conditional statements to determine outputs based on user input.

Uploaded by

rashsach1204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <iostream>

int main() {

int num1, num2, num3, num4;

std::cout << "Enter four numbers: ";

std::cin >> num1 >> num2 >> num3 >> num4;

int largest;

if (num1 >= num2 && num1 >= num3 && num1 >= num4) {

largest = num1;

} else if (num2 >= num1 && num2 >= num3 && num2 >= num4) {

largest = num2;

} else if (num3 >= num1 && num3 >= num2 && num3 >= num4) {

largest = num3;

} else {

largest = num4;

std::cout << "The greatest number is: " << largest << std::endl;

return 0;

#include <iostream> // Required for input/output operations

int main() {
int num1, num2, num3; // Declare three integer variables to store the
numbers

// Prompt the user to enter the three numbers

std::cout << "Enter the first number: ";

std::cin >> num1;

std::cout << "Enter the second number: ";

std::cin >> num2;

std::cout << "Enter the third number: ";

std::cin >> num3;

// Determine the greatest number using if-else if-else statements

if (num1 >= num2 && num1 >= num3) {

std::cout << "The greatest number is: " << num1 << std::endl;

} else if (num2 >= num1 && num2 >= num3) {

std::cout << "The greatest number is: " << num2 << std::endl;

} else {

std::cout << "The greatest number is: " << num3 << std::endl;

return 0; // Indicate successful program execution

Int main(){

Int marks;
Cout<<”Enter Your Marks: “;

Cin>>marks;

If (marks >= 90){

Cout<<”Your Grade is A+”;

Else if (marks >= 80){

Cout<<”Your Grade is A”;

Else if (marks >= 70){

Cout<<”Your Grade is B+”;

Else if (marks >= 60){

Cout<<”Your Grade is B”;

Else if (marks >= 50){

Cout<<”Your Grade is C”;

Else if (marks >= 40){

Cout<<”Your Grade is D”;

Else if (marks >= 30){

Cout<<”Your Grade is E”;

Else if (marks <= 30){

Cout<<”Your Grade is F”;

Else{
Cout<<”Enter Valid Marks”;

Return 0;

You might also like