Sum and Average of Two Numbers
-
Upload
rajat-sangroy -
Category
Documents
-
view
218 -
download
0
Transcript of Sum and Average of Two Numbers
-
8/2/2019 Sum and Average of Two Numbers
1/37
1
//Sum and Average of two numbers
#include
#include
void main()
{
clrscr();
int num1,num2;
float sum,avg;
coutnum1;
coutnum2;
sum=num1+num2;
avg=sum/2;
cout
-
8/2/2019 Sum and Average of Two Numbers
2/37
2
-
8/2/2019 Sum and Average of Two Numbers
3/37
3
//Program to implement break statement
#include
#include
void main()
{
clrscr();
int t;
for(t=1;t
-
8/2/2019 Sum and Average of Two Numbers
4/37
4
-
8/2/2019 Sum and Average of Two Numbers
5/37
5
//Program to create calculator using switch case statement
#include
#include
void main()
{
clrscr();
int ch,num1,num2,s;
cout
-
8/2/2019 Sum and Average of Two Numbers
6/37
6
case 2 : s=num1-num2;
cout
-
8/2/2019 Sum and Average of Two Numbers
7/37
7
//Program to implement continue statement
#include
#include
void main()
{
clrscr();
int i;
for(i=1;i
-
8/2/2019 Sum and Average of Two Numbers
8/37
8
-
8/2/2019 Sum and Average of Two Numbers
9/37
9
//Program to print the Fibonacci series
#include
#include
void main()
{
clrscr();
int a,b,c,n;
a=0;
b=1;
coutn;
cout
-
8/2/2019 Sum and Average of Two Numbers
10/37
10
-
8/2/2019 Sum and Average of Two Numbers
11/37
11
//Program to implement goto statement
#include
#include
void main()
{
clrscr();
int t;
t=1;
loop1:
cout
-
8/2/2019 Sum and Average of Two Numbers
12/37
12
-
8/2/2019 Sum and Average of Two Numbers
13/37
13
//Largest number among three number
#include
#include
void main()
{
clrscr();
int a,b,c;
couta;
coutb;
coutc;
if(a>b && a>c)
cout
-
8/2/2019 Sum and Average of Two Numbers
14/37
14
-
8/2/2019 Sum and Average of Two Numbers
15/37
15
//Program to find the prime number
#include
#include
void main()
{
clrscr();
int i,num;
coutnum;
for(i=2;i
-
8/2/2019 Sum and Average of Two Numbers
16/37
16
-
8/2/2019 Sum and Average of Two Numbers
17/37
17
//Program to print the reverse of a number
#include
#include
void main()
{
clrscr();
int num,a;
coutnum;
cout
-
8/2/2019 Sum and Average of Two Numbers
18/37
18
-
8/2/2019 Sum and Average of Two Numbers
19/37
19
//Program to find the sum of digit of a number
#include
#include
void main()
{
clrscr();
int num,sum=0,a;
coutnum;
do
{
a=num%10;
sum+=a;
num=num/10;
}while(num!=0);
cout
-
8/2/2019 Sum and Average of Two Numbers
20/37
20
-
8/2/2019 Sum and Average of Two Numbers
21/37
21
//Program to print the table of a number
#include
#include
void main()
{
clrscr();
int n,i;
coutn;
for(i=1;i
-
8/2/2019 Sum and Average of Two Numbers
22/37
22
-
8/2/2019 Sum and Average of Two Numbers
23/37
23
//Program to calculate area of circle using while loop
#include
#include
void main()
{
clrscr();
int r;
float area;
coutr;
while(r!=0)
{
area=3.14*r*r;
cout
-
8/2/2019 Sum and Average of Two Numbers
24/37
24
-
8/2/2019 Sum and Average of Two Numbers
25/37
25
//Program to implement Single Dimensional Array
#include
#include
void main()
{
clrscr();
int num[5],i;
cout
-
8/2/2019 Sum and Average of Two Numbers
26/37
26
-
8/2/2019 Sum and Average of Two Numbers
27/37
27
//Program to implement a Two Dimensional Array
#include
#include
void main()
{
clrscr();
int a[3][3],i,j;
for(i=1;i
-
8/2/2019 Sum and Average of Two Numbers
28/37
28
}
-
8/2/2019 Sum and Average of Two Numbers
29/37
29
//Program to implement Nested Function
#include
#include
void func1();
void func2();
void func3();
void main()
{
clrscr();
cout
-
8/2/2019 Sum and Average of Two Numbers
30/37
30
{
cout
-
8/2/2019 Sum and Average of Two Numbers
31/37
31
//Program to get and print the number of Character in String
#include
#include
void main()
{
clrscr();
char book_name[]="Mastering in C++";
int i=0;
while(book_name[i]!='\0')
{
cout
-
8/2/2019 Sum and Average of Two Numbers
32/37
32
-
8/2/2019 Sum and Average of Two Numbers
33/37
33
//Program to implement Recursive Function
#include
#include
void main()
{
int n;
long int factorial(int);
clrscr();
coutn;
if(n
-
8/2/2019 Sum and Average of Two Numbers
34/37
34
-
8/2/2019 Sum and Average of Two Numbers
35/37
35
//Program to implement class concept
#include
#include
class item
{
int number;
float cost;
public:
void getdata(int a,float b);
void pushdata()
{
cout
-
8/2/2019 Sum and Average of Two Numbers
36/37
36
x.getdata(100,299.95);
x.pushdata();
getch();
return 0;
}
-
8/2/2019 Sum and Average of Two Numbers
37/37