12-C-2017-Pract-1. Define a class my array to find the largest and smallest element using
member functions.-Algorithim
Input:
1. size of the array- n
2. Entering the n array elements // declaring variable in private section
Output:
1. largest-l
2. smallest-s
Mehod:
1. start // input(), output(), larg() and small() -public section
2. input()
begin
Read n
Read n array elements // for(i=0;i<n;i++) cin>>a[i];
end
3. larg()
begin
l=a[0];
for(i=1;i<n;i++)
begin
if(l<a[i])
l=a[i];
end.
end
4. small()
begin
s=a[0];
for(i=1;i<n;i++)
begin
if(s>a[i])
s=a[i];
end.
end.
5. output()
begin
write n
write n array element
write l
wite s
end.
6.stop
member functions.-Algorithim
Input:
1. size of the array- n
2. Entering the n array elements // declaring variable in private section
Output:
1. largest-l
2. smallest-s
Mehod:
1. start // input(), output(), larg() and small() -public section
2. input()
begin
Read n
Read n array elements // for(i=0;i<n;i++) cin>>a[i];
end
3. larg()
begin
l=a[0];
for(i=1;i<n;i++)
begin
if(l<a[i])
l=a[i];
end.
end
4. small()
begin
s=a[0];
for(i=1;i<n;i++)
begin
if(s>a[i])
s=a[i];
end.
end.
5. output()
begin
write n
write n array element
write l
wite s
end.
6.stop
No comments:
Post a Comment