Part 3: Complete a Program Complete the program below so that it will allow the
ID: 3596910 • Letter: P
Question
Part 3: Complete a Program Complete the program below so that it will allow the user to enter a number and then determine if that number is odd or even. HINT: use modulus operator with integer division. If we divide an integer by 2 and the remainder is 0 the number is even, and any other result the number is odd. HINT: You will need two simple if statements to process this program, eachif statement when true will process a statement block more than one statement enclosed in curly braces : // Enter a number and determine if it is odd or even nclude include # include using namespace std; int main) // declare variables int num // enter data cout numl ?72// do processing 2?2// display output return 0 Run the program twice, the first time enter 44 and the second time enter 23·The output should look like this: The number 44 is even The number 23 is odd Part 4: Write a Program A student has a percentage mark for an examination:; these marks are to be converted to grades as follows: 70 A 60.69 'B' 50.59 0-49 D 30-39E' 30 F Write a program using switch statement to assign grades as described. (Use the fact that mark/10 gives the first digit of the mark)Explanation / Answer
PART 3
// PROGRAM TO DETERMINE NUMBER IS ODD OR EVER
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
int num1;
cout << "Enter a positive integer";
cin >> num1;
// Checking if number is odd or even
if ( num1 %2 == 0)
cout << "The number " << num1 << " is even";
else
cout << "The number " << num1 << " is odd";
return 0;
}
PART 4 :
Converting marks percentage to grade
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
char grade;
int marks,i;
cout << "Enter the percentage mark";
cin >> marks;
i=marks/10;
switch(i)
{
case 3 :
grade='E';
break;
case 4 :
grade='D';
break;
case 5 :
grade='C';
break;
case 6 :
grade='B';
break;
case 7 :
grade='A';
break;
default :
grade='F';
break;
}
cout << "Grade : " <<grade;
return 0;
}