Square – Format Print

The program must print a number and print the square as per the format given in the Example Input/Output Section.

Example Input/Output 1:
Input:
5

Output:
Square of 5 is 25

Example Input/Output 2:
Input:
10

Output:
Square of 10 is 100

Python

N = int(input())
print("Square of", N, "is", N*N)

Java

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

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int side;
    scanf("%d", &side);
    printf("Square of %d is %d", side, side * side);
}

C++

#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    cout << "Square of " << N << " is " << N*N;
    return 0;
}
Previous Article

Print Last Four Digits

Next Article

Century or Half-Century

Write a Comment

Leave a Comment

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