c++ program to find out the maximum of 10 numbers accepted from the user
C++ program to print max of 10 numbers?
#include %26lt;iostream.h%26gt;
#define INPUT_COUNT 10
main()
{
int i;
int number;
int max;
for ( i = 0; i %26lt; INPUT_COUNT; i++ )
{
cout %26gt;%26gt; "Input #" %26gt;%26gt; (i+1);
cin %26lt;%26lt; number;
if (( i == 0 ) || ( number %26gt; max ))
max = number;
}
cout %26gt;%26gt; "The maximum number was " %26gt;%26gt; max;
}
Reply:#include %26lt;iostream%26gt;
#include %26lt;vector%26gt;
int main()
{
std::vector%26lt;int%26gt; Numbers;
int temp = 0;
for (int i = 0; i %26lt; 10; i++)
{
std::cout %26lt;%26lt; "\nEnter number: ";
std::cin %26gt;%26gt; temp;
Numbers.push_back(temp);
}
for (int i = 0; i %26lt; Numbers.size(); i++)
{
std::cout %26lt;%26lt; "\nNumber " %26lt;%26lt; i+1 %26lt;%26lt; "
: " %26lt;%26lt; Numbers[i];
}
return 0;
}
Reply:#include%26lt;iostream.h%26gt;
{
int a,b,c,d,e,f,hi,j
{
cin%26gt;%26gt;"input a number";%26gt;%26gt;a;
cin%26gt;%26gt;"input a number";%26gt;%26gt;b;
cin%26gt;%26gt;"input a number";%26gt;%26gt;c;
cin%26gt;%26gt;"input a number";%26gt;%26gt;d;
cin%26gt;%26gt;"input a number";%26gt;%26gt;e;
cin%26gt;%26gt;"input a number";%26gt;%26gt;f;
cin%26gt;%26gt;"input a number";%26gt;%26gt;g;
cin%26gt;%26gt;"input a number";%26gt;%26gt;h;
cin%26gt;%26gt;"input a number";%26gt;%26gt;i;
cin%26gt;%26gt;"input a number";%26gt;%26gt;j;
cout%26lt;%26lt;"ur no.s are"%26lt;%26lt;a;b;c;d;e;f;g;h;i;j:
}
}
deliver flowers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment