Category Archives: C Programs

C Programs

C Program to sort Word in String in Descending Order

C Program to sort Word in String in Descending Order

In this tutorial, we will learn to create a C program that will sort Word in String in Descending Order 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.
  • Conditional statement in C Programming.

Sort Word in String in Descending Order:-

As we all know String 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 string input from the user. Then will pass that string to the for loop to sort it in reverse order. And at last, we will sort Word in String in Descending Order C Programming Language.

Algorithm:-

Program:-

sort Word in String in Descending Order

Output:-

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

  • str[100] = it will hold the elements in a string.
  • flag = it will hold the number of elements in a string
  • len = it will hold the integer value for the length of the string.
  • i = it will hold the integer value to control the array.
  • j = it will hold the integer value to control the array.

Taking input string from the user.

Checking the length of string,

Sorting the string in reverse order.

Printing the results.

 

C Program to count Characters with and without Space

C Program to count Characters with and without Space

In this tutorial, you will learn about the C Program to count Characters with and without Space 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 with and without Space

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 while loop for counting. The C programming language has many pre-defined functions for string manipulation. but in today’s tutorial, we will count Characters with and without Space.

With the help of this program, we can count Characters with and without Space

Algorithm:-

Program:-

Output:-

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

  • str[100] = it will hold the string value.
  • i= it will hold the integer value of the loop.
  • countWithSpace = it will hold the integer value of the counting.
  • countWithoutSpace= it will hold the integer value of the counting.

Taking Input string from the user.

 

Counting the characters from the string entered by the user .

Printing output data characters.

C Program to Print Sum of Digit in given Number

C Program to Print Sum of Digit in given Number

In this tutorial, we will learn to create a C program that will Print Sum of digits in a given Number 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.
  • Conditional Statements in C programming.
  • Arithmetic operations in C Programming.

Program to Print Sum of digits in a given Number

In c programming, it is possible to take numerical input from the user and Print Sum of digits in a 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 files the programming is easy.

With the help of this program, we can Print Sum of digits in a given number.

Algorithm:-

Program to Print Sum of digits in a given number:-

Output:-

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

  • no = it will hold the integer value of the input.
  • sum = it will hold the integer value for sum.
  • m = it will hold the integer value.

Input number from the user.

Program Logic Code.

Printing output for sum the digits.

C Program to Print Next Successive Character

C Program to Print Next Successive Character

In this tutorial, we will learn to create a C program that will Print the Next Successive Character 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.
  • Conditional statements in c programming.
  • String functions of c programming.

Program to Print Next Successive Character

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, we will take the input character from the user then we will Print the Next Successive Character. The ASCII value of the input character will be scanned and increased by 1 and print the character value.

With the help of this program, we can Print the Next Successive Character.

Algorithm:-

Program to Sort Word in String in Ascending Order:-

Output:-

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

  • ch = it will hold the character value for the input.

Input character message and Scan the character from the user.

Getting the ASCII value and calculating the next letter using the conditional statement.

And printing the output character.

C Program to Print Number in Words

C Program to Print Number in Words.

In this tutorial, we will learn to create a C program that will Print Numbers in Words 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.
  • Switch Case in 

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 take the input number and Print Number in Words with the help of the c programming language.

With the help of this program, we can Print Numbers in Words.

Algorithm:-


 

Program to Print Numbers in Words:-

Output:-

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

  • no = it will hold the integer value of number input.
  • num  = it will hold the integer value of number input.

Taking input number from the user.

Program logic.

Printing Output numbers.

C Program to Find LCM & HCF

C Program to Find LCM & HCF

In this tutorial, we will learn to create a C program that will Find LCM & HCF 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 Find LCM & HCF

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

With the help of this program, we can Find LCM & HCF.

Here,

LCM:-Least Common Multiple.

HCF:- Highest Common Factor.

Algorithm:-

 

Program to Find HCF and LCM:-

 

 

Output:-

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

  • x = it will hold the integer value1.
  • y = it will hold the integer value2.
  • a = it will hold the integer value of x.
  • b = it will hold the integer value of y.
  • t = it will hold the integer temporary value.
  • hcf = it will hold the integer value  of calculated hcf.
  • lcm= it will hold the integer value of calculated lcm .

Input number from user.

Program Logic Code.

Printing output

C Program to Add n Numbers

C Program to Add n Numbers

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

Program to Add n Numbers

In c programming, it is possible to take numerical input from the user and Add n 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. In C language, we can do many arithmetic operations.

With the help of this program, we can Add n Numbers.

Here,

We will first take the input

The second will make a series and add the numbers.

Algorithm:-

 

Program to Add n Numbers:-

 

Output:-

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

  • no = it will hold the integer value.
  • i = it will hold the integer value.
  • sum = it will hold the integer value.

Input number from the user.

 

Program Logic Code.

 

Printing output

C Program to Add Subtract Multiply Divide

C Program to Add Subtract Multiply Divide

In this tutorial, we will learn to create a C program that will Add, Subtract, Multiply & Divide 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.

Program to Add Subtract Multiply Divide

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

With the help of this program, we can Add Subtract Multiply Divide.

Here,

We will first take the input

The second will make a series and add the numbers.

Algorithm:-

 

Program to Add Subtract Multiply Divide:-

 

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 number from the user.

 

Program Logic Code and print the output.

 

 

C Program to Print Second Largest & Second Smallest Array Element

C Program to Print Second Largest & Second Smallest Array Element

In this tutorial, we will learn to create a C program that will Print Second Largest & Second Smallest Array Element 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.

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, Print Second Largest & Second Smallest Array Element using C Programming Language.

Algorithm:-

 

Program:-

Print Second Largest & Second Smallest Array Element

Output:-

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

  • a[n] = it will hold the elements in an array.
  • n = it will hold the number of elements in an array.
  • i = it will hold the integer value to control the array.
  • flag = it will hold the integer value.

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

Sorting the array,

Printing the results.

 

C Program to Calculate Telephone Call Bills

C Program to Calculate Telephone Call Bills

In this tutorial, we will learn to create a C program that will Calculate Telephone Call Bills 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 Telephone Call Bills

In c programming, it is possible to take numerical input from the user and calculate Telephone Call Bills 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 Telephone Call Bills using c programming. As per the following rule:

Minimum Rs. 200 for up to 100 calls.
Plus Rs. 0.60 per call for the next 50 calls.
Plus Rs. 0.50 per call for the next 50 calls.
Plus Rs. 0.40 per call for any call beyond 200 calls.

With the help of this program, we can Calculate Telephone Call Bills.

Algorithm:-

 

Program to Calculate Telephone Call Bills:-

 

 

Output:-

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

  • calls = it will hold the integer value for the calls in minutes.
  • bill = it will hold the floating value for the bills.

Input number from the user.

 

Program Logic Code.

 

Printing output for bill generated.

C Program to Print Sum of Even & Product of Odd Digit

C Program to Print Sum of Even & Product of Odd Digit

In this tutorial, we will learn to create a C program that will Print Sum of Even & Product of Odd Digit 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 Print Sum of Even & Product of Odd Digit

In c programming, it is possible to take numerical input from the user and Print Sum of Even & Product of Odd Digit 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.

With the help of this program, we can Print Sum of Even & Product of Odd Digit.

Algorithm:-

 

 

Program to Print Sum of Even & Product of Odd Digit:-

 

Output:-

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

  • evenSum = it will hold the integer value for the sum of numbers.
  • oddProd = it will hold the integer value for the product of the numbers.
  • temp = it will hold the temporary integer value.
  • rem = it will hold the integer value of the remainder.
  • no = it will hold the integer value of the input.

Input number from the user.

 

Program Logic Code.

 

Printing output for sum and the product.

C Program to Round off Floating point Number

C Program to Round off Floating point Number

In this tutorial, we will learn to create a C program that will Round off Floating-point Numbers 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.
  • Conditional Statements in c programming.

Round off Floating point 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 Round off the Floating-point Numbers using the c programming language.

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

With the help of this program, we can Round off Floating-point Numbers.

Algorithm:-


 

Program to Round off Floating point Number:-

 

 

Output:-

Positive round-of:-

Negative round-of:-

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

  • num = it will hold the floating number value.
  • flag = it will hold the integer value.
  • roundNum = it will hold the integer value.
  • tempNum = it will hold the integer value.

Checking the number greater than zero.

Checking the number smaller than zero.

Printing the number equal to zero.