Professional Documents
Culture Documents
#include <iostream>
int main()
char oper;
switch (oper)
case '+':
break;
case '-':
break;
case '*':
break;
case '/':
break;
default:
break;
return 0;
}
Output:
+65
11
- 10 5
/ 10 5
2
Experiment -2-: Write a C++ program to print right angled (Right oriented)
pyramid of numbers.
#include <iostream>
int main()
cin>>rows;
cout<<"\t";
cout<<k<<"\t";
k++;
cout<<"\n";
return 0;
Output:
2 3
4 5 6
7 8 9 10
5
2 3
4 5 6
7 8 9 10
11 12 13 14 15
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
Experiment-3: Write a C++ program to add two integer numbers
using class and Objects
#include <iostream>
using namespace std;
class Numbers
{
private:
int a;
int b;
public:
void readNumbers(void);
void printNumbers(void);
int calAddition(void);
};
void Numbers::readNumbers(void)
{
cin>>a;
cin>>b;
}
void Numbers::printNumbers(void)
{
cout<<"a= "<<a<<" b= "<<b<<endl;
}
int Numbers::calAddition(void)
{
return (a+b);
}
int main()
{
Numbers num;
int add;
num.readNumbers();
add=num.calAddition();
num.printNumbers();
cout<<add<<endl;
return 0;
}
Output:
45 45
a= 45 b= 45
90
35 45
a= 35 b= 45
80
15 45
a= 15 b= 45
60