Category Archives: C Programs

C Programs

C Program to Convert Octal to Binary

C Program to Convert Octal to Binary

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

Program to Convert Octal to Binary:-

As we all know the c is a very powerful language. With the help of c programming language, we can make many programs. We cal perform many input-output operations using c programming. In today’s tutorial, we take the input in octal from the user and convert it into binary. With the help of c programming, we can perform many conversion operations.

With the help of this program, we can Convert Octal to binary

Algorithm:-

 

Program to Convert Octal to Binary:-

Output:-

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

  • oct = in will hold the integer value.

Taking the input.

Octal to decimal.
Decimal to binary.
Printing the binary data.
Main Function.

 

C Program to Convert Octal to Hexadecimal

C Program to Convert Octal to Hexadecimal

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

Program to Convert Octal to Hexadecimal:-

As we all know the c is a very powerful language. With the help of c programming language, we can make many programs. We cal perform many input-output operations using c programming. In today’s tutorial, we take the input in octal from the user and convert it into hexadecimal. With the help of c programming, we can perform many conversion operations.

With the help of this program, we can Convert Octal to Hexadecimal.

Algorithm:-

 

Program to Convert Octal to Hexadecimal:-

Output:-

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

  • hexadecimal[] = it will hold the character value for the program.
  • octaltobinary[] = in will hold the integer value.
  • i = it will hold the integer value.

Taking the input.

Octal to Binary.
Binary to Hexadecimal.
Printing the Decimal data.

 

C Program to Convert Hexadecimal to Binary

C Program to Convert Hexadecimal to Binary

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

Program to Convert Hexadecimal to Binary:-

As we all know the c is a very powerful language. With the help of c programming language, we can make many programs. We cal perform many input-output operations using c programming. In today’s tutorial, we take the input in hexadecimal from the user and convert it into binary. With the help of c programming, we can perform many conversion operations.

With the help of this program, we can Convert Hexadecimal to Binary.

Algorithm:-

 

Program to Convert Hexadecimal to Binary:-

Output:-

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

  • hex[100] = it will hold the Hexa value for the program.

Hexa to binary

Printing the binary data.

 

Main function.

C Program to Convert Hexadecimal to Decimal

C Program to Convert Hexadecimal to Decimal

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

Program to Convert Hexadecimal to Decimal:-

As we all know the c is a very powerful language. With the help of c programming language, we can make many programs. We cal perform many input-output operations using c programming. In today’s tutorial, we take the input in hexadecimal from the user and convert it into Decimal. With the help of c programming, we can perform many conversion operations.

With the help of this program, we can Convert Hexadecimal to Decimal.

Algorithm:-

 

Program to Convert Hexadecimal to Decimal:-

Output:-

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

  • hex[] = it will hold the Hexa value for the program.
  • i = it will hold the integer value.

Taking the input.

Hexadecimal to Decimal.
Printing the Decimal data.

C Program to Convert Hexadecimal to Octal

C Program to Convert Hexadecimal to Octal

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

Program to Convert Hexadecimal to Octal:-

As we all know the c is a very powerful language. With the help of c programming language, we can make many programs. We cal perform many input-output operations using c programming. In today’s tutorial, we take the input in hexadecimal from the user and convert it into octal. With the help of c programming, we can perform many conversion operations.

With the help of this program, we can Convert Hexadecimal to Octal.

Algorithm:-

 

Program to Convert Hexadecimal to Octal:-

Output:-

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

  • hex[20] = it will hold the Hexa value for the program.

Hexa to binary

Binary to octal.
Hexa to octal.

Main function.

C Program to Convert Inches to Centimeters

C Program to Convert Inches to Centimeters

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

Program to Convert Inches to Centimeters

As we all know the c is a very powerful language. With the help of c programming language, we can make many programs. We cal perform many input-output operations using c programming. In today’s tutorial, we take the input in inches from the user and convert it into centimeters. With the help of c programming, we can perform many conversion operations.

With the help of this program, we can Convert Inches into Centimeters.

Algorithm:-

 

Program to Convert Inches to Centimeters:-

 

Output:-

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

  • inch = it will hold the float value for the program as an input from the user. 
  • cm = it will hold the float value that will hold the grams converted in the program.

Taking the input from the user in the form of inch.

Scanning the input.
Converting the inch into centimeters.

Printing the converted output from kilograms to grams.

C Program to Convert Kilogram to Gram

C Program to Convert Kilogram to Gram

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

Program to Convert Kilogram to Gram

As we all know the c is a very powerful language. With the help of c programming language, we can make many programs. We cal perform many input-output operations using c programming. In today’s tutorial, we take the input in kilograms from the user and convert it into grams. With the help of c programming, we can perform many conversion operations.

With the help of this program, we can Convert Kilogram to Gram.

Algorithm:-

 

Program to Convert Kilogram to Gram:-

 

Output:-

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

  • kg = it will hold the float value for the program as an input from the user. 
  • g = it will hold the float value that will hold the grams converted in the program.

Taking the input from the user in the form of kilograms.

Converting the kilograms to grams.

 

Printing the converted output from kilograms to grams.

C Program to Pass Array to Function

C Program to Pass Array to Function

In this tutorial, we will learn to create a C program that will Pass Array to Function 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.
  • String functions of c programming.

Program to Pass Array to Function

As we all know the array is a collection of similar data types. In an array, only one variable is declared which can store multiple values. First, we will declare the input array for the program.

Then we will pass that array to a function for the calculation.

Then we will add the elements of using the for a loop.

With the help of this program, we can Pass Array to Function.

Algorithm:-

 

Program to Pass Array to Function:-

 

Output:-

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

  • no[] = it will hold the float value array.
  • result = it will hold the float value.
  • sum = it will hold the float value.
  • i = it will hold the integer value for the loop control. 

User-defined function declaration for the addition of array.

Body of the user-defined function.

 

Printing the output.

C Program to print Address of Variable

C Program to print Address of Variable

In this tutorial, we will learn to create a C program that will Print the Address of the variable 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.

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, string functions. But today we will print the address of the variable taken input from the given number using the c programming language.

With the help of this program, we can Print the Address of the variable.

Algorithm:-


 

Program to Print the Address of variable:-

 

 

Output:-

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

  • no1 = it will hold the integer value of number input.
  • no2 = it will hold the integer value of number input.
  • no3 = it will hold the integer value of number input.
  • sum = it will hold the integer value of number input.

Display message to Take input number from the user and scan the input number.

Program code to print the data and address of the given number.

 

C Program to Sort a String

C Program to Sort a String

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

Sort a String

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 give the input string to the program. Then will Sort a String by finding its length and sending it to a for loop with conditional statements in nested for loop.

With the help of this program, we can Sort a String.

Algorithm:-

 

Program to Sort a String:-

 

Output:-

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

  • string[] = it will hold the string value.
  • temp = it will hold the string value.
  • i = it will hold the string value.
  • j = it will hold the string value.

Finding the length of the string.

Printing before sorting.

Printing the output.

C Program to Print Array Elements at Even Position

C Program to Print Array Elements at Even Position

In this tutorial, we will learn to create a C program that will Print Array Elements at Even Positions 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.
  • Arithmetic Operators 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, we will Print Array Elements at Even Positions C Programming Language.

With the help of this program, we can Print Array Elements at Even Positions.

Algorithm:-

 

Program to Print Array Elements at Even Positions:-

 

Output:-

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

  • arry[10] = it will hold the string value.
  • i = it will hold the integer value for controlling the loop.

Getting the elements in the array for printing the Even index values.

For Loop for input.

Calculating the array elements of the Even index values.

Printing the output for the Even Index values.

C Program to Print Prime Numbers

C Program to Print Prime Numbers

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

Program to Print Prime Numbers

In c programming, it is possible to take numerical input from the user and check if that number is Prime Number or not with the help of a very small amount of code. The prime number means a number that is only divisible by itself. The C language has many types of header libraries that have supported functions in them with the help of these files the programming is easy.

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

Algorithm:-

Program to Print Prime Numbers:-

 

Output:-

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

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

Input message for the user for the integer value.

Program Logic Code.

Printing output prime number or not.