Area of Square in cpp

October 31, 2019


Area of Square


                    To calculate the area of the square we must know the formula area of the square is  area=side*side
                   To perform this operation in the cpp language first take the two variables as side and area to display or store the final answer. Then take the input from the user using cin, then store that values in the side as shown in the code. Pass this variable in formulae to calculate the area of the square. Then the answer is stored in area variable, display area. Refer the following code to calculate the area of the square.  

C language code to calculate the area of square:

#include<iostream.h>

#include<conio.h>

int main()
 {
   int side, area;

   clrscr();

   cout<<"\nEnter the Length of Side : ";

   cin>>side;   //to accept the side

   area=side*side;   //formula to find the area of a square

   cout<<"\nArea of Square:"<<area;   //To display the final answer

   getch();
}
-----------------------------------------------------------------------------------------
Output:
Enter the Length of Side: 5
Area of Square: 25


Area of Square in cpp Area of Square in cpp Reviewed by Amit Waghmare on October 31, 2019 Rating: 5

Simple python Program

October 31, 2019


Hello friends, in this blog we see the actual code of python. To run the program of python you must install the python setup in the machine. You can download the setup of python from the python official site (www.python.org).

First, we see how to get input from the user and print output. The below program show how to print and store input data in a variable.

Program:

print("PYTHON PROGRAMMING")

a=input("ENTER YOUR NAME:")

print("HELLO",a)

In the above program ‘print’ keyword is used to print the data like print(“ PYTHON PROGRAMMING”). To store the data in any variable which is entered by the user we use keyword ‘input’ like a=input("ENTER YOUR NAME:"), if you enter your name like Alex then the Alex name is stored in the variable ‘a’.
            

The above image shows the actual code of python. To run python code save the code with the extension .py like xyz.py and to run this code press F5 function key or click on run button. When you run this program the python shell will appear like the below image.



           In the above image as per requirement, the PYTHON PROGRAMMING is printed then the next line is ENTER YOUR NAME and I enter ALEX and then pressed Enter key then the final output is like below image.


Friends if you have any doubts related to this post or any other post or any suggestions to me then write a comment in the comment box. Thank You.


Simple python Program Simple python Program Reviewed by Amit Waghmare on October 31, 2019 Rating: 5