Answer to Question #1337 in C++ for sam2010

Question #1337
Write a c++ program to accept 5 number usin while and print their sum then print the fifth number and second number and print if second is less or bigger of equal to fifth.
1
Expert's answer
2011-01-13T15:01:39-0500
#include <iostream>
using namespace std;

int main()
{
int i=0,sum=0;
int a[5];
cout<<"Enter five numbers\n";
while(i!=5)
{
& cin>>a[i];
& sum=sum+a[i];
& i++;
}
cout<<"\nSum equals& "<<sum<<endl;
cout<<"Fifth number equqls quot;<<a[4]<<endl;
cout<<"Second number equals& quot;<<a[1]<<endl;
if(a[1]<a[4]) cout<<"Second number is less then fifth\n";
if(a[1]>a[4]) cout<<"Second number is bigger then fifth\n";
if(a[1]==a[4]) cout<<"Second number is equal fifth\n";
system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS