This program is used to find the square and cube of a number entered by the user. The program accepts one number and calculates its square by multiplying the number two times and calculates its cube by multiplying the number three times.
no.
no * no.
no * no * no.
#include <stdio.h> #include <conio.h> main() { int no; clrscr(); printf("\n Enter any no"); scanf("%d", &no); printf("\n Square is %d * %d = %d", no, no, no * no); printf("\n Cube is %d * %d * %d = %d", no, no, no, no * no * no); getch(); }
for loop to accept 5 numbers from the user and display the square and cube of each number.for loop and arithmetic operators to calculate square and cube values of multiple numbers.k and no. Run the loop from 1 to 5. Calculate square using no * no and cube using no * no * no.
#include <stdio.h> #include <conio.h> main() { int k, no; clrscr(); for (k = 1; k <= 5; k = k + 1) { printf("\n Enter any no"); scanf("%d", &no); printf("\n Square is %d * %d = %d", no, no, no * no); printf("\n Cube is %d * %d * %d = %d", no, no, no, no * no * no); } getch(); }
for loop to accept 5 numbers from the user. For each number, it calculates the square by multiplying the number two times and calculates the cube by multiplying the number three times. The results are displayed after each input.