Category Archives: C Programs

C Programs

C Program to Print 1 to 100 without using Loop

C Program to Print 1 to 100 without using Loop

In this tutorial, we will learn to create a C program that will Print 1 to 100 without using Loop 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.
  • Conditional Statements in c programming.

Algorithm:-

As we all know, the series printing works are done using the loops, but today we will print a series from 1 to 100 without using Loop. In this program, we will first define the variables for the program. Then we will pass that variable to a user-defined function to print the series.

With C programming, we can make many arithmetic series with just a little code.

With the help of this program, we can Print 1 to 100 without using Loop.

Program:-

 

Output:-

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

  • val = it will hold the integer value for the program.
  • num = it will hold the integer value of the number.

Sending the data to the user-defined function for the generation of series.

Program code to print the list up to the given number 100.

C program to print First Digit of Number

C Program to print First Digit of a Number

In this tutorial, we will learn to create a C program that will print the First 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 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 last digit of the number.

Let us take the example program from the below code for printing the First 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.
  • Count = it will hold the integer value.

Input Number from the user for the program.

Finding the First Digit of a Number.

Printing output first and the last digit.

C program to Calculate Electricity Bill

C program to Calculate Electricity Bill

In this tutorial, we will learn to create a C program that will calculate the Electricity Bill in C programming.

Prerequisites

Before starting 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 Operators in C Programming.

What is an Electricity Bill?

The electricity bill is the generated net payable amount charged by the electricity-providing company. The electricity bill is generated on the basis of the consumption of the electricity in units by the consumer.

Algorithm:-

Program Description.

In this program, First will take the input units from the user. Secondly, we will use the conditional statements to generate the electricity bill of the user. At last, we will print the electricity bill of the user.

With the help of the below program, we can calculate the electricity bill.

Program Code:-

Output:-

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

  • bill = it will hold the float value for the bill
  • units = it will hold the input float value for the units.

Taking the input units from the user.

Calculating the Bill of the user.

Printing the output bill.

C program to calculate GCD of Two Numbers

C program to calculate GCD of Two Numbers

In this tutorial, we will learn to create a C program that will calculate the GCD of Two Numbers 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 Operators in C Programming.
  • While Loop in the C programming.

What is the GCD of Two Numbers?

In the GCD of two numbers, it means the greatest common divisor of two numbers is the largest number that divides both of them. It can also be called the highest common factor.

Algorithm:-

Program Description.

In today’s program, we will first take the input numbers from the user in integer format. And after that, we will pass that variable to a for loop and the conditional statements to check the greatest common divisor of two numbers. At last, we will print the result of the greatest common divisor of those numbers to the user.

With the help of the below program, we can calculate the GCD of Two Numbers.

Program Code:-

Output:-

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

  • n1 = it will store the input integer value.
  • n2 = it will store the input integer value.
  • i = it will store the integer value for the loop control.
  • gcd = it will hold the value for the output gcd.

Taking the input numbers from the user.

Calculating the GCD of two numbers.

Printing the output of the program.

C program to calculate Generic Root of a Number

C program to calculate Generic Root of a Number

In this tutorial, we will learn to create a C program that will calculate the Generic Root 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 Operators in C Programming.
  • While Loop in the C programming.

What is the Generic Root of a Number?

In the generic root, it’s the terms of the mathematics where the units of the number are added to find a single-digit number.

Algorithm:-

Program Description.

In today’s program, we will first take the input from the user in numbers more than a single digit. And then we will pass that variable to a while loop for the finding of the generic root of the number. At last, we will print the result generic root of the user after the

With the help of the below program, we can calculate the Generic Root of a Number.

Program Code:-

Output:-

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

  • no = it will store the input integer value.

Taking the input from the user in number.

Calculating the generic root of the number.

Printing the output of the program.

C Program to convert Kilometer to Meter Centimeter and Millimeter

C Program to convert Kilometer to Meter Centimeter and Millimeter

In this tutorial, we will learn to create a C program that will convert the Kilometer to Meter, Centimeter, and Millimeter 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 Operators in C Programming.

What are Kilometer to Meter, Centimeter and Millimeter?

The kilometers, meters, centimeters & millimeters are the metric units for the measurement of length between two points.

Description Table below.

Algorithm:-

Program to convert the kilometers into small units.

In today’s program, we will first take the input from the user in kilometers. And then we will convert that input into meters, centimeters, and millimeters,

With the help of the below program, we can convert the kilometers to subunits.

Program Code:-

Output:-

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

  • km = it will store the input kilometers value.

Taking the input from the user in kilometers.

Converting into smaller values.

Printing the output of the program.

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

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

In this tutorial, we will learn to create a C program that will Print a Square where each column contains one 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.
  • For loop in C programming.
  • Conditional Statements in C programming.

What is Square?

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

Algorithm:-

Program description Print a Square where each column 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 that contains the same number in all columns using the for-loop. Printing that pattern filled with numbers using the c programming language.

Let’s take the below example for the problem.

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 Mirrored Right Triangle Star Pattern

C Program to Print Mirrored Right Triangle Star Pattern

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

Algorithm:-

With the help of this program, we will draw the pattern.

Program description:-

Mirrored patterns are just flipped patterns. In this program, we will first take the input number of rows by the user. Then we will use that input number of rows to draw the Mirrored Right Triangle pattern using the C programming language.

Below is the example program for the mirrored right triangle.

Program Code:-

Output:-

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

  • rows  = 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 Mirrored Right Triangle Star.

Program Code.

Printing output pattern using c programming.

C Program to Print Hollow Mirrored Right Triangle Star Pattern

C Program to Print Hollow Mirrored Right Triangle Star Pattern

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

Program description:-

In this program, we will first take the input number of rows by the user. Then we will use that input number of rows to draw the Hollow Mirrored Right Triangle pattern using the C programming language.

In the Hollow Mirrored Right Triangle, the pattern is hollow from inside and only borders are printed. Let’s take the below example for the problem.

Program Code:-

Output:-

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

  • rows  = 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 Inverted Mirrored Right Triangle Star.

Program Code.

Printing output pattern using c programming.

C Program to Print Inverted Right Triangle Star Pattern

C Program to Print Inverted Right Triangle Star Pattern

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

Program description:-

In this program, we will first take the input number of rows by the user. Then we will use that input number of rows with the nested for loop to draw the Inverted Right Triangle Star pattern using the C programming language.

In the Inverted Right Triangle, the for loop only prints the border of the triangle and is filled with stars.

Printing the Inverted Right Triangle pattern created 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.

  • Rows= 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 Inverted Mirrored Right Triangle Star.

Program Code.

Printing output pattern using c programming.

C Program to Print Hollow Inverted Right Triangle Star Pattern

C Program to Print Hollow Inverted Right Triangle Star Pattern

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

Program description:-

In this program, we will first take the input number of rows by the user. Then we will use that input number of rows with the nested for loop to draw the Hollow Inverted Right Triangle Star pattern using the C programming language.

In the Hollow Inverted Right Triangle, the for loop only prints the border of the triangle.

Printing the Hollow Inverted Right Triangle pattern created 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.

  • rows  = 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 Inverted Mirrored Right Triangle Star.

Program Code.

Printing output pattern using c programming.

C Program to Print Inverted Mirrored Right Triangle Star Pattern

C program to Print Inverted Mirrored Right Triangle Star Pattern

In this tutorial, we will learn to create a C program that will print an Inverted Mirrored Right Triangle 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 star pattern?

The star pattern means a pattern made using C programming filled with the “*”. This pattern is drawn using the nested for loops.

Algorithm:-

Program description:-

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 Inverted Mirrored Right Triangle Star pattern using the C programming language.

Printing the right triangle pattern created 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.

  • rows  = 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 Inverted Mirrored Right Triangle Star.

Program Code.

Printing output pattern using c programming.