Wednesday, February 20, 2019

First numbers

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.

#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

Modelo OSI

Open System Interconnection , Interconexión de Sistemas Abiertos, es un modelo para estudiar las categorías en que se pueden dividir los pr...