Print – 1 to 222

The program must print from 1 to 222, with the numbers separated by a space.

Python

for ctr in range(1, 223):
    print(ctr, end = " ")

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        int N = 1;
        while (N <= 222) {
            System.out.print(N++ + " ");
        }
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int N=1;
    while(N<=222)
    {
        printf("%d ",N);
        N++;
    }
}

C++

#include <iostream>
using namespace std;
int main()
{
    int N = 1;
    while(N <= 222){
        cout << N << " ";
        N++;
    }
    return 0;
}

Leave a Reply

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

More posts. You may also be interested in.