1) Hello World Program
#include <iostream>
using namespace std;
int main() {
cout << "Hello World";
return 0;
}
Output: Hello World
2) Sum of Two Numbers
#include <iostream>
using namespace std;
int main() {
int a = 5, b = 7;
cout << "Sum = " << (a + b);
return 0;
}
Output: Sum = 12
3) Swap Two Numbers
#include <iostream>
using namespace std;
int main() {
int a = 10, b = 20, temp;
temp = a;
a = b;
b = temp;
cout << "a = " << a << ", b = " << b;
return 0;
}
Output: a = 20, b = 10
4) Largest of Two Numbers
#include <iostream>
using namespace std;
int main() {
int a = 15, b = 25;
if(a > b)
cout << "Largest = " << a;
else
cout << "Largest = " << b;
return 0;
}
Output: Largest = 25
5) Check Even or Odd
#include <iostream>
using namespace std;
int main() {
int n = 11;
if(n % 2 == 0)
cout << "Even";
else
cout << "Odd";
return 0;
}
Output: Odd