Program to print series 1,22,333,4444...n

 Problem statement:- Program to print series 1,22,333,4444...n.

 Data requirement:-

   Input Data:- n

  Output Data:-out

  Additional Data:- in.

Program in C
  
Here is the source code of the C Program to print series 1,22,333,4444...n.

Code:

#include <stdio.h>
int main()
{
    int n,out,in;
    printf("Enter the range of number(Limit):");
    scanf("%d",&n);

  for(out=1;out<=n;out++)
  {
      for(in=1;in<=out;in++)
      {
           printf("%d",out);
      }
      printf(" ");

  }
}

Input/Output:
Enter the range of number(Limit):4
1 22 333 4444

Program in C++

Here is the source code of the C++ Program to print series 1,22,333,4444...n.

Code:

#include<iostream>
using namespace std;
int main()
{
    int n,in,out;
    cout<<"Enter the range of number(Limit):";
    cin>>n;
    for(out=1;out<=n;out++)
    {
      for(in=1;in<=out;in++)
      {
        cout<<out;
    }
    cout<<" ";
    }
}

Input/Output:
Enter the range of number(Limit):5
1 22 333 4444 55555

Program in Java

Here is the source code of the Java Program to print series 1,22,333,4444...n.

Code:

import java.util.Scanner;
public class Print_Series7 {

public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n,out,in;
   System.out.printf("Enter the range of number(Limit):");
    n=sc.nextInt();
    for(out=1;out<=n;out++)
    {
        for(in=1;in<=out;in++)
        {
    System.out.print(out);
    }
        System.out.print(" ");
    }
    sc.close();
}
}

Input/Output:
Enter the range of number(Limit):7
1 22 333 4444 55555 666666 7777777 

Program in Python

Here is the source code of the Python Program to print series 1,22,333,4444...n.

Code:

n=int(input("Enter the range of number(Limit):"))
for out in range(n+1):
    for i in range(out):
        print(out,end="")
    print(end=" ")

Input/Output:
Enter the range of number(Limit):5
 1 22 333 4444 55555


Post a Comment

0 Comments