N Integers From N

The program must accept an integer N as the input. Then the program must print N integers from N as the output.

Example Input/Output:
Input:
5

Output:
5 6 7 8 9

Python

N = int(input())
for ctr in range(N, N+N):
    print(ctr, end =" ")

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for (int ctr = N; ctr < (N + N); ctr++) {
            System.out.print(ctr + " ");
        }
    }
}

C

#include <stdio.h>
int main()
{
    int num;
    scanf("%d",&num);
    for(int ctr=num; ctr<num+num; ctr++)
    {
        printf("%d ", ctr);
    }
}

C++

#include <iostream>
using namespace std;
int main()
{
    int num;
    cin >> num;
    for(int ctr = num; ctr < num+num; ctr++)
    {
        cout << ctr << " ";
    }
    return 0;
}
Previous Article

Cricket Tournament Schedule

Next Article

Classroom - Seating Arrangement

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *