C Write a program that reads in one value you can assume tha

C++

Write a program that reads in one value (you can assume that the value entered is a positive integer) and outputs all of the positive integers that are less than that number. Output values should be separated by spaces, and output in ascending order. The following sample run should give the idea. User inputs are in bold. Enter one value: 12 1 2 3 4 5 6 7 8 9 10 11

Solution

#include <iostream>
using namespace std;

int main() {
   int value=0;
   // Enter a positive one value
   cout<< \"Enter one value : \";
   cin>>value; // read one value
   int i;
   for(i=1;i<value;i++)
   cout<<i <<\" \"; //output value seperated by space
cout<<endl;
   return 0;
}

--------------------

output sample 1:-

Enter one value : 12

1 2 3 4 5 6 7 8 9 10 11

------------------

output sample 2:-

Enter one value : 44                                                                                                                                                

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

--------------

output sample 3:-

Enter one value : 3                                                                                                                                                 

1 2

---------------------------------------------------------------------------------------------

If you have any query, please feel free to ask.

Thanks a lot

C++ Write a program that reads in one value (you can assume that the value entered is a positive integer) and outputs all of the positive integers that are less

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site