Computer Science, asked by sanjinakhatun, 1 year ago

a) Write a porogram to calculate the Square
and cube of any number.
n ein​

Answers

Answered by pihu5084
0

Answer:

This c program will calculate the square and cube of any given number. We will also perform this by the use of functions.

C Program To Find Square and Cube Of A Number

#include<stdio.h>

#include<conio.h>

void main()

{

int a,s,c;

clrscr();

printf("\n Enter A Number: ");

scanf("%d",&a);

s=a*a; //Square = number * number

c=s*a; //Cube = Square * number

printf("\n Square of %d is = %d",a,s);

printf("\n\n Cube of %d is = %d",a,c);

getch();

}

Answered by AskewTronics
0

Program in Python :

Explanation:

number=int(input("Enter the number to calculate the square and the cube: "))#take the input from the user.

print("The square of a "+str(number)+" is",number*number,end=" and ")#print the square of the number.

print("the cube of a "+str(number)+" is",number*number*number)#print the cube of a number.

Output:

  • If the user input as 4, then the output is 16 for square and 64 for cube.
  • If the user input as 2, then the output is 4 for square and 8 for cube.

Code Explanation :

  • The above code is in python language, in which the first line is used to render the message to the user and take the input from the user and save it into the number variable.
  • Then the second and the third line will print after being calculate the square and the cube of the number

Learn More:

  • Python : https://brainly.in/question/14689905
Similar questions