Write an algorithm to find the first 50 natural numbers
Write an algorithm to find the first 50 natural numbers
A very simple c++ code can be :
#include <iostream>
using namespace std;
int main()
{
for (int i =0; i<49; i ++)
{
cout<<i<<" ";
}
return 0;
}
--------------------------------------------------
if you only want a general algorithm to read the first n natural numbers:
1. Read n
2. Initialize N = 0
3. Calculate N = N+1
4. If N> n-1, stop
5. Write N
All times are GMT -7. The time now is 05:12 AM. |