- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Environmental Science
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Check Whether Number is Perfect Or Not using C
C Program to Check Whether Number is Perfect Or Not
#include <stdio.h>
int main() {
int num, i = 1, sum = 0;
printf("Enter a number: ");
scanf("%d", &num);
while (i < num) {
if (num % i == 0) {
sum = sum + i;
}
i++;
}
if (sum == num)
printf("%d is a Perfect Number", i);
else
printf("%d is Non Perfect Number", i);
return 0;
}
- Related Questions & Answers
- Write C Program to Find Largest Element in Array in C Programming
- Write C Program to Find Smallest Element in Array in C Programming
- How to reverse a given number using C
- How to find sum of two numbers using C Language
- How to calculate gross salary of a person using C Program
- How to reads customer number and power consumed and prints amount to be paid using C
- Write C Program to Delete duplicate elements from an array
- Write a ‘C’ Program to compute the sum of all elements stored in an array using pointers
- How to print hello world using C Language
- How to Calculate Area of Equilatral Triangle using C Language
- Write a C program using pointers to read in an array of integers and print its elements in reverse order.
- How to Calculate Area of Rectangle using C Program
- How to find area and circumference of circle using C Programming
- How to Implement Stack Operations Using Array using C
- Write C Program to Merge Two arrays in C Programming
- How to read the values of x, y and z and print the results expressions in one line using C Program
Advertisements
ads