Programme-1
#include <iostream>
using namespace std;
int main()
{
string name;
cout << "Enter the name: ";
cin >> name;
cout << "Entered name is: " << name;
return 0;
}
Programme-2
#include <iostream>
using namespace std;
int main()
{
int i;
cin >> i;
cout << i;
return 0;
}
Programme-3
#include <iostream>
using namespace std;
int main()
{
string name;
int age;
cin >> name >> age;
cout << "Name : " << name << endl;
cout << "Age : " << age << endl;
return 0; }
Programme-4
#include <iostream>
using namespace std;
int main()
{
int num;
cout << "Enter the integer: ";
cin >> num;
cout << "Entered integer is: " << num;
return 0;
}
Output
Enter the integer: 10
Entered integer is: 10
#include <iostream>
using namespace std;
int add(int A, int B)
// Return sum of A and B
return A + B;
// Driver Code
int main()
{ // Given two number
int A = 4, B = 11;
// Function call
cout << "sum = " << add(A, B);
return 0;
Output
sum = 15
#include <bits/stdc++.h>
using namespace std;
// Driver code
int main()
int a = 2, b = 3;
cout << "Before swapping a = " << a << " , b = " << b << endl;
// temporary variable
int temp;
// appying swapping algorithm
temp = a; temp=2
a = b; a=3
b = temp;b= 2
cout << "After swapping a = " << a << " , b = << b << endl;
return 0;
Output
Before swapping a = 2 , b = 3
After swapping a = 3 , b = 2
#include <bits/stdc++.h>
using namespace std;
// Driver code
int main()
int a = 25, b = 39;
cout << "Before swapping a = " << a << " , b = " << b << endl;
// applying algorithm
b = a + b; b=25+39=64
a = b - a;a=64- 25=39
b = b - a;b=64-39=25
cout << "After swapping a = " << a << " , b = " << b
<< endl;
return 0;
Output
Before swapping a = 25 , b = 39
After swapping a = 39 , b = 25
#include <iostream>
using namespace std;
int main()
int integerType;
char charType;
float floatType;
double doubleType;
// Calculate and Print
// the size of integer type
cout << "Size of int is: " << sizeof(integerType)
<< "\n";
// Calculate and Print
// the size of doubleType
cout << "Size of char is: " << sizeof(charType) << "\n";
// Calculate and Print
// the size of charType
cout << "Size of float is: " << sizeof(floatType)
<< "\n";
// Calculate and Print
// the size of floatType
cout << "Size of double is: " << sizeof(doubleType)
<< "\n";
return 0;
Output
Size of int is: 4
Size of char is: 1
Size of float is: 4
Size of double is: 8
#include<iostream>
using namespace std;
// Utility function
int areaRectangle(int a, int b)
int area = a * b;
return area;
int perimeterRectangle(int a, int b)
int perimeter = 2*(a + b);
return perimeter;
// Driver code
int main()
int a = 5;
int b = 6;
cout << "Area = " <<
areaRectangle(a, b) <<
endl;
cout << "Perimeter = " <<
perimeterRectangle(a, b);
return 0;
Output:
Area = 30
Perimeter = 22
#include<iostream>
using namespace std;
// Driver code
int main()
{
// We can change values
here for
// different inputs
float P = 1, R = 1, T = 1;
// Calculate simple
interest
float SI = (P * T * R) /
100;
// Print the resultant
value of SI
cout << "Simple Interest =
" << SI;
return 0;
}
Output:
Simple Interest: 0.01
#include <iostream>
using namespace std;
// Returns true if n is
// even, else odd
bool isEven(int n) { return (n % 2 == 0); }
// Driver code
int main()
{
int n = 101;
if (isEven(n))
cout << "Given number is Even";
else
cout << " Given number is Odd";
return 0;
}
#include <bits/stdc++.h>
using namespace std;
// Driver code
int main()
{
int a, b, c;
cout << "Enter the three numbers a, b & c" << endl;
cin >> a >> b >> c;
if (a > b)
{
if (a > c)
{
cout << "The Largest Among Three Numbers is : " << a << endl;
}}
else
{
if (b > c) {
if (b > a)
{
cout << "The Largest Among Three Numbers is : " << b << endl;
}
else {
cout << "The Largest Among Three Numbers is : " << c << endl;
}
}
return 0;
}
Output
Enter the three numbers a, b & c
The Largest Among Three Numbers is :