C Program To Find Square and Cube Of A Number | LearntHub

Hello friends, I welcome all of you in the Learnt Hub. In today's article I am going to tell you about how we can find the square and cube of the given number using C programming language.
Find square and cube
Let's know how to find the square and cube of a number in C programming language.
See example, written below to know more.
Example:

Output:
Enter any number:
8
Square of the number is: 64
Cube of the number is: 512
  1. FlowChart
  2. Operators
  3. Conditions Statements
For finding square and cube of any numbers, we need to follow the following step, which showing in the above program.
1. First, we take preprocessor directive in the program.
For example: #include<stdio.h>
It's mean that this is Include with Standard Input Output Header File.
2. Next is, main function.
i.e., int main()
It's mean that this is Integer Main function.
3. Next is, variables declaration. In variables declaration, we decleare the variables, which define in the program.
4. Next step is printf(). printf() function uses for print(Output) to the statement on the monitor.
5. Next is, scanf() function. This function used for read(input) variables.
In this program %d uses for read the integer data type and & (address operator) is address of  variable.
6. In the next step, we use logic for square and cube.
In the output, we find the square and cube of the number (num=1,2,3,......n)

Post a Comment

0 Comments