Write a program that reads a number n, and prints all numbers between 0 and n.
Input: Input consists of a natural number n.
Output: Print in order all natural numbers between 0 and n.
Input: Input consists of a natural number n.
Output: Print in order all natural numbers between 0 and n.
#include <iostream> using namespace std; int main (){ int n; cin >> n; int i = 0; while (i <= n) { cout << i << endl; ++i; } }
No comments:
Post a Comment