Category Archives: C Programs

C Programs

C program to find ASCII Values of all Characters

C Program to find the ASCII Value of All Characters

In this tutorial, we will learn to create a C program that will find the ASCII Value of All Characters 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.

What is ASCII value?

The ASCII stands for American Standard Code for Information Interchange. The ASCII is used for character encoding for text data in computers and other devices. There is a total of 256 ASCII values. ASCII is a subset of Unicode and is made up of 128 symbols in the character set.

Algorithm:-

Program to print ASCII Value of All Characters.

In today’s program, we will first declare a variable in integer format having the value “i=0”. Then we will use a for loop printing all the values. There are 256 values in ASCII, and 128 of them are unique characters.

With the help of the below program, we can print the ASCII value of all characters.

Program Code:-

Output:-

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

  • i = it will hold the integer value for the loop.

For loop for values.

Finding the character ASCII values and printing the values.

Main function code of the program.

C Program to check Character is Alphabet or Digit

C Program to Check Character is Alphabet or Digit

In this tutorial, we will learn to create a C program that will Check the Character is Alphabet or Digit 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.

What is a character?

The character is a single entity in the English language or in any word. These characters can be anything alphabets, digits.

For Example:-

In the word “W3Adda”, there are six characters, they are as follows

  1. “W”
  2. “3”
  3. “A”
  4. ‘d’
  5. ‘d’
  6. ‘a’

Here,

“W” is an alphabet.

“3” is a digit.

“A, d, d, a” are also alphabets.

Algorithm:-

Program to check Character is Alphabet or Digit

First, we will take the input character from the user. Then will pass that character in the conditional statements to find whether the character is the alphabet or digit.

With the help of this program, we can Check the Character with the conditions.

Program Code:-

Output:-

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

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

Input character from the user.

Checking the given character is an alphabet, digit.

Printing output for the program.

C Program to find the ASCII Value of Total Characters in a String

C Program to find the ASCII Value of Total Characters in a String

In this tutorial, we will learn to create a C program that will find the ASCII Value of Total Characters in a String 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.

What is ASCII value?

The ASCII stands for American Standard Code for Information Interchange. The ASCII is used for character encoding for text data in computers and other devices. ASCII is a subset of Unicode and is made up of 128 symbols in the character set.

Algorithm:-

Program to ASCII Value of Total Characters in a String

In today’s program, we will first take the input string from the user for the program. Then we will find the values for all characters using a for loop. Then we will Print the ASCII values of each character in the string.

With the help of the below program, we can Check the ASCII value of total Characters in a string.

Program Code:-

Output:-

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

  • str = it will hold the string value for the input.

Input string from the user.

Finding the character ASCII values.

Printing output for the program.

C Program for Average of Two Numbers

C Program to Average of Two Numbers

In this tutorial, we will learn to create a C program that will Calculate the Average 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 operator in C programming.

What is the average of number?

The average of numbers in mathematics means that all the numbers are added and then the sum of all the numbers is divided by the total number of objects.

It means if there are 4 number as follows {2,4,6,8} then the average will be:-

average = 2+4+6+8/4

average = 5.

Algorithm:-

Program to Calculate the average of a Number

In this program, we will take two numbers in input from the user. Then we will add that number and store it in a variable. After that, we will divide the sum of those numbers by 2 to find the average. At last, we will print the average of two numbers.

With the help of this program, we can find the average of two numbers.

Program code:-

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.
  • sum = it will hold the integer value.
  • average = it will hold the float value.

Taking input number from the user to find the cube.

Calculating the average of those numbers.

Printing output average for that given numbers.

C program to Calculate Cube of a Number

C Program to Calculate Cube of a Number

In this tutorial, we will learn to create a C program that will Calculate the Cube 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.
  • For loop and its concepts in C Programming.
  • Conditional Statements in C Programming.

What is a cube of a number?

The cube of any number means a number multiplied by itself 3 times. This can also be called ‘a number cubed’. The symbol for cube is ³ {the power of any is 3 for cube}.

Algorithm:-

Program to Calculate the Cube of a Number

In this program, we will take a number in input from the user. Then we will multiply that number by itself 3 times. After that, we will print the resultant answer to the user as an output.

With the help of this program, we can cube a number.

Program code:-

Output:-

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

  • Number = it will hold the integer value.
  • Cube = it will hold the integer value.

Taking input number from the user to find the cube.

Calculating the cube of that number.

Printing output cube for that given number.

C Program to find the Leap Year

C Program to find the Leap Year

In this tutorial, we will learn to create a C program that will find the Leap Year 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.

What is a Leap year?

A leap year contains 366 days. Leap year occurs every fourth year and has one extra day that day is adjusted in February month. The leap year means a year that must be divisible by four rather than the end-of-century years, which must be divisible by 400. This means that the year 2000 was a leap year, but 1900 was not.

Algorithm:-

Program to find the Leap Year

In this program today, we will take the integer input from the user as a year and store it in a variable. Then we will pass that variable to a conditional statement to check whether it’s a leap year or not. After that, we will print the output to the console.

With the help of this program, we can find the Leap Year.

Program code:-

Output:-

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

  • yr = it will hold the integer value.

Taking input year from the user.

Calculating the leap year using the program.

Printing Output year.

C Program to Convert Character to Uppercase

C Program to Convert Character to Uppercase

In this tutorial, we will learn to create a C program that will Convert Character to Uppercase 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.

What is a character?

The character is a single entity in the English language or in any word. These characters can be any alphabets in lower case or upper case.

The lower case means the small letters. And the upper case means the capital letters of the English language.

For Example:-

In the word “W3Adda”, there are six characters, they are as follows

Here,

‘W’ is a character in the Upper case.

‘3’ is a digit.

‘A’ is a character in the upper case.

‘d’ is a character in the lowercase.

‘d’ is a character in the lower case.

‘a’ is a character in the lowercase.

Algorithm:-

Program to Convert Character to Uppercase

First, we will take the input character from the user. Then will pass that character in the conditional statements to check and convert it into the character to Upper case.

With the help of this program, we can convert that character to upper case.

Program Code:-

Output:-

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

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

Input character from the user.

Checking the given character is an alphabet and covert it into an upper case alphabet.

Printing lowercase characters.

C Program to Convert Character to Lowercase

C Program to Convert Character to Lowercase

In this tutorial, we will learn to create a C program that will Convert Character to Lowercase 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.

What is a character?

The character is a single entity in the English language or in any word. These characters can be any alphabets in lower case or upper case.

The lower case means the small letters. And the upper case means the capital letters of the English language.

For Example:-

In the word “W3Adda”, there are six characters, they are as follows

  1. ‘W’
  2. ‘3’
  3. ‘A’
  4. ‘d’
  5. ‘d’
  6. ‘a’

Here,

‘W’ is a character in the Upper case.

‘3’ is a digit.

‘A’ is a character in the upper case.

‘d’ is a character in the lowercase.

‘d’ is a character in the lower case.

‘a’ is a character in the lowercase.

Algorithm:-

Program to Convert Character to Lowercase

First, we will take the input character from the user. Then will pass that character in the conditional statements to check and convert it into the character to lower case.

With the help of this program, we can convert that character to lower case.

Program Code:-

Output:-

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

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

Input character from the user.

Checking the given character is an alphabet and covert it into a lower case alphabet.

Printing lowercase characters.

C program to calculate LCM of Two Numbers

C program to calculate LCM of Two Numbers

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

What Is The Least Common Multiple (LCM)?

The LCM stands for least common multiple and is also known as the lowest common multiple in mathematics. The least common multiple of two or more numbers is the smallest number among all common multiples of the given input numbers.

Program to Find LCM

In this program, we will take the integer input from the user, i.e. number 1 AND number 2. Then in the program, we will while loop to find the LCM for both the numbers. After that, we will print the LCM of those two numbers using the printf() statement.

Let us take a look at the below program to find the LCM of two numbers.

Program to Find LCM:-

 

Output:-

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

  • no1 = it will hold the integer value1.
  • no2 = it will hold the integer value2.
  • max = it will hold the integer value of the calculated LCM.

Input number from user.

Program Logic Code.

Printing output.

C Program to check character is a digit or not using IsDigit function

C Program to Check Character is Alphabet Digit or Special Character

In this tutorial, we will learn to create a C program that will Check the Character is Alphabet Digit or Special Character 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.

What is a character?

The character is a single entity in the English language or in any word. These characters can be anything alphabets, digits, special symbols, 

For Example:-

In the word “W3Adda@”, there are six characters, they are as follows

  1. “W”
  2. “3”
  3. “A”
  4. “d”
  5. ‘d’
  6. ‘a’
  7. ‘@’

Here,

“W” is an alphabet.

“3” is a digit.

“A, d, d, a” are also alphabets.

“@” is a Special Character.

Algorithm:-

Program to check character is a digit or not using IsDigit function

First, we will take the input character from the user. Then will pass that character in the conditional statements to find whether the character is the digit or not without using the isdigit function.

With the help of this program, we can Check the Character with the conditions.

Program Code:-

Output:-

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

  • chr = it will hold the input value.

Input character from the user.

Checking the given character is digit or not.

Printing output for the program.

C Program to Check Character is Alphabet Digit or Special Character

C Program to Check Character is Alphabet Digit or Special Character

In this tutorial, we will learn to create a C program that will Check the Character is Alphabet Digit or Special Character 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.

What is a character?

The character is a single entity in the English language or in any word. These characters can be anything alphabets, digits, special symbols, 

For Example:-

In the word “W3Adda@”, there are six characters, they are as follows

  1. “W”
  2. “3”
  3. “A”
  4. “d”
  5. ‘d’
  6. ‘a’
  7. ‘@’

Here,

“W” is an alphabet.

“3” is a digit.

“A, d, d, a” are also alphabets.

“@” is a Special Character.

Algorithm:-

Program to check Character is Alphabet Digit or Special Character

First, we will take the input character from the user. Then will pass that character in the conditional statements to find whether the character is the alphabet, digit, special character.

With the help of this program, we can Check the Character with the conditions.

Program Code:-

Output:-

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

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

Input character from the user.

Checking the given character is an alphabet, digit, or special character.

Printing output for the program.

C Program to Check Character is Lowercase or Not

C Program to Check Character is Lowercase or not

In this tutorial, we will learn to create a C program that will Check the Character in Lowercase or Not 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.

What is a character?

The character is a single alphabetical entity in the English language and in any word. These letters can be both capital & small or uppercase & lowercase.

For Example:-

In the “World” word the there are five characters, they are as follows

  1. “W”
  2. “o”
  3. “r”
  4. “l”
  5. ‘d’

Here,

“W” is an uppercase letter.

“o” is a lowercase letter.

“r” is a lowercase letter.

“l” is a lowercase letter.

“d” is a lowercase letter.

Algorithm:-

Program to Check the Character is Lowercase or Uppercase Alphabet

First, will take the character in input from the user. Then will pass that character in the conditional statements to find whether it is lowercase or not.

With the help of this program, we can Check the Character is in lowercase or not.

Program Code:-

Output:-

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

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

Input character from the user.

Finding the character is in lower case or not.

Printing output for the program.