Calculate Perimeter of a square
C Program
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,res;
printf("Enter length/side of a square:");
scanf("%d",&a);
res = a*4;
printf("Perimeter of the square is: %d",res);
}
import java.util.Scanner;
public class SimpleProgram {
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.print("enter length/side of a square:");
int side = s.nextInt();
System.out.print("The perimeter of the square is " + (side*4));
}
}
Python Program
x = int(input("Enter the side length of a square: "))
print("The perimeter of a square is : " + str(x*4))
0 Comments:
Post a Comment