The following code shows how to Display All Perfect Numbers in the Given Range in C.
// To Find all perfect numbers in the given range
#include <stdio.h>
int main()
{
int mynum, factorsum=0, i, j, low, high;
printf("Enter the lower value limit of the range: ");
scanf("%d", &low);
printf("Enter the higher limit of the range: ");
scanf("%d", &high);
for(i=low;i<=high;i++){
for(j=1;j<=i/2;j++)
{
if(i%j==0)
{
factorsum+=j;
}
}
if(factorsum==i)
{
printf("%d ", i);
}
factorsum=0;
}
return 0;
}
Output
Further Reading
50+ C Programming Interview Questions and Answers
C Program to Find Factorial of a Number
- AI
- Android
- Angular
- ASP.NET
- Augmented Reality
- AWS
- Bioinformatics
- Biometrics
- Blockchain
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Cyber Security
- Data Science
- Data Structures and Algorithms
- Data Visualization
- Datafication
- Deep Learning
- DevOps
- Digital Forensic
- Digital Trust
- Digital Twins
- Django
- Docker
- Dot Net Framework
- Drones
- Elasticsearch
- ES6
- Extended Reality
- Flutter and Dart
- Full Stack Development
- Git
- Go
- HTML
- Image Processing
- IoT
- IT
- Java
- JavaScript
- Kotlin
- Latex
- Machine Learning
- MEAN Stack
- MERN Stack
- Microservices
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Quantum Computing
- React
- Robotics
- Rust
- Scratch 3.0
- Shell Script
- Smart City
- Software
- Solidity
- SQL
- SQLite
- Tecgnology
- Tkinter
- TypeScript
- VB.NET
- Virtual Reality
- Web Designing
- WebAssembly
- XML