Category Archives: C Programs

C Programs

C Program to Print Right Arrow Star Pattern

C Program to Print Right Arrow Star Pattern

In this tutorial, we will learn to create a C program that will print a Right Arrow Star Pattern 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.
  • For loop in C programming.
  • Conditional Statements in C programming.

What is a pattern?

The patterns can be any shape or design drawn on the screen i.e. triangle, rectangle, pyramid, any other shape. In the C programming language, the patterns are generated using loops and iterative statements.

What is Printing Right Arrow Star Pattern?

The Right Arrow star pattern means to create a Right Arrow -symbol like a pattern on the screen to the user. For the Right Arrow symbol, using the “*” to draw the pattern

Algorithm:-

Program description:-

In today’s tutorial, we will create a program, that will print a Right Arrow Star Pattern using nested for loops. First, we will be taking the size in form of rows from the user. Then we will use nested for loops to create a pattern looking like the Right Arrow symbol. Then we will print the pattern using the printf() function.

Below is an example of Print Right Arrow Star Pattern.

Program Code:-

 

Output:-

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

  • rw = it will hold the integer value.
  • j = it will hold the integer value.
  • i = it will hold the integer value.

Input the number of rows for the pattern.

Code to make the pattern on the screen.

Printing output pattern using c programming.

C Program to Check Triangle is Equilateral Isosceles or Scalene

C Program to Check Triangle is Equilateral Isosceles or Scalene

In this tutorial, we will learn to create a C program that will Check Triangle is Equilateral Isosceles or Scalene 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.
  • Conditional statements in C programming.

What is a scalene triangle?

A Scalene triangle is a triangle that has 3 unequal sides. Since all the three sides are unequal, this means all the three angles are also of different measures.

What is an equilateral triangle?

In geometry, a triangle is an equilateral triangle when it’s all the sides are equal. The triangle has three interior angles and the total of its interior angle is 180 degrees. Here all three angles are 60 Degrees.

Below is a figure for the equilateral triangle with all sides and the anglers are equal.

Algorithm:-

Program Check Triangle is Equilateral Isosceles or Scalene:-

In this tutorial, we will create a program, that will Use sides to check Triangle is equilateral, isosceles, or scalene. First, we will take three sides from the input by the user. Then we will use the conditional statements to check which type of triangle is it. Then we will print the  Triangle type. 

Program Code:-

Output:-

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

  • s1 = it will hold the value for the input first side of the triangle.
  • s2 = it will hold the value for the input second side of the triangle.
  • s3 = it will hold the value for the input third side of the triangle.

Taking the Input of the three sides of the triangle.

Code to check the type of the triangle.

Printing the output for the triangle is valid or not.

C Program to Use Sides to check Triangle is Valid or Not

C Program to Use Sides to check Triangle is Valid or Not.

In this tutorial, we will learn to create a C program that will Use Angles to check Triangle is valid or Not 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.
  • Conditional statements in C programming.

What is a triangle?

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

Below is a figure for the equilateral triangle with all sides and the anglers are equal.

Algorithm:-

Program description that Use Sides to check Triangle is Valid or Not:-

In this tutorial, we will create a program, that will Use sides to check Triangle is valid or Not. First, we will take three sides from the input by the user. Then we will add any two sides and the sum should be greater than the third side then Triangle is valid if not greater than the third it’s Not a valid triangle. Then will print the output to the user.

Program Code:-

Output:-

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

  • s1 = it will hold the value for the input first side of the triangle.
  • s2 = it will hold the value for the input second side of the triangle.
  • s3 = it will hold the value for the input third side of the triangle.

Taking the Input of the three sides of the triangle.

Code to check the triangle is a valid triangle or not.

Printing the output for the triangle is valid or not.

C Program to Use Angles to check Triangle is valid or Not

C Program to Use Angles to check Triangle is valid or Not

In this tutorial, we will learn to create a C program that will Use Angles to check Triangle is valid or Not 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.
  • Conditional statements in C programming.

What is a triangle?

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

Algorithm:-

Program description that will check the Triangle:-

In this tutorial, we will create a program, that will Use Angles to check Triangle is valid or Not. First, we will take three angles from the input by the user. Then we will add all three angles if the sum is equal to 180 then Triangle is valid if not equal to 180 then it’s Not a valid triangle. Then will print the output of the triangle.

 

Program Code:-

 

Output:-

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

 

  • ang1 = it will hold the value for the input first angle of the triangle.
  • ang2 = it will hold the value for the input second angle of the triangle.
  • ang3 = it will hold the value for the input third angle of the triangle.

Taking the Input of the three angles of the triangle.

Code to check the triangle is a valid triangle or not.

Printing the output for the triangle is valid or not.

C Program to Find Angle of a Triangle if two angles are given

C Program to Find Angle of a Triangle if two angles are given

In this tutorial, we will learn to create a C program that will Find the third Angle of a 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.
  • Arithmetic Operations in C Programming.

What is a triangle?

In geometry, a triangle is a shape generally to be drawn by 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 angle of a triangle using C programming. First, take the input angle 1 and 2  of the triangle by the user. Then we will find the third angle using the arithmetic expression. At last, we will print the answer third angle.

 

Program Code:-

 

Output:-

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

  • x = it will hold the value for the input first angle of the triangle.
  • y  = it will hold the value for the input second angle of the triangle.
  • z = it will hold the value for the third angle of the triangle.

Taking the Input the first and the second angle of the triangle.

Code to calculate the third angle of the triangle.

Printing output the third angle of the triangle.

C Program to Print Right Triangle Alphabets Pattern

C Program to Print Right Triangle Alphabets Pattern

In this tutorial, we will learn to create a C program that will print the Right Triangle Alphabets Pattern in C programming

Prerequisites

Before starting with this tutorial we assume that you are 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.

Algorithm:-

Program description that will print the Right Triangle Alphabets Pattern:-

In today’s tutorial, we will create a program, that will print the Right Triangle Alphabets Pattern using a while loop. First, take the rows from the user. Then we will print the simple right-angle triangle of Alphabets using the for-loop. The below is an example to print a Right Triangle Alphabets Pattern.

Program Code:-

Output:-

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

  • rw = it will hold the integer value.
  • j = it will hold the integer value.
  • i = it will hold the integer value.

Input the number of rows for the pattern.

Code to make the pattern on the screen.

Printing output pattern using c programming.

C Program to Print Hollow Right Triangle Star Pattern

C Program to Print Hollow Right Triangle Star Pattern

In this tutorial, we will learn to create a C program that will print the Hollow Right Triangle Star Pattern in C programming.

Prerequisites

Before starting with this tutorial we assume that you are 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.

A Right Triangle:-

The right triangle has a 90 degrees angle between its two sides. and the square of its hypotenuse is equal to the sum of the square of its base and the square of the altitude.

Algorithm:-

Program description that will print the Right Triangle Star Pattern:-

In this tutorial, we will create a program, that will print the Hollow Right Triangle Star Pattern using a for-loop. First, take the rows from the user. Then we will print the Hollow right-angle triangle / only the borders of the right-angled triangle using the for-loop. The below is an example to print a Hollow Right Triangle Star Pattern.

Program Code:-

 

Output:-

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

  • rw = it will hold the integer value.
  • j = it will hold the integer value.
  • i = it will hold the integer value.

Taking the Input number of rows for the hollow right triangled pattern.

Code to make the pattern on the screen.

Printing output pattern using c programming.

C Program to Print Right Angled Triangle Star Pattern

C Program to Print Right Triangle Star Pattern

In this tutorial, we will learn to create a C program that will print the Right Triangle Star Pattern in C programming

Prerequisites

Before starting with this tutorial we assume that you are 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.

A Right Triangle:-

The right triangle has a 90 degrees angle between its two sides. and the square of its hypotenuse is equal to the sum of the square of its base and the square of the altitude.

Algorithm:-

Program description that will print the Right Triangle Star Pattern:-

In this tutorial, we will create a program, that will print the Right Triangle Star Pattern using a for-loop. First, take the rows from the user. Then we will print the simple right-angle triangle of stars using the for-loop. The below is an example to print a Right Triangle Star Pattern.

Program Code:-

Output:-

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

  • rw = it will hold the integer value.
  • j = it will hold the integer value.
  • i = it will hold the integer value.

Taking the Input number of rows for the right triangled pattern.

Code to make the pattern on the screen.

Printing output pattern using c programming.

C Program to Print Floyd’s Triangle

C Program to Print Floyd’s Triangle

In this tutorial, we will learn to create a C program that will Print a Floyd’s Triangle using C programming.

Prerequisites:-

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

  • Operators in C Programming.
  • Basic Input and Output function in C Programming.
  • Basic C programming.
  • For loop in C Programming.

Floyd’s Triangle:-

Floyd’s triangle is a right-angled triangle that contains mathematical numbers from 1 and goes up to the required point.

Printing a Floyd’s:-

The C language is a very powerful programming language. In C programming we can perform many operations with the help of codings. The c language is very easy to create any shape. In this program, we will learn to create Floyd’s triangle with the help of some code.

Algorithm:-

Program:-

To print a Floyd’s Triangle

Output:-

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

  • i = it will hold the integer value to control parent for loop.
  • j = it will hold the integer value to control child for loop.
  • k = it will hold the integer value to control child for loop.
  • num = it will hold the integer value for the number of rows.

Taking input Number of rows

Nested For loop the body of the program

Printing Numbers

 

C Program to Print Rectangle Star Pattern

C Program To Print Rectangle Star Pattern

In this tutorial, we will learn to create a C program that will Print Rectangle Star Pattern 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.
  • For loop in 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 print the Rectangle pattern. we will First, take the rows and the columns of the Rectangle from the user. Then we will print the rectangle pattern using the nested for loops.

Program Code:-

Output:-

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

  •  rw = it will hold the input value for the rows of the Rectangle.
  •  clm = it will hold the input value for the columns of the Rectangle.
  •  i, j = it will hold the value for controlling the loop.

Taking the input rows and the columns of the Rectangle.

Generating the pattern using the for loop to print the Rectangle.

Printing the pattern of the Rectangle.

C Program To Print Hollow Rectangle Star Pattern

C Program To Print Hollow Rectangle Star Pattern

In this tutorial, we will learn to create a C program that will Print Hollow Rectangle Star Pattern 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.

The perimeter is the total of all the borders of the shape rectangle. In the hollow rectangle, we will only print the perimeter of the rectangle.

Algorithm:-

Program description:-

In this tutorial, we will create a program, that will print the hollow Rectangle pattern. we will First, take the rows and the columns of the Rectangle from the user. Then we will print the hollow rectangle pattern using the for loops. At last, we will print the pattern of hollow Rectangle pattern.

Program Code:-

 

Output:-

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

 

  •  rw = it will hold the input value for the rows of the Rectangle.
  •  clm = it will hold the input value for the columns of the Rectangle.
  •  i, j = it will hold the value for controlling the loop.

Taking the input rows and the columns of the Rectangle.

Generating the pattern using the for loop to print the Rectangle.

Printing the pattern of the Rectangle.

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

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

In this tutorial, we will learn to create a C program that will Find the Perimeter 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.

The perimeter is the total of all the borders of the shape rectangle.

Algorithm:-

Program description:-

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

Program Code:-

 

Output:-

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

  •  wd = it will hold the input value for the base of the Rectangle.
  •  lt = it will hold the input value for the height of the Rectangle.
  •  pmr = it will hold the value of the area of the Rectangle.

Taking the input width and the length of the Rectangle.

Calculating the Perimeter of the Rectangle.

Printing the Perimeter of the Rectangle.