WELCOME TO MY BLOG BY SHABEEB.K

C,C++ PROGRAMMING: FIND LARGEST NUMBER FROM n NUMBERS

Search This Blog

Sunday, 3 November 2013

FIND LARGEST NUMBER FROM 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
#include<iostream.h>
#include<conio.h>
class largenumber
{
long big,n,i,a[50];      //varibles needeed for calculation.

public:

void read()
{
cout<<"ENTER LENGTH HOW MANY NUMBER U WANT TO ENTER\n";
cin>>n;                                        //reciveve array size from user.
cout<<"ENTER "<<n<<" NUMBERS\n";

for(i=0;i<n;i++)
{
cin>>a[i];        //enter array elements until i met equal to maximum size of array.
}
}

void calculate()          //calculation to find largest number ffrom list of numbers in array..
{
big=a[0];

for(i=0;i<n;i++)
{
if(big<=a[i])
big=a[i];
}
}

void display()    
{
cout<<"\nENTERED NUMBERS\n";
for(i=0;i<n;i++)            //display entred array elements to user.
{
cout<<a[i]<<",\t";
}
cout<<"\nTHE GREATER NUMBER IS: "<<big;    //display  biggest number from the array.
 }
};

void main()
{
clrscr();
largenumber s1;

s1.read();
s1.calculate();
s1.display();
getch();
}


No comments:

Post a Comment