By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,261 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,261 IT Pros & Developers. It's quick & easy.

C++ help!!!!!!

P: 1
i have this homework; I am supose to write the program due this afternoon please help me!!
it says first:

Write a program that, Prompts the user to input five decimal numbers;
Prints the five decimal numbers
Converts each decimal number to the nearest integer
Adds the fve integers
Prints the sum and average of the five integers

i must send it by 5:00-6:00
Oct 1 '06 #1
Share this Question
Share on Google+
1 Reply


P: 14
#include <iostream.h>

void main(void)
{ float mat[5]; /// it is ulikely that the user imputs mor then this
char test='y';
int i=0,j=0;
int dd[5];

/// reads the numbers//////
while(i<5)
{cout<<" next number = ";
cin>>mat[i];
if(i==3) cout<<"this is the last number ";

i++;
}

////////////////////////////////////////////////////////////////////////////


/*Prints the five decimal numbers && Converts each decimal number to the nearest integer */

for(int i=0;i<5;++i)
{
cout<<mat[i]<<" ";
dd[i]=mat[i];
}
cout<<endl<<endl;
//////////////////////////////////////////////////////////////////////////



////Prints the five integer numbers
for(int i=0;i<5;++i)
cout<<dd[i]<<" ";
////////////////////////////////////////////////////////

for(int i=0;i<5;++i)
j=j+dd[i];

cout<<"sume is "<<j;

cout<<"average is"<<(float)j/(float)5;
system("PAUSE");
}
Oct 1 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.