Professional Documents
Culture Documents
Shree Amreli Jilla Charitable Trust, Surat: Computer Assignment Trivedi Harshil Vishalbhai
Shree Amreli Jilla Charitable Trust, Surat: Computer Assignment Trivedi Harshil Vishalbhai
Surat
S.M.T Santaben Haribhai Gajera Shaikshanik Sankul
Amreli
Computer Assignment
STD :9E
Roll No :16
Topic : Assignment ::5 (2/9/2021)
1)find area of square
Program to find the area of the square
Area of the square is the amount of space occupied by a square. Square refers to a
plane figure with four equal straight sides and four right angles.
Formula
area = width × height
Area of square will be calculated as :
area = side2
since width = height;
Algorithm
1. Define the height of any one side of the square as 's.'
2. Calculate the area of the square by multiplying s with s
3. Define the area_square as the area of the square.
#include <stdio.h>
int main()
{
int s=13;
int area_square=s*s;
printf("Area of the square=%d",area_square);
}
Java Program
public class shpere{
{
int s=13;
int area_square=s*s;
}
2)find area of Triangle
Program to find the area of a triangle
Explanation
Three sided polygon is known as Triangle. It has a base and an altitude(height).
Algorithm
1. Define base and height
2. Apply in the formula.
3. Print the Area.
area = ( b*h) / 2 ;
"+area);
}}
3)find area of circle
This is a Java Program to Calculate and Display Area of a Circle.
Formula:
Perimeter of circle=pi * radius * radius
Enter the radius of the circle as input. Now we use the given formula to calculate the
area of the circle using formula.
Here is the source code of the Java Program to Calculate and Display Area of a Circle.
The Java program is successfully compiled and run on a Windows system. The program
output is also shown below.
import java.util.Scanner;
int r;
r = s.nextInt();
area = pi * r * r;
System.out.println("Area of circle:"+area);
}
}
4)find area of rectangle
Program to calculate the area of the rectangle
Area of a rectangle is the amount of space occupied by the rectangle. A rectangle
can be defined as the plain figure with two adjacent sides equal in length. The 4
angles present in the rectangle are also equal. A rectangle can be divided into 4
similar square. The measurement of each interior angle in a rectangle is 90 degrees.
Area of a rectangle is the number of square units takes to fill a rectangle completely.
Formula
1. A= W x H
where
Algorithm
1. Define the width of the rectangle.
2. Define the Height of the rectangle.
3. Define Area of the rectangle.
4. Calculate the area of the rectangle by multiplying the width and height of the
rectangle.
5. Assign the area of the rectangle to the area variable.
6. print the area of the rectangle.
Here is the source code of the Java Program to Create a Simple Class to Find out the
Area and Perimeter of Rectangle. The Java program is successfully compiled and run on
a Windows system. The program output is also shown below.
import java.util.Scanner;
public class Area_Perimeter
{
public static void main(String[] args)
{
int l, b, perimeter, area;
Scanner s = new Scanner(System.in);
System.out.print("Enter length of rectangle:");
l = s.nextInt();
System.out.print("Enter breadth of rectangle:");
b = s.nextInt();
perimeter = 2 * (l + b);
System.out.println("Perimeter of
rectangle:"+perimeter);
area = l * b;
System.out.println("Area of rectangle:"+area);
}
}