Thursday, July 30, 2009

One more C++ Question/Task?

Write a program to accept as many numbers from the keyboard operator as she/he wishes to enter. The numbers should be from 1 to 99. When finished, list each number entered and the number of times that number was entered

One more C++ Question/Task?
#include %26lt;iostream.h%26gt;


int main(void){





int numbers[101];


int x;


for(x=0;x%26lt;100;x++) numbers[x]=0;


int entry=1;





while(entry!=0){


cout%26lt;%26lt;"Enter value from 1-99 (0 to exit) -%26gt;";


cin%26gt;%26gt;entry;


numbers[entry]++;


}





for(x=1;x%26lt;100;x++){


if(numbers[x]) cout%26lt;%26lt;"The number "%26lt;%26lt;x%26lt;%26lt;" was entered "%26lt;%26lt;numbers[x]%26lt;%26lt;" times"%26lt;%26lt;endl;


}


return 0;


}
Reply:Not understanding the answer is the risk you take when you ask strangers to do your homework for you! Report It

Reply:Maybe if you did your own homework, instead of asking others for the solutions, you would know how to do such a simple problem.


No comments:

Post a Comment