Intro to C++
 Session 4- Four Sample C++ Programs
By Coding-Bootcamps.com
#####################################################
#####################################################
#####################################################

Program #1
//Program to find out the given number is odd or even
#include <iostream> 
using namespace std;

int main()
{
	int n;
	cout << "Enter the number = ";
	cin >> n;

	if (n % 2 == 0) //% is used to calculate the remainder
		cout << "The number is even";
	else 
		cout << "The number is odd";

	return 0;
}
#####################################################
Program #2
//Program to find out the greater number from given numbers
#include <iostream>
using namespace std;

int main()
{
	int a, b, c, max;
	cout << "Enter the value of a = ";
	cin >> a;
	cout << "Enter the value of b = ";
	cin >> b;
	cout << "Enter the value of c = ";
	cin >> c;
	if (a > b)
		max = a;
	else
		max = b;
	if (c > max)
		max = c;
	cout << "The Greater number is = " << max;

	return 0;
}

#####################################################
Program #3
//Program to find out the grade of given marks
#include <iostream>
using namespace std;

int main() {
	int mark;
	string grade;
	cout << "Please enter a mark number: " << endl;
	cin >> mark;
	if (mark >= 85) {
		grade = "A+";
	}
	else if (mark >= 80) {
		grade = "A";
	}
	else if (mark >= 75) {
		grade = "B";
	}
	else if (mark >= 70) {
		grade = "C";
	}
	else if (mark >= 65) {
		grade = "D";
	}
	else {
		grade = "F";
	}
	cout << "The grade given is " << grade;
	return 0;
}

#####################################################
Program #4
//Program to find out the smaller number from given numbers
#include <iostream>
using namespace std;
int main()
{
	int a, b, c, min;
	cout << "Enter the value of a = ";
	cin >> a;
	cout << "Enter the value of b = ";
	cin >> b;
	cout << "Enter the value of c = ";
	cin >> c;
	if (a < b && a < c) min = a;
	if (b < a && b < c) min = b;
	if (c < a && c < b) min = c;
	cout << "The Smaller number is = " << min;
	return 0;
}
#####################################################