Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a C++ program that reads 3 integer numbers from keyboard, with proper i

ID: 3627990 • Letter: 1

Question

1. Write a C++ program that reads 3 integer numbers from keyboard, with proper input prompt, and then display the smallest number. You may assume that these 3 numbers are distinct in value (indicating this in the prompt for data), or consider a number to be the smallest if there is no other number that is smaller in value.

2. Write a C++ program making use of an if-else chain. The program reads in a mark (in float) and then output the grade (in char) according to the following marking scheme:
i. The grade is 'H' if 85 <= mark <= 100
ii. The grade is 'D' if 75 <= mark < 85
iii. The grade is 'C' if 65 <= mark < 75
iv. The grade is 'P' if 50 <= mark < 65
v. The grade is 'F' if 0 <= mark < 50
The program should display message like "invalid mark for a grade" if the mark is out of the range of [0, 100].

Explanation / Answer

1)

#include<iostream>
using namespace std;
int main()
{
int a,b,c,min;
cout << "Enter First number :" <<endl;
cin >>a;
min = a;
cout << "Enter Second number :" <<endl;
cin >>b;
if(b < min) min = b;
cout << "Enter Third number :" <<endl;
cin >>c;
if(c < min) min = c;
cout << "Smallest number given by" << min << endl;
return 0;
}

2)

#include<iostream>
using namespace std;
int main()
{
double mark;
cout << "Enter no of marks";
cin >> mark;

cout << endl;
if(mark < 0 || mark >100)
cout << " invalid mark for a grade" << endl;
else if(mark>=85 && mark<=100)
cout << " grade is H" << endl;
else if(mark>=75 && mark<=85)
cout << " grade is D" << endl;
else if(mark>=65 && mark<=75)
cout << " grade is C" << endl;
else if(mark>=50 && mark<=65)
cout << " grade is P" << endl;
else
cout << " grade is F" << endl;
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote