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

The Output of the Program to Display All Perfect Numbers in the Given Range in C
The Output of the Program to Display All Perfect Numbers in the Given Range in C

Further Reading

50+ C Programming Interview Questions and Answers

C Program to Find Factorial of a Number