Assignment:
Write a program segment to store a list of ten integers (input by the user from the keypad) in an array; then display a table similar to the following showing each array element value and what percentage each values is of the total of all ten values in the array.
I wrote the program but I am getting errors. Do i need to put something in my library to make this work?
My errors:
(15) : error C2065: 's' : undeclared identifier
(15) : error C2059: syntax error : 'bad suffix on number'
(15) : error C2017: illegal escape sequence
(15) : error C2146: syntax error : missing ')' before identifier 's'
(15) : error C2001: newline in constant
(17) : warning C4552: '<' : operator has no effect; expected operator with side-effect
(17) : error C2143: syntax error : missing ';' before ')'
(17) : error C2143: syntax error : missing ';' before ')'
(17) : error C2143: syntax error : missing ';' before '{'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include "Homework.h"
using namespace std;
int main (void)
{
int n[ 30 ];
int i;
for ( i = 0; i < 30; i++ ) {
n[ i ] = 0;
}
printf( %s%13s\n", "Element", "Value" ) ;
for ( i = 0; i < 30; i++ ) {
printf( "%7d%13d\n", i, n[ i ] ) ;
}
system("pause");
return 0;
}
|
I have in my library now: