Category Archives: C Programs

C Programs

C Program to Print Hollow Inverted Mirrored Right Triangle Star Pattern

C program to Print Hollow Inverted Mirrored Right Triangle Star Pattern

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

Program Code.

Printing output pattern using c programming.

C Program to Print Rhombus Star Pattern

C program to Print Rhombus Star Pattern

In this tutorial, we will learn to create a C program that will Print 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 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 Rhombus pattern using the C programming language.

Printing the 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.

  • 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 Rhombus.

Program Code.

Printing output pattern using c programming.

C Program to accept User Input and Print

C Program to accept User Input and Print

In this tutorial, we will learn to create a C program that will accept User Input and Print 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.

What is an integer?

The integer is a positive or negative whole number including zero. These are the number real numbers.

Algorithm to print:-

Program to Print Integer 

As we all know the integer, character, float, or double value in c programming. In c programming, we can take the input from the user in character & number format. In this program, we will take input in integer format. The second will display the integer & character with the help of a small program. The integer & character are the most useful terminology in any programing language. For number/arithmetic manipulation in c programming, there are many predefined functions available.

With the help of this program, we can accept User Input and Print.

Program Code:

Output:-

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

  • num = it will hold the input number value from the user.
  • ch = it will hold the character number value from the user.

Taking Input character from the user.

Taking the number value.

Printing the number value.

 

C program to find Gross Salary of an Employee

C program to find Gross Salary of an Employee

In this tutorial, we will learn to create a C program that will calculate the Gross Salary of an Employee using C programming.

Prerequisites

Before starting with the 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 statement in C programming.

Program to Calculate Gross Salary of an Employee:-

In c programming, it is possible to take numerical input from the user and calculate the Gross using Basic Salary with the help of a very small amount of code. The C language has many types of header libraries which has supported function in them, with the help of these files the programming is easy.

Algorithm:-

With the help of this program, we can calculate the bonus & Gross using Basic Salary.

 

Output:-

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

  • basic = it will hold the float value for the basic salary.
  • bonus = it will hold the float value for the bonus salary.
  • gross = it will hold the float value for the gross salary.

Input salary for the employee.

Bonus Salary for the employee.

Gross Salary for the employee.

Printing output for salary for the employee.

C program to find NCR Factorial of a Number

C program to find NCR Factorial of a Number

In this tutorial, we will learn to create a C program that will find NCR Factorial of a Number using 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.

Algorithm:-

Finding the NCR Factorial of a number:-

In this program, we will take the input numbers N and R from the user. Then we will pass that number to a for loop to calculate the factorial. Then we will print that factorial for N & R using the printf() function.

With the help of the below program, we can find the NCR Factorial of a Number.

Program Code:-

 

Output:-

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

  • no= it will hold the integer value for the input.
  • re = it will hold the integer value for the input.
  • i = it will hold the integer value for the controlling of the loop.

Taking the input N and R number from the user.

Converting the factorial for the number.

Printing output.

C program to print Natural Numbers in Reverse Order

C program to Print Natural Numbers in Reverse Order

In this tutorial, we will learn to create a C program that will print Natural Numbers in Reverse Order using 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.
  • Arithmetic operations in C Programming.

Algorithm:-

In this program, we will take the input number from the user. Then we will pass that number to a for loop to make the series. Then we will print that series of natural numbers in reverse order using the printf() function.

With the help of the below program, we can print Natural Numbers in Reverse Order.

Program Code:-

 

Output:-

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

  • start = it will hold the integer value for the input.
  • i = it will hold the integer value for the controlling of the loop.

Taking the input amount from the user.

Converting the notes for the amount.

Printing output.

C program, to calculate Product of Digits of a Number

C program to calculate Product of Digits of a Number

In this tutorial, we will learn to create a C program that will calculate the Product of Digits of a Number using 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.
  • Arithmetic operations in C Programming.

Algorithm:-

Calculate the Product of Digits of a number:-

In this program, we will take the input number from the user. Then we will pass that number to a while loop to break it down. Then we will use arithmetic statements to find the digits from that number. After that, we will find the product of the digits. At last, we will print the product of the digits to the user.

With the help of the below program, we can find a product of the digits in a number.

Program Code:-

 

Output:-

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

  • no = it will hold the integer value for the input.
  • i = it will hold the integer value for the controlling of the loop.
  • rem = it will hold the integer value for the reminder.
  • prod = it will hold the integer value for the product.

Taking the input amount from the user.

Converting the notes for the amount.

Printing output.

C Program to find Total Notes in a Given Amount

C Program to find Total Notes in a Given Amount

In this tutorial, we will learn to create a C program that will find Total Notes in a Given Amount using 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.
  • Arithmetic operations in C Programming.

Algorithm:-

Find Total Notes in a Given Amount:-

In this program, we will take the input amount of currency from the user. Then we will pass that amount to the for loop and conditional statements to find the number of notes for that amount. At last, we will print the number of notes to the user.

With the help of the below program, we can convert days to weeks and years.

Program Code:-

 

Output:-

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

  • Amount = it will hold the integer value for the input.
  • i = it will hold the integer value for the controlling of the loop.
  • flag = it will hold the temporary integer value.

Taking the input amount from the user.

Converting the notes for the amount.

Printing output.

C Program to Convert Days to Years Weeks and Days

C Program to Convert Days to Years, Weeks, and Days

In this tutorial, we will learn to create a C program that will Convert Days to Years Weeks, and Days using 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.
  • Arithmetic operations in C Programming.

Algorithm:-

Find the Day Name of a Week:-

In today’s program, we will take the input number of days from the user. Then we will pass that variable to the mathematical expressions to find the number of weeks and years. At last, we will print the resulting years and the weeks to the user.

With the help of the below program, we can convert days to weeks and years.

Program Code:-

 

Output:-

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

  • days = it will hold the integer value for the input.
  • years = it will hold the integer value.
  • weeks = it will hold the integer value.

Taking the input day from the user.

Converting the days to years.

Printing output.

C Program to find the Day Name of a Week

C Program to find the Day Name of a Week

In this tutorial, we will learn to create a C program that will Find the Day Name of a Week using 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.
  • Arithmetic operations in C Programming.

Algorithm:-

Find the Day Name of a Week:-

In today’s program, we will take the input day in a range between 1 to 7 from the user. Then we will pass that variable to the conditional statements to find the name of days. At last, we will print the resulting name of the day to the user.

With the help of the below program, we can find the name of the day in a week.

Program Code:-

 

Output:-

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

  • wd = it will hold the integer value for the input.

Taking the input day from the user.

Finding the name of the day in a week.

Printing output.

C Program to Find Number of Days in a Month

C Program to Find Number of Days in a Month

In this tutorial, we will learn to create a C program that will Find the Number of Days in a Month using 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.
  • Arithmetic operations in C Programming.

Algorithm:-

Find Number of Days in a Month:-

In today’s program, we will take the input month in a range between 1 to 12 from the user. Then we will pass that variable to the conditional statements to find the number of days. At last, we will print the resulting number of days to the user.

With the help of the below program, we can find the number of days in a month.

Program Code:-

 

Output:-

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

  • month = it will hold the integer value for the input.

Taking the input month from the user.

Finding the number of days in a month.

Printing output.

C program to print Prime Numbers from 1 to 100

C program to print Prime Numbers from 1 to 100

In this tutorial, we will learn to create a C program that will print Prime Numbers from 1 to 100 using 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.
  • Arithmetic operations in C Programming.

Algorithm:-

Prime Numbers:-

The prime numbers are those numbers that are only divisible by themselves. These numbers can’t be complete, divide by the 2 & 3.

Display Prime Numbers Between 1 and 100:-

In today’s program, we will define the input range to print the prime numbers between them. Then we will find the prime numbers between the range using the for loops and the conditional statements. Now we will print the prime numbers.

With the help of this program, we can Display Prime Numbers Between Two 1 to 100 Using For Loop and conditional statements.

Program Code to print prime numbers:-

 

Output:-

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

  • i = it will hold the integer value of the loop.
  • no = it will hold the integer value of the loop.
  • flag = it will hold the temporary value.

The parent for loop to define the range.

Defining the child loop for the program.

Printing output prime numbers between the range of 1 to 100.