0% found this document useful (0 votes)
22 views

Task 5

The document contains 3 C++ programs that take user input and perform conditional checks. The first program takes a digit from the user and checks if it is even or odd. The second program takes a student's marks in a programming course and checks if they have passed or failed based on a cutoff of 60. The third program takes a student's overall marks, checks it against different thresholds and outputs the corresponding grade from A to D, or marks them as failed if below 60.

Uploaded by

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

Task 5

The document contains 3 C++ programs that take user input and perform conditional checks. The first program takes a digit from the user and checks if it is even or odd. The second program takes a student's marks in a programming course and checks if they have passed or failed based on a cutoff of 60. The third program takes a student's overall marks, checks it against different thresholds and outputs the corresponding grade from A to D, or marks them as failed if below 60.

Uploaded by

umarirfan208
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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