WELCOME TO MY BLOG BY SHABEEB.K

C,C++ PROGRAMMING: 2014

Search This Blog

Saturday, 25 January 2014

FIND SUM OF N NUMBERS


 1
 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<iostream.h>
#include<conio.h>

int temp=0;
class sum
{
int a[100];
int size;
int i;
public:
void input();
void calculate();
void display();

void read()
{
cout<<"ENTER ARRAY SIZE\n";
cin>>size;
}

};


void sum::input()
{
cout<<"\nENTER NUMBERS\n";
for(i=0;i<size;i++)
{
cin>>a[i];
}
}

void sum::calculate()
{
for(i=0;i<size;i++)
{
temp=temp+a[i];
}
}


void sum::display()
{
cout<<"\nSUM OF NUMBER IS "<<temp;
}


void main()
{
clrscr();
sum s;
s.read();
s.input();
s.calculate();
s.display();
getch();
}