Category Archives: C Programs

C Programs

C Program to Print a Square where each row contains one Number

C Program to Print a Square where each row contains one Number

In this tutorial, we will learn to create a C program that will Print a Square where each row contains one 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.
  • 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 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 Print a Square where each row contains one number:-

In this program, we will first take the input side of the square by the user. Then we will print the square using the for-loop. Printing that pattern filled with numbers in each row contains one number. The below is an example of the square 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 Same Numbers in Rows and Columns

C Program to Print Same Numbers in Rows and Columns

In this tutorial, we will learn to create a C program that will Print the Same Numbers in Rows and Columns 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. 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. The pattern can be any shape square, rectangle, or rhombus.

Algorithm:-

Program description:-

In today’s program, we will first take the input rows and columns from the user. Then we will print the pattern using the for loop containing the same numbers in rows and columns.

The below is an example of the pattern program code filled with numbers.

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.

C Program to print Square Number Pattern

C Program to Print Square Number Pattern

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

In today’s tutorial, we will create a program, that will print a square using for loop taking the size of the side from the user. Very first, taking the input side of the square by the user. Then we will print the square using the for-loop.

The below is an example to print a square number 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 Same Alphabet in each Right Triangle Column

C Program to Print Same Alphabet in each Right Triangle Column

In this tutorial, we will learn to create a C program that will Print the Same Alphabet in each Right Triangle Column 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.

What is Right Angled Triangle?

This triangle plays an important role in trigonometry. A right-angled triangle is a triangle, that has one of its interior angles equal to 90 degrees or a right angle. Therefore, this triangle is also called the right triangle or 90-degree triangle.

Algorithm:-

Program description:-

In today’s tutorial, we will create a program, that will Print the Same Alphabet in each Right Triangle Column using a while loop. First, take the input number of rows in the triangle by the user. Then we will print the simple right-angle triangle of Alphabets using the while-loop. The below is an example to print a Print Same Alphabet in each Right Triangle Column.

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 K Shape Number Pattern

C program to Print K Shape Number Pattern

In this tutorial, we will learn to create a C program that will Print K Shape Number 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 numbers 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 numerical 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 on the screen.

Printing output pattern using c programming.

C program to Print Sandglass Number Pattern

C program to Print Sandglass Number Pattern

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

It is a sand clock for measuring time. This clock uses sand that flows from one part to another at a specific time.

Algorithm:-

Program description Printing Sandglass Number Pattern:-

In this program, we will first take the input number of rows by the user. Then we will generate the sandglass pattern using the for loops and fill it with numerical 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.
  • k = 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 Replacing All Occurrence of a Character in a String

C Program to Replacing All Occurrence of a Character in a String

In this tutorial, we will learn to create a C program that will be Replacing All Occurrence of a Character in a String 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 string?

As we all know the String is a collection of characters and words. The word is a collection of alphabets. For string, only one variable is declared which can store multiple values. The String can consist of all the typeable data it means Digits, Alphabets, Symbols, etc.

Algorithm:-

Replacing All Occurrence of a Character in a String

In this program first, we will take input string from the user. Then we will take the character to be replaced by the user. Then will be Replacing all the Occurrence of the Character in that String. Printing the result string.

Let us take the example program from the below code for Replacing all the Occurrences of the Character in that String.

Program Code:-

Output:-

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

  • str[100] = it will hold the character value.
  • ch = it will hold the character value.
  • Newch = it will hold the character value.
  • i = it will hold the integer value.

Input string from the user for the program and Take the character that needs to be replaced and the new character to Replace.

Replacing that character from the string.

Printing output String after replacement.

C Program to Replace First Occurrence of a Character in a String

C Program to Replace First Occurrence of a Character in a String

In this tutorial, we will learn to create a C program that will Replace the First Occurrence of a Character in a String 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 string?

As we all know the String is a collection of characters and words. The word is a collection of alphabets. For string, only one variable is declared which can store multiple values. The String can consist of all the typeable data it means Digits, Alphabets, Symbols, etc.

Algorithm:-

Removing the First Occurrence of a Character in a String

In this program first, we will take input string from the user. Then we will take the character to be Replaced by the user. Then will be Replacing the First Occurrence of the Character in that String. Printing the result string.

Let us take the example program from the below code for Replacing the First Occurrence of the Character in that String.

Program Code:-

Output:-

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

 

  • strg[100] = it will hold the character value.
  • chr = it will hold the character value.
  • Newchr = it will hold the character value.
  • i = it will hold the integer value.

Input string from the user for the program and Take the character that needs to be replaced and the new character to Replace.

Replacing that character from the string.

Printing output String.

C Program to Replace Last Occurrence of a Character in a String

C Program to Replace Last Occurrence of a Character in a String

In this tutorial, we will learn to create a C program that will Replace the Last Occurrence of a Character in a String 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 string?

As we all know the String is a collection of characters and words. The word is a collection of alphabets. For string, only one variable is declared which can store multiple values. The String can consist of all the typeable data it means Digits, Alphabets, Symbols, etc.

Algorithm:-

Removing the Last Occurrence of a Character in a String

In this program first, we will take input string from the user. Then we will take the character to be replaced by the user. Then will be Replacing the last Occurrence of the Character in that String. Printing the result string.

Let us take the example program from the below code for Replacing the Last Occurrence of the Character in that String.

Program Code:-

Output:-

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

 

  • str[100] = it will hold the character value.
  • ch = it will hold the character value.
  • Newch = it will hold the character value.
  • i = it will hold the integer value.

Input string from the user for the program and Take the character that needs to be replaced and the new character to Replace.

Replacing that character from the string.

Printing output String.

C Program to Removing All Occurrences of a Character in a String

C Program to Remove All Occurrences of a Character in a String

In this tutorial, we will learn to create a C program that will Remove All Occurrences of a Character in a String 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 string?

As we all know the String is a collection of characters and words. The word is a collection of alphabets. For string, only one variable is declared which can store multiple values. The String can consist of all the typeable data it means Digits, Alphabets, Symbols, etc.

Algorithm:-

Removing All the Occurrences of a Character in a String

In this program First, we will take input strings from the user. Then we will take the character to be searched and removed from the string. Then will be Removing all the Occurrence of the Character in that String. Printing the result string.

Let us take the example program from the below code for Removing all the Occurrences of that Character in that String.

Program Code:-

 

Output:-

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

  • str[100] = it will hold the string value.
  • ch = it will hold the string value.
  • len = it will hold the integer value.
  • i = it will hold the integer value.

Input string from the user for the program and Take the input character from the user to remove.

Removing that character from the string.

Printing output String.

C Program to Find Minimum Occurring Character in a String

C Program to Find Minimum Occurring Character in a string

In this tutorial, we will learn to create a C program that will Find the Minimum Occurring Character in a string 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 string?

As we all know the String is a collection of characters and words. The word is a collection of alphabets. For string, only one variable is declared which can store multiple values. The String can consist of all the typeable data it means Digits, Alphabets, Symbols, etc.

Algorithm:-

Find the Minimum Occurring Character in a string

In this program first, we will take input string from the user. Then we will count the characters in that string separately. Then will find the Minimum occurrence of the character in that string. Printing the Minimum occurring character from that string.

Let us take the example program from the below code to find the Minimum occurrence of the character.

Program Code:-

 

Output:-

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

  • strg[100] = it will hold the string value.
  • result = it will hold the string value.
  • len = it will hold the integer value.
  • i = it will hold the integer value.
  • min = it will hold the integer value

Input string from the user for the program.

Calculating the max character from the string.

Printing output character from the string.

C Program to Find Maximum Occurring Character in a string

C Program to Find Maximum Occurring Character in a string

In this tutorial, we will learn to create a C program that will Find the Maximum Occurring Character in a string 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 string?

As we all know the String is a collection of characters and words. The word is a collection of alphabets. For string, only one variable is declared which can store multiple values. The String can consist of all the typeable data it means Digits, Alphabets, Symbols, etc.

Algorithm:-

Find the Maximum Occurring Character in a string

In this program first, we will take input string from the user. Then we will count the characters in that string separately. Then will find the maximum occurrence of the character in that string. Printing the maximum occurring character from that string.

Let us take the example program from the below code to find the maximum occurrence of the character.

Program:-

 

Output:-

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

 

  • strg[100] = it will hold the string value.
  • result = it will hold the string value.
  • len = it will hold the integer value.
  • i = it will hold the integer value.
  • max = it will hold the integer value

Input string from the user for the program.

Calculating the max character from the string.

Printing output character from the string.