Category Archives: C Programs

C Programs

C Program to Find Perimeter of a Rhombus

C Program to Find Perimeter of a Rhombus

In this tutorial, we will learn to create a C program that will Find the Perimeter of a Rhombus in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Arithmetic operations in C programming.

What is a Rhombus?

The Rhombus is a quadrilateral shape having four sides its side are parallel with each other and of the same size. The size of the parallel sides is equal and the total of its interior angles is 360 degrees.

Algorithm:-

Program description:-

In this tutorial, we will create a program, that will find the Perimeter of the Rhombus. we will First, take the side of the Rhombus from the user. Then we will calculate the Perimeter of the Rhombus using arithmetic expressions / the formulae for the Perimeter of the rhombus. At last, we will print the Perimeter of the Rhombus.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

 

  •  rmp = it will hold the input value for the side of the Rhombus.
  •  perimeter = it will hold the perimeter of the Rhombus.

Taking the input side of the rhombus.

Calculating the Perimeter of the rhombus.

Printing the Perimeter of the rhombus.

C Program to Find Area of a Rhombus

C Program to Find Area of a Rhombus

In this tutorial, we will learn to create a C program that will Find the Area of a Rhombus in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Arithmetic operations in C programming.

What is a Rhombus?

The Rhombus is a quadrilateral shape having four sides its side are parallel with each other and of the same size. The size of the parallel sides is equal and the total of its interior angles is 360 degrees.

Algorithm:-

Program description:-

In this tutorial, we will create a program, that will find the Area of the Rhombus. we will First, take the diagonals 1 and 2 of the Rhombus from the user. Then we will calculate the area of the Rhombus using arithmetic expressions / the formulae for the area of the rhombus. At last, we will print the Area of the Rhombus.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

  •  dia1 = it will hold the input value for the diagonal1 of the Rhombus.
  •  dia2 = it will hold the input value for the diagonal2 of the Rhombus.
  •  area = it will hold the value of the area of the rhombus.

Taking the input diagonal1 and diagonal2 of the rhombus.

Calculating the area of the rhombus.

Printing the area of the rhombus.

C Program to Find Area of a Triangle using Base and Height

C Program to Find Area of a Triangle using Base and Height

In this tutorial, we will learn to create a C program that will Find the Area of a Triangle using Base and Height in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Arithmetic Operations in C programing.

What is a triangle?

In geometry, a triangle is a shape used to be drawn by the three lines. The triangle has three interior angles and the total of its interior angle is 180 degrees.

Algorithm:-

Program description that will print the area of a Triangle:-

In this tutorial, we will create a program, that will find the area of a triangle using C programming. First, take the input height and the width of the triangle by the user. Then we will calculate the area of that triangle using the mathematical expression. At last, we will print the area of a triangle.

Program Code:-

 

Output:-

In the above program, we have first initialized the required variable.

 

  • bs = it will hold the value for the input base of the triangle.
  • ht  = it will hold the value for the input height of the triangle.
  • area = it will hold the integer value for the area of a triangle.

Input the base and height of the triangle.

Code to calculate the area of the triangle.

Printing output the area of an isosceles triangle.

C Program to Find Area of an Isosceles Triangle

C Program to Find Area of an Isosceles Triangle

In this tutorial, we will learn to create a C program that will Find the Area of an Isosceles Triangle in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • While loop in C programming.
  • Conditional Statements in C programming.

What is an Isosceles triangle?

In geometry, an isosceles triangle is a triangle that has two sides of equal length. The two sides of an equilateral triangle are equal so it can also be classified as an isosceles triangle.

Algorithm:-

Program description that will print the area of an Isosceles Triangle:-

In today’s tutorial, we will create a program, that will find the area of an Isosceles triangle using C programming. First, take the input common size of the side of the isosceles triangle by the user. Now, will take the size of another side.  Then we will calculate the area of that triangle using the mathematical expression. At last, we will print the area of an isosceles triangle.

Program Code:-

 

Output:-

In the above program, we have first initialized the required variable.

  • x = it will hold the value for the input common size of the side for the triangle.
  • y  = it will hold the value for the input size of the other side for the triangle.
  • iares = it will hold the integer value for the area of a triangle.

Input the size of the side of the triangle.

Code to calculate the area of the triangle.

Printing output the area of an isosceles triangle.

C Program to Find Area of Rectangle

C Program to Find Area of a Rectangle

In this tutorial, we will learn to create a C program that will Find the Area of a Rectangle in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Arithmetic operations in C programming.

What is a rectangle?

The rectangle is four sides geometrical shape with pair of two sides parallel and of the same size as each other. The Rectangle has the length and the width in it.

Algorithm:-

Program description:-

In this tutorial, we will create a program, that will find the Area of the Rectangle. we will First, take the length and the width of the Rectangle from the user. Then we will calculate the area of the Rectangle using arithmetic expressions / the formulae for the area of the Rectangle. At last, we will print the Area of the Rectangle.

Program Code:-

 

Output:-

In the above program, we have first initialized the required variable.

 

  •  recwth = it will hold the input value for the base of the Rectangle.
  •  reclgth = it will hold the input value for the height of the Rectangle.
  •  recar= it will hold the value of the area of the Rectangle.

Taking the input width and the length of the Rectangle.

Calculating the area of the Rectangle.

Printing the area of the Rectangle.

C Program to Find Area of a Rectangle using Length and Width

C Program to Find Area of a Rectangle using Length and Width

In this tutorial, we will learn to create a C program that will Find the Area of a Rectangle using Length and Width in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Arithmetic operations in C programming.

What is a rectangle?

The rectangle is four sides geometrical shape with pair of two sides parallel and of the same size as each other. The Rectangle has the length and the width in it.

Algorithm:-

Program description:-

In this tutorial, we will create a program, that will find the Area of the Rectangle. we will First, take the length and the width of the Rectangle from the user. Then we will calculate the area of the Rectangle using arithmetic expressions / the formulae for the area of the Rectangle. At last, we will print the Area of the Rectangle.

Program Code:-

 

Output:-

In the above program, we have first initialized the required variable.

 

  •  recwth = it will hold the input value for the base of the Rectangle.
  •  reclgth = it will hold the input value for the height of the Rectangle.
  •  recar= it will hold the value of the area of the Rectangle.

Taking the input width and the length of the Rectangle.

Calculating the area of the Rectangle.

Printing the area of the Rectangle.

C Program to Find Area of a Parallelogram

C Program to Find Area of a Parallelogram

In this tutorial, we will learn to create a C program that will Find the Area of a Parallelogram in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Arithmetic operations in C programming.

What is a Parallelogram?

The Parallelogram is four sides geometrical shape with pair of two sides parallel and of the same size as each other. The parallelogram has the base and the height in it.

Algorithm:-

Program description:-

In this tutorial, we will create a program, that will find the Area of the Parallelogram. we will First, take the base and the height of the Parallelogram from the user. Then we will calculate the area of the Parallelogram using arithmetic expressions / the formulae for the area of the Parallelogram. At last, we will print the Area of the Parallelogram.

Program Code:-

 

Output:-

In the above program, we have first initialized the required variable.

 

  •  llbase = it will hold the input value for the base of the parallelogram.
  •  llheight = it will hold the input value for the height of the parallelogram.
  •  llarea= it will hold the value of the area of the parallelogram.

Taking the input base and the height of the parallelogram.

Calculating the area of the parallelogram.

Printing the area of the parallelogram.

C Program to Find Area of a Trapezoid

C Program to Find Area of a Trapezoid

In this tutorial, we will learn to create a C program that will Find the Area of a Trapezoid in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Arithmetic operations in C programming.

What is a Trapezoid?

The Trapezoid is a four-sided shape that has two sides that are parallel and two sides that are not parallel. Here, the shape has two different bases and the height for the trapezoid.

Algorithm:-

Program description:-

In this tutorial, we will create a program, that will find the Area of the Trapezoid. we will First, take the base 1 and 2 of the Trapezoid, then the height of the Trapezoid from the user. Then we will calculate the area of the Trapezoid using arithmetic expressions / the formulae for the area of the Trapezoid. At last, we will print the Area of the Trapezoid.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

 

  •  bs1 = it will hold the input value for the base 1of the Trapezoid.
  •  bs2 = it will hold the input value for the base 2 of the Trapezoid.
  •  ar = it will hold the value of the area of the Trapezoid.

Taking the input bases and the height of the Trapezoid.

Calculating the area of the Trapezoid.

Printing the area of the Trapezoid. 

C Program to Find Volume and Surface Area of Sphere

C Program to Find Volume and Surface Area of a Sphere

In this tutorial, we will learn to create a C program that will Find the Volume and Surface Area of a Sphere in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Arithmetic operations in C programming.

What is a Sphere?

The sphere is a ball-like geometrical 3d shape which is having a diameter equal in all positions going through the center.

Algorithm:-

Program description:-

In this tutorial, we will create a program, that will find the Volume and Surface Area of the sphere. we will First, take the radius of the sphere as input from the user. Then we will calculate the surface area and the volume of a sphere using arithmetic expressions. At last, we will print the Volume and Surface Area of a sphere.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

 

  •  rad = it will hold the integer value for the input radius of the sphere.
  •  sa = it will hold the integer the surface area of the sphere
  •  vol = it will hold the value of the volume of the sphere.

Taking the input radius of the sphere.

Calculating the surface area & volume of the sphere.

Printing the volume and surface area of the sphere.

C Program to Find Volume and Surface Area of a Cube

C Program to Find Volume and Surface Area of a Cube

In this tutorial, we will learn to create a C program that will Find the Volume and Surface Area of a Cube in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Mathematical operations in C programming.

What is a cube?

The cube is a three-dimensional box with all the sides are equal. The cube is a box made with squares at all of its six faces.

Algorithm:-

Program description:-

In today’s tutorial, we will create a program, that will calculate the Volume and Surface Area of a Cube using C programming. First, take the side of the Cube as input from the user. Then we will find the surface area and the volume of a cube using the mathematical expression and calculations. At last, we will print the Volume and Surface Area of a Cube.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

 

  •  l = it will hold the integer value for the input length of the cube.
  •  sa = it will hold the integer the surface area of the cube
  •  vl = it will hold the value of the volume of the cube.

Taking the input length of the side of the cube.

Calculating the surface area & volume of the cube.

Printing the volume and surface area of the Cube.

C Program to Find Volume and Surface Area of a Cylinder

C Program to Find Volume and Surface Area of a Cylinder

In this tutorial, we will learn to create a C program that will Find the Volume and Surface Area of a Cylinder in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Mathematical operations in C programming.

What is a Cylinder?

The cylinder is a 3d shape containing two parallel lines and the circles connected to form a cylindrical shape in geometry. The distance between the two circular bases is called the height of the cylinder.

Algorithm:-

Program description:-

In today’s tutorial, we will create a program, that will calculate the Volume and Surface Area of a Cylinder using C programming. First, take the height and the radius of the Cylinder as input from the user. Then we will find the surface area and the volume of a Cylinder using mathematical expressions and calculations. At last, we will print the Volume and Surface Area of a Cylinder.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

  •  rd = it will hold the integer value for the input radius of the cylinder.
  •  ht = it will hold the integer value for the input radius of the cylinder.
  •  sa = it will hold the integer the surface area of the cylinder
  •  vol = it will hold the value of the volume of the cylinder.

Taking the input length of the side of the cylinder.

Calculating the surface area & volume of the cylinder.

Printing the volume and surface area of the cylinder.

C Program to Find Volume and Surface Area of a Cuboid

C Program to Find Volume and Surface Area of a Cuboid

In this tutorial, we will learn to create a C program that will Find the Volume and Surface Area of a Cuboid in C programming.

Prerequisites

Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • Mathematical operations in C programming.

What is a cuboid?

The cuboid is a box-like geometrical structure used for storing items. The cuboid consists of 3 types of measurements in its structure.

  • Height
  • Width
  • Length

Algorithm:-

Program description:-

In today’s tutorial, we will create a program, that will calculate the Volume and Surface Area of a Cuboid using C programming. First, take the length, width and the height of the Cuboid as input from the user. Then we will find the surface area and the volume of a Cuboid using the mathematical functions and calculations. At last, we will print the Volume and Surface Area of a Cuboid.

Program Code:-

Output:-

In the above program, we have first initialized the required variable.

 

  •  l = it will hold the integer value for the input length of the Cuboid.
  •  w = it will hold the integer value for the input width of the Cuboid.
  •  h = it will hold the integer value for the input height of the Cuboid.
  •  vol = it will hold the value of the volume of the Cuboid.

Taking the input length, width, and height of the cuboid from the user.

Calculating the surface area & volume of the Cuboid.

Printing the volume and surface area of the Cuboid.