C program to Check Number is a Prime, Armstrong, or Perfect Number

In this tutorial you will learn about the C program to Check Number is a Prime, Armstrong, or Perfect Number and its application with practical example.

C Program to Check Number is a Prime, Armstrong, or Perfect Number

In this tutorial, we will learn to create a C program that will check Number is a Prime, Armstrong, or Perfect 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.
  • While loop in C programming.

What is a prime number?

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

What is an Armstrong number?

Armstrong number is a number that is equal to the sum of cubes of its digits.

What is a Perfect number?

A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.

Algorithm:-

Program For checking the Number is a Prime, Armstrong, or Perfect Number:-

 

With the help of this program, we can check THE Number.

Program Code:-

Output:-

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

  • num = it will hold the integer value.
  • i = it will hold the integer value.

Taking the input integer number from the user.

Checking the number is a prime number, Armstrong number, or perfect number.
Printing the output for the program.

 

In this tutorial we have learn about the C program to Check Number is a Prime, Armstrong, or Perfect Number and its application with practical example. I hope you will like this tutorial.