Category Archives: C Programs

C Programs

C Program to Count Positive Negative Zero

C Program to Count Positive Negative Zero

In this tutorial, we will learn to create a C program that will Count Positive Negative Zero 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.
  • Arithmetic operations in C Programming.
  • While Loop in C programming.
  • Conditional Statements in C programming.

Program to Count Positive Negative Zero

In c programming, it is possible to take numerical input from the user and Count Positive Negative Zero from the given number 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 functions, the programming is easy.

With the help of this program, we can Count Positive Negative Zero.

Here,

We will first take the input

The second will make Count Positive Negative Zero.

Algorithm:-

 

Program to Count Positive Negative Zero:-

 

 

Output:-

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

  • size = it will hold the integer value.
  • no = it will hold the integer value.
  • positive = it will hold the integer value.
  • negative = it will hold the integer value.
  • zero = it will hold the integer value.

Input number from the user.

Program Logic Code.

Printing the output.

C Program to Calculate Arithmetic Mean

C Program to Calculate Arithmetic Mean

In this tutorial, we will learn to create a C program that will Calculate Arithmetic Mean 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.
  • Arithmetic operations in C Programming.
  • For Loop in C programming.

Program to Calculate Arithmetic Mean

In c programming, it is possible to take numerical input from the user and Calculate the Arithmetic Mean 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 functions, the programming is easy.

With the help of this program, we can Calculate Arithmetic Mean.

Here,

We will first take the input

The second will make Calculate the Arithmetic Mean.

Algorithm:-

 

Program to Calculate Arithmetic Mean:-

 

Output:-

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

  • size = it will hold the integer value.
  • i = it will hold the integer value.
  • num = it will hold the float value.
  • sum = it will hold the float value.
  • am = it will hold the float value.

Input number from the user.

 

Program Logic Code.

Printing the output.

C Program to Calculate Wage of Labor on Daily Basis

C Program to Calculate Wage of Labor on Daily Basis

In this tutorial, we will learn to create a C program that will Calculate the Wage of Labor on a Daily Basis 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.
  • While loop in C programming.
  • Arithmetic operations in C Programming.

Program to Calculate Wage of Labor on Daily Basis

In c programming, it is possible to take numerical input from the user and Calculate the Wage of Labor on Daily Basis 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. But today we will Calculate the Wage of Labor on Daily Basis using c programming.

As per the following rule:

With the help of this program, we can Calculate the Wage of Labor on a Daily Basis.

Algorithm:-

 

Program to Calculate the Wage of Labor on a Daily Basis:-

 

Output:-

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

  • name = it will hold the character value for the name.
  • initWage = it will hold the floating value for the workers.
  • hours = it will hold the floating value for the working hours.
  • temphour = it will hold the floating value.
  • tempWage = it will hold the floating value.
  • totalWage = it will hold the floating value to calculate the wages.

Input name and hour from the user.

 

Program Logic Code.

 

Printing output for wages calculated.

C Program to Find Total Number of Digit in a Given Number

C Program to Find Total Number of Digit in a Given Number.

In this tutorial, we will learn to create a C program that will Find the Total Number of digits in a Given 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.
  • While loop in c programming.

Finding Total Number of Digits in a Given Number.

As we all know the c programming is a very powerful language. In the c programming language, we have many pre-defined functions for arithmetic operations. but today we will count the number of digits in a number with the help of a while loop.

With the help of this program, we can Find the Total Number of digits in a Given Number.

Algorithm:-


 

Program to Find Total Number of Digits in a Given Number:-

 

Output:-

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

  • flag= it will hold the integer value for numbers.
  • no = it will hold the integer value of number input.

Display message to Take input number from the user.

Scanning the input number and storing it to a variable.

While loop to get the number of digits in a number.

Printing output of the program.

C Program to calculate Charges for Sending Parcels as per Weight

C Program to calculate Charges for Sending Parcels as per Weight

In this tutorial, we will learn to create a C program that will Charge for Sending Parcels as per Weight using C programming.

Charges for Sending Parcels as per Weight

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.
  • Arithmetic operations in C Programming.

Program to Charges for Sending Parcels as per Weight

In c programming, it is possible to take numerical input from the user and Charges for Sending Parcels as per Weight 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. But today we will Charge for Sending Parcels as per Weight using c programming.

As per the following rule:

The minimum charge for a parcel equal to or lighter than the 2k.g. will be 32.50 and for each extra Kg,  there is an additional charge of 10.50


Algorithm:-

With the help of this program, we can Charge for Sending Parcels as per Weight.

 

Program to Calculate the Charges for Sending Parcels as per Weight:-

 

 

Output:-

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

  • wght= it will hold the floating value.
  • initCharge = it will hold the floating value initial value 32.50.
  • perCharge = it will hold the floating value initialvalue 10.50.
  • tempWght= it will hold the floating value.
  • addCharge= it will hold the floating value.
  • totalCharge= it will hold the floating value.

Input weight for the parcel.

 

Program Logic Code.

 

Printing output for shipping calculated.

C Program to find Smallest of Three Numbers

C Program to find Smallest of Three Numbers

In this tutorial, we will learn to create a C program that will find the Smallest of Three Numbers 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.
  • Conditional statement in C programming.

Program to find the Smallest of Three Numbers

In c programming, it is possible to take numerical input from the user and find the Smallest of Three Numbers 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. But today we will find the Smallest of Three Numbers using c programming.

Algorithm:-

With the help of this program, we can find the Smallest of Three Numbers.

 

Program to find the Smallest of Three Numbers:-

 

Output:-

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

  • no1 = it will hold the integer value.
  • no2 = it will hold the integer value.
  • no3 = it will hold the integer value.

Input numbers for the program.

 

Program Logic Code.

Printing output for smallest number.

C Program to find Smallest of Two Numbers

C Program to find Smallest of Two Numbers

In this tutorial, we will learn to create a C program that will find the Smallest of two Numbers 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.
  • Conditional statement in C programming.

Program to find the Smallest of two Numbers

In c programming, it is possible to take numerical input from the user and find the Smallest of two Numbers 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. But today we will find the Smallest of two Numbers using c programming.

Algorithm:-

With the help of this program, we can find the Smallest of two Numbers.

 

Program to find the Smallest of two Numbers:-

 

 

Output:-

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

  • no1 = it will hold the integer value.
  • no2 = it will hold the integer value.

Input numbers for the program.

First number

Second Number
Scanning First Number
Scanning Second Number

 

Program Logic Code in the conditional statement.

Printing output for smallest number.

C Program to Calculate Bonus & Gross using Basic Salary

C Program to Calculate Bonus & Gross using Basic Salary

In this tutorial, we will learn to create a C program that will Calculate bonuses & Gross using Basic Salary using C programming.

Prerequisites

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

Program to Calculate bonuses & Gross using Basic Salary

In c programming, it is possible to take numerical input from the user and calculate the bonus & 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.

 

Program :-

 

 

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 Calculate Purchase Amount to be Paid after Discount

C Program to Calculate Purchase Amount to be Paid after Discount

In this tutorial, we will learn to create a C program that will Purchase Amounts to be Paid after Discount using C programming.

Prerequisites

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

Program to Calculate Purchase Amount to Pay after Discount

In c programming, it is possible to take numerical input from the user and Purchase Amounts to Pay after Discount 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 Purchase Amounts to Pay after Discount.

Program:-

Output:-

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

  • amt = it will hold the float value for the basic amount.
  • discount = it will hold the float value for the discount amount.
  • amtToBePaid = it will hold the float value for the gross amount.

Input amount from the user.

Calculating the discount.

Printing amount after giving the discount.

C Program to remove all extra Spaces from String

C Program to remove all extra spaces from String

In this tutorial, we will learn to create a C program that will remove all extra Spaces from String 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.
  • While loop in C Programming.

Remove all extra Spaces from String

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. First will take the number of elements of an array from the user as a string. Then we will remove the extra spaces for a string using a while loop.  With the help of C Programming Language.

Algorithm:-

Program:-

Remove all extra Spaces from String.

 

Output:-

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

  • str[100] = it will hold the elements in an array.
  • blank[100] = it will hold the number of elements in an array.
  • c = it will hold the integer value to control the array.
  • d = it will hold the value of the blank space to be removed.

Taking input from the user in an array as a string to sort and remove extra spces.

Filtering the string value by removing the extra spaces using While Loop.

Printing output without extra blank spaces.

C Program to count Characters, Spaces, Tabs, Newline in a File

C Program to count Characters, Spaces, Tabs, Newline in a File

In this tutorial, you will learn about the C Program to count Characters, Spaces, Tabs, Newline in the File with a practical example.

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.
  • Concepts of while loop.
  • Conditional Statements in C programming.
  • Using file functions of c language.

Count Characters, Spaces, Tabs, Newline in a File

As we all know the String is a collection of character data types. In strings, only one variable is declared which can store multiple values. First will take the string from the user. Then will pass that string to a for loop for copying. The C programming language has many pre-defined functions for string manipulation. but in today’s tutorial, we will count Characters, Spaces, Tabs, Newline in a File.

With the help of this program, we can count Characters, Spaces, Tabs, Newline in a File

Algorithm:-

Program:-

Output:-

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

  • *fp[100] = it will hold the address value.
  • ch = it will hold the character value.
  • fname[30] = it will hold the string value of the file name.
  • noOFChar = it will hold the string value of the file name.
  • noOFSpaces = it will hold the string value of the file name.
  • noOFTab = it will hold the string value of the file name.
  • noOFNewline = it will hold the string value of the file name.

Taking Input string from the user.

 

Reading the file.

Counting the characters, spaces, tabs, newline.

Printing output data.

C Program to Find Common Elements in Two Array

C Program to Find Common Elements in Two Array

In this tutorial, we will learn to create a C program that will Find Common Elements in Two Arrays 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.

Find Common Elements in Two Array:-

As we all know array is a collection of similar data type elements. In an array, only one variable is declared which can store multiple values. First will take the number of elements of an array from the user. Then will take the elements from the user for the array. And at last, we will Find Common Elements in Two Array C Programming Language.

Algorithm:-

 

Program:-

Find Common Elements in Two Array

 

Output:-

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

  • p[max] = it will hold the elements in an array.
  • q[max] = it will hold the elements in an array.
  • r[max] = it will hold the elements in an array.
  • n = it will hold the number of elements in an array.
  • m = it will hold the number of elements in an array.
  • i = it will hold the integer value to control the array.
  • j = it will hold the integer value to control the array.
  • k = it will hold the integer value to control the array.

Taking input from the user in an array number of elements in the array.

Checking the array,

Printing the results.