Thursday, July 2, 2020

Write a Program to Calculate area and perimeter of a circle


Write a C program to calculate the area and perimeter of a circle . or Write a program to calculate the area and perimeter of a circle  in C

Code:

/*Write a C program to calculate the area and perimeter of a circle . or Write a program to calculate the area and perimeter of a circle Using C*/

#include<stdio.h>
int main()
{
    double radius;
    double area,perimeter;

    printf("Enter the radius of the circle:");
    scanf("%lf",&radius);

    area=3.14*radius*radius;
    perimeter=2*3.14*radius;

     printf("Area of the Circle = %0.2lf",area);
     printf("\nPerimeter of the Circle = %0.2lf",perimeter);

    return 0;
}



Input/Output:

Enter the radius of the circle:5
Area of the Circle = 78.50
Perimeter of the Circle = 31.40


Write a C++ program to calculate the area and perimeter of a circle . or Write a program to calculate the area and perimeter of a circle  in C++


Code:


/*Write a C++ program to calculate the area and perimeter of a circle . or Write a program to calculate the area and perimeter of a circle using C++*/

#include <iostream>

using namespace std;

int main()
{
    double radius;
    double area,perimeter;

    cout<<"Enter the radius of the circle:";
    cin>>radius;

    area=3.14*radius*radius;
    perimeter=2*3.14*radius;

    cout<<"Area of the Circle = "<<area;
    cout<<"\nPerimeter of the Circle = "<<perimeter;

    return 0;
}




Input/Output:

Enter the radius of the circle: 9
Area of the Circle = 254.34
Perimeter of the Circle = 56.52




Write a JAVA program to calculate the area and perimeter of a circle . or Write a program to calculate the area and perimeter of a circle  in Java


Code:

/*Write a JAVA program to calculate the area and perimeter of a circle . or Write a program to calculate the area and perimeter of a circle using Java*/

import java.util.Scanner;
public class AreaPerimeterCircle 
{

public static void main(String[] args) 
{
Scanner cs=new Scanner(System.in);
double radius;
    double area, perimeter;

    System.out.println("Enter the radius of the circle:");
    radius=cs.nextDouble();

    area=3.14*radius*radius;
    perimeter=2*3.14*radius;

     System.out.println("Area of the Circle = "+area);
     System.out.println("\nPerimeter of the Circle = "+perimeter);
       
     cs.close();
 
}
}


Input/Output:

Enter the radius of the circle:
11
Area of the Circle = 379.94

Perimeter of the Circle = 69.08




Write a PYTHON program to calculate the area and perimeter of a circle . or Write a program to calculate the area and perimeter of a circle  in Python

Code:


'''Write a Python program to calculate the area and perimeter of a circle.
or Write a program to calculate the area and perimeter of a circle using Python'''

radius=int(input("Enter radius of a circle :"))

area=3.14*radius*radius
perimeter=2*3.14*radius

print("Area =",area)
print("Perimeter =",perimeter)

Input/Output:

Enter radius of a circle : 4
Area = 50.24
Perimeter = 25.12

No comments:

Post a Comment

All the posts

Recent Posts

Program to Find the nth Palindrome Number

  Palindrome Number:  remains the same when it's reverse the digits . Example:                 212                717                Pro...