Category Archives: C Programs

C Programs

C Program to Print Hollow Rhombus Star Pattern

C program to Print Hollow Rhombus Star Pattern

In this tutorial, we will learn to create a C program that will print a Hollow Rhombus 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 Hollow Rhombus?

The Rhombus is a four-sided shape in geometry. The Rhombus is a quadrilateral shape that has all four sides of the same length. And the hollow rhombus is empty from inside only borders are printed. 

Algorithm:-

Program description Printing Hollow Rhombus:-

In this program, we will first take the input number of rows by the user. Then we will pass that input size to the nested for loop to draw the Hollow Rhombus pattern using the C programming language.

Printing the Hollow Rhombus pattern filled with stars. Let’s take the below example for the problem.

Program Code:-

 

Output:-

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

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

Input the number of rows for the Hollow Rhombus.

Program Code.

Printing output pattern using c programming.

C Program to Print Mirrored Rhombus Star Pattern

C program to Print Mirrored Rhombus Star Pattern

In this tutorial, we will learn to create a C program that will Print Mirrored Rhombus 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 Rhombus?

The Rhombus is a four-sided shape in geometry. The Rhombus is a quadrilateral shape that has all four sides of the same length. 

Algorithm:-

Program description Printing Mirrored Rhombus:-

In this program, we will first take the input number of rows by the user. Then we will pass that input size to the nested for loop to draw the Mirrored Rhombus pattern using the C programming language.

Printing the Mirrored Rhombus pattern filled with stars. Let’s take the below example for the problem.

Program Code:-

 

Output:-

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

 

  • rw  = it will hold the integer value for the input.
  • x = it will hold the integer value.
  • y = it will hold the integer value.

Input the number of rows for the Mirrored Rhombus.

Program Code.

Printing output pattern using c programming.

C Program to Print X Star Pattern

C program to Print X Star Pattern

In this tutorial, we will learn to create a C program that will Print X 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 X Shape?

The X shape pattern means a pattern containing the Star and looks like the Alphabet X. It will be created using two triangles.

Algorithm:-

Program description Printing X Shape Star Pattern:-

In this program, we will first take the input number of rows by the user. Then we will generate the X shape pattern using the nested for loops and fill it with star values.

Printing the pattern filled with stars.

Let’s take the below example for the problem.

Program Code:-

 

Output:-

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

 

  • N  = 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 X pattern.

Program Code.

Printing output pattern using c programming.

C Program to Print Square Star Pattern

C Program to Print Square Star Pattern

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

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 Square?

The angle between every two sides of the square is 90 degrees, and the sum of all the angles is 360 degrees. The square is a shape which is having all the sides equal in length.

Algorithm:-

Program description that will print Square Star Pattern:-

In today’s tutorial, we will create a program, that will print a square with the stars using for loop. Taking the size of the side from the user for the square. Then we will print the square using the nested for-loop.

The below is an example to print a square star pattern.

Program Code:-

 

Output:-

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

  • Side = 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 Square Pattern With Diagonals

C Program to Print Hollow Square Star Pattern

In this tutorial, we will learn to create a C program that will print a hollow Square 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.

What is a Hollow Square with a diagonal?

The hollow square is a square. Made in the c programming language. The hollow square has only four borderlines of the square. It is not filled from the inner section. The diagonal is the line that is drawn from one interior angle to another interior angle. There are two diagonals.

Algorithm:-

Program description Printing a Hollow Square Star Pattern:-

In this program, we will first take the input size of the side of the square. Then we will use nested for loops for the program to print the hollow square and the diagonals for the square. We will print the borders only for the shape.  So that we can create a hollow shape. At last, the loop will print the square and the diagonal row by row.

The below is an example of the hollow Square Star Pattern program code.

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.

Logic Code to make the pattern on the screen.

Printing output hollow Square Star Pattern using c programming.

C Program to Print Hollow Square Star Pattern

C Program to Print Hollow Square Star Pattern

In this tutorial, we will learn to create a C program that will print a hollow Square 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.

What is Hollow Square?

The hollow square is a square. Made in the c programming language. The hollow square has only four borderlines of the square. It is not filled from the inner section.

Algorithm:-

Program description Printing a Hollow Square Star Pattern:-

In this program, we will first take the input size of the side of the square. Then we will use nested for loops for the program to print the hollow square. We will print the borders only for the shape.  So that we can create a hollow shape. At last, the loop will print the square row by row.

The below is an example of the hollow Square Star Pattern program code.

Program Code:-

 

Output:-

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

  • Side = 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 Last Digit of Number

C Program to print Last Digit of a Number

In this tutorial, we will learn to create a C program that will print the Last Digit of a Number 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 Ca programming.
  • Operators in C programming.

What are the digits in the number?

The number of integers in a number is called its digits. A number is said to be a single-digit number when it is between 0 and 9. Hence, the number is said to be a 4-digit number when it is between the range of 1000 and 9999. In c programming, we can print the first and last digit from the number with the help of a small program.

Algorithm:-

Printing the Last Digit of a Number

In this program first, we will take the input number from the userThen we will separate the digits from that number. And at last, we will print the last digit of the number.

Let us take the example program from the below code for printing the Last Digit of a Number.

Program Code:-

 

Output:-

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

 

  • n = it will hold the integer value.
  • ldigit = it will hold the integer value.
  • sum = it will hold the integer value.

Input Number from the user for the program.

Finding the Last Digit of a Number.

Printing output first and the last digit.

C program to print First and Last Digit of a Number

C Program to print First and Last Digit of a Number

In this tutorial, we will learn to create a C program that will print First and Last Digit of a Number 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.
  • Operators in C programming.

What are the digits in the number?

The number of integers in a number is called its digits. A number is said to be a single-digit number when it is between 0 and 9. Hence, the number is said to be a 4-digit number when it is between the range of 1000 and 9999. in c programming, we can print the first and last digit from the number with the help of a small program.

Algorithm:-

Printing the First and Last Digit of a Number

In this program first, we will take the input number from the userThen we will separate the digits from that number. And at last, we will print the first and the last digit of the number.

Let us take the example program from the below code for printing the First and Last Digit of a Number.

Program Code:-

 

Output:-

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

 

  • n = it will hold the integer value.
  • fdigit = it will hold the integer value.
  • ldigit = it will hold the integer value.
  • sum = it will hold the integer value.

Input Number from the user for the program.

Finding the First and Last Digit of a Number.

Printing output first and the last digit.

C program to find Sum of First and Last Digit of a Number

C Program to find Sum of First and Last Digit of a Number

In this tutorial, we will learn to create a C program that will find Sum of the First and Last digits of a Number 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.
  • Arithmetic operations in C programming.
  • Operators in C programming.

What is the sum of digits?

In summation, we add the data of two variables or the data in the variable. In this program, we will add the first and last digits by separating each digit and adding them and at last will print the resultant data of that variable.

Algorithm:-

Adding the First and Last Digit of a Number

In this program first, we will take the input number from the userThen we will separate the digits from that number. Now we will add those first and last digits. And at last, we will print that output number

Let us take the example program from the below code for Add First and Last Digit of a Number.

Program Code:-

 

Output:-

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

 

  • num = it will hold the integer value.
  • fdigit = it will hold the integer value.
  • ldigit = it will hold the integer value.
  • sum = it will hold the integer value.

Input Number from the user for the program.

Sum of the First and Last Digit of a Number.

Printing output addition of the number.

C program to Swap First and Last Digit of a Number

C Program to Swap First and Last Digit of a Number

In this tutorial, we will learn to create a C program that will Swap the First and Last Digit of a Number 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.
  • Arithmetic operations in C programming.
  • Operators in C programming.

What is swapping?

In swapping we swap the data of two variables or the data in the variable. In this program, we will swap the first and last digits from each other and print the resultant data of that variable.

Algorithm:-

Swapping the First and Last Digit of a Number

In this program first, we will take the input number from the userThen we will separate the digits from that number. And at last, we will print that output number

Let us take the example program from the below code for Swap First and Last Digit of a Number.

Program Code:-

 

Output:-

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

 

  • no = it will hold the integer value.
  • fdigit = it will hold the integer value.
  • ldigit = it will hold the integer value.
  • x = it will hold the integer value.
  • y = it will hold the integer value.
  • sno = it will hold the integer value.
  • flag = it will hold the integer value.

Input Number from the user for the program.

Swapping the First and Last Digit of a Number.

Printing output swapped number.

C Program to Print K Shape Alphabets Pattern

C program to Print K Shape Alphabets Pattern

In this tutorial, we will learn to create a C program that will Print K Shape 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.
  • 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 K Shape?

The k Shape pattern means a pattern containing the Alphabets and looks like the Alphabet K. It will be created using two triangles.

Algorithm:-

Program description Printing K Shape Number Pattern:-

In this program, we will first take the input number of rows by the user. Then we will generate the K shape pattern using the for loops and fill it with Alphabetical values. Printing the pattern filled with numbers.

Let’s take the below example for the problem.

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 containing the alphabets.

Printing output pattern using c programming.

C program to Print Box Number Pattern of 1 and 0

C program to Print Box Number Pattern of 1 and 0

In this tutorial, we will learn to create a C program that will Print a Box Number Pattern of 1 and 0 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.

What is the box?

The box can be square or rectangle in shape. We can make shapes in the C programming language. The Box will be filled with numbers, today’s tutorial.

Algorithm:-

Program description Printing a Box:-

In this program, we will first take the input sides of the box in the form of rows and columns. Then we will use nested for loops for the program to print the box of required rows and columns. We will print the box with numbers “0” & “1” only for the shape.

The below is an example of the square program code.

Program Code:-

 

Output:-

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

  • rw = it will hold the integer value.
  • cl = 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.