Thursday, July 2, 2020

Write a program to calculate area of a rectangle and perimeter of a rectangle.


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

Code:

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

#include<stdio.h>

int main()
{
    double length,breadth;
    double area,perimeter;

    printf("Enter the length of rectangle:");
    scanf("%lf",&length);

    printf("Enter the breadth of rectangle:");
    scanf("%lf",&breadth);

    area=length*breadth;
    perimeter=2*(length+breadth);

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

    return 0;
}

Input/Output:

Enter the length of rectangle:5
Enter the breadth of rectangle:4
Area of the rectangle = 20.00
Perimeter of the rectangle = 18.00


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

Code:

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

int main()
{
    double length,breadth;
    double area,perimeter;

    cout<<"Enter the length of rectangle:";
    cin>>length;

    cout<<"Enter the breadth of rectangle:";
    cin>>breadth;

    area=length*breadth;
    perimeter=2*(length+breadth);

    cout<<"Area = "<<area;
    cout<<"\nPerimeter = "<<perimeter;

    return 0;
}


Input/Output:

Enter the length of rectangle:7
Enter the breadth of rectangle:3
Area = 21
Perimeter = 20



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

Code:

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

import java.util.Scanner;
public class AreaPerimeterRectangle {

public static void main(String[] args) {
Scanner cs=new Scanner(System.in);

double length,breadth;
    double area, perimeter;

    System.out.println("Enter the length of rectangle:");
    length=cs.nextDouble();

    System.out.println("Enter the breadth of rectangle:");
    breadth=cs.nextDouble();

    area=length*breadth;
    perimeter=2*(length+breadth);

    System.out.println("Area of the rectangle = "+area);
    System.out.println("Perimeter of the rectangle = "+perimeter);
    cs.close();

}

}


Input/Output:

Enter the length of rectangle:
7.5
Enter the breadth of rectangle:
8.0
Area of the rectangle = 60.0
Perimeter of the rectangle = 31.0




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

Code:


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

length=int(input("Enter length of a rectangle :"))
breadth=int(input("Enter breadth of a rectangle :"))

area=length*breadth
perimeter=2*(length+breadth)

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


Input/Output:

Enter length of a rectangle :8
Enter breadth of a rectangle :5
Area = 40
Perimeter = 26

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

Write a program for addition multiplication and average of two numbers


Write a C program for addition multiplication and an average of two numbers. or Write a program for addition multiplication and an average of two numbers in C

Code:

/*Write a C program for addition multiplication and an average of two numbers. or Write a program for addition multiplication and an average of two numbers using C*/

#include<stdio.h>
int main()
{
    int num_1,num_2,sum=0;
    printf("Enter the two number=>");
    scanf("%d %d",&num_1,&num_2);
    sum=num_1+num_2;
    printf("Addition of two Number = %d\n",sum);
    int multiplication=num_1*num_2;
    printf("Multiplication of two Number = %d\n",multiplication);
    double average;
    average=sum/2.0;
    printf("Average of Two number = %0.2lf",average);

}


Input/Output:

Enter the two number=>4 5
Addition of two Number = 9
Multiplication of two Number = 20
Average of Two number = 4.50



Write a C++ program for addition multiplication and an average of two numbers. or Write a program for addition multiplication and an average of two numbers in C++


Code:


/*Write a C++ program for addition multiplication and an average of two numbers. or Write a program for addition multiplication and an average of two numbers using C++*/

#include <iostream>

using namespace std;

int main()
{
    int num1,num2;
    cout<<"Enter two numbers :";
    cin>>num1>>num2;
    int addition=num1+num2;
    int multiplication=num1*num2;
    double average=(num1+num2)/2.0;

    cout<<"Addition = "<<addition;
    cout<<"\nMultiplication = "<<multiplication;
    cout<<"\nAverage = "<<average;

    return 0;

}

Input/Output:

Enter two numbers :5 6
Addition = 11
Multiplication = 30
Average = 5.5


Write a JAVA program for addition multiplication and an average of two numbers. or Write a program for addition multiplication and an average of two numbers in Java


Code:

/*Write a JAVA program for addition multiplication and an average of two numbers. or Write a program for addition multiplication and an average of two numbers using Java*/

import java.util.Scanner;
public class addmultiavg
{

public static void main(String[] args) 
{
Scanner cs=new Scanner(System.in);
int num_1,num_2,sum=0;

    System.out.println("Enter the two number=>");
       num_1=cs.nextInt();
       num_2=cs.nextInt();

    sum=num_1+num_2;

    System.out.println("Addition of two Number = "+sum);

    int multiplication=num_1*num_2;

    System.out.println("Multiplication of two Number = "+multiplication);

    double average;

    average=sum/2.0;

    System.out.println("Average of Two number = "+average);


cs.close();

}

}



Input/Output:

Enter the two number=>
5
6
Addition of two Number = 11
Multiplication of two Number = 30
Average of Two number = 5.5



Write a PYTHON program for addition multiplication and an average of two numbers. or Write a program for addition multiplication and an average of two numbers in Python.

Code:

'''Write a python program for addition multiplication and an average of two numbers.
 or Write a program for addition multiplication and an average of two numbers using python'''

num1=int(input("Enter a number :"))
num2=int(input("Enter a number :"))

addition=num1+num2
multiplication=num1*num2
average=(num1+num2)/2

print("Addition =",addition)
print("Multiplication =",multiplication)
print("Average =",average)




Input/Output:

Enter a number :8
Enter a number :7
Addition = 15
Multiplication = 56
Average = 7.5

Write a program to Display your name and some Message

Write a C program to display your name and some Message or write a  program to display your name and some Message on Screen in C


Code:

/*Write a C program to display your name and some Message or write a  program to display your name on Screen in C
*/
#include<stdio.h>
int main()
{
printf("Sourav Patra\n");
printf("Welcome to C\n");
printf("Welcome to our page www.csinfoall.blogspot.com\n");
printf("Programming");
printf("Thank you!");

}

Output:

Sourav Patra
Welcome to C
Welcome to our page www.csinfoall.blogspot.com
Programming
Thank you!



Write a C++ program to display your name and some Message or write a  program to display your name and some Message on Screen in C++

Code:

/*Write a C++ program to display your name and some Message or write a  program to display your name and some Message on Screen in C++*/
#include <iostream>

using namespace std;

int main()
{


    cout<<"Sourav Patra";
    cout<<"\nWelcome to C++ ";
    cout<<"\nWelcome to our page www.csinfoall.blogspot.com";
    cout<<"\nProgramming";
    cout<<"\nThank you!";

    return 0;
}


Output:

Sourav Patra
Welcome to C++
Welcome to our page www.csinfoall.blogspot.com
Programming
Thank you!



Write a JAVA program to display your name and some Message or write a  program to display your name and some Message on Screen in JAVA

Code:

/*Write a Java program to display your name and some Message or write a  program to display your name and some Message on Screen in Java*/
public class DisplayNameMessage {

public static void main(String[] args) {
System.out.println("Sourav Patra");
System.out.println("Welcome to Java");
System.out.println("Welcome to our page www.csinfoall.blogspot.com");
System.out.println("Programming");
System.out.println("Thank you!");
}

}



Output:

Sourav Patra
Welcome to Java
Welcome to our page www.csinfoall.blogspot.com
Programming
Thank you!






Write a PYTHON program to display your name and some Message or write a  program to display your name and some Message on Screen in PYTHON

Code:
'''Write a Python program to display your name and some Message or write a  program to
display your name and some Message on Screen in Python'''

print("Sourav Patra")
print("Welcome to Python")
print("Welcome to our page www.csinfoall.blogspot.com")
print("Programming")
print("Thank you!")


Output:

Sourav Patra
Welcome to Python
Welcome to our page www.csinfoall.blogspot.com
Programming
Thank you!

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...