You are on page 1of 3

Task 5

Umar Irfan
Roll No:93

1. Ask the user to enter a digit and check whether this digit is even
or odd.

#include <iostream>
using namespace std;
int main()
{
int digit;
cout << "Enter a digit: ";
cin >> digit;
if (digit % 2 == 0)
{
cout << digit << " is an even number." << endl;
}
else
{
cout << digit << " is an odd number." << endl;
}
return 0;
}
2.Ask the user to enter his marks in the Programming course, if the
marks are greater than equal to 60 then display a message “He is Passed
in the course” otherwise, display message: “ He is Failed”

#include <iostream>
using namespace std;
int main()
{
int marks;
cout << "Enter your marks in Programming course: ";
cin >> marks;

if (marks >= 60)


{
cout << "You have passed the course." << endl;
}
else
{
cout << "You have failed the course." << endl;
}
return 0

3.Ask the user to enter his\her marks and estimate his grade as follows: “A”
if marks are greater than equal to 90, “B” if marks are greater than equal to
80, “C” if marks are greater than or equal to 70, “D” if marks are greater than
or equal to 60, the student will be failed otherwise.

#include <iostream>
using namespace std;
int main()
{
int marks;
cout << "Enter your marks: ";
cin >> marks;
if (marks >= 90)
{
cout << "Your grade is A." << endl;
}
else if (marks >= 80)
{
cout << "Your grade is B." << endl;
}
else if (marks >= 70)
{
cout << "Your grade is C." << endl;
}
else if (marks >= 60)
{
cout << "Your grade is D." << endl;
}
else
{
cout << "You have failed." << endl;
}
return 0;
}

You might also like