Wednesday, April 20, 2022

Armstrong c

 #include <stdio.h>

int main() {

    int num, originalNum, remainder, result = 0;

    printf("Enter a three-digit integer: ");

    scanf("%d", &num);

    originalNum = num;

 

    while (originalNum != 0) {

       // remainder contains the last digit

        remainder = originalNum % 10;

       

       result += remainder * remainder * remainder;

       

       // removing last digit from the orignal number

       originalNum /= 10;

    }

 

    if (result == num)

        printf("%d is an Armstrong number.", num);

    else

        printf("%d is not an Armstrong number.", num);

 

    return 0;

}

No comments:

Post a Comment

How to install and configure Oracle Apex 24.1 with ORDS 22, Tomcat 9 and Jasper Report 7 on Oracle Linux 8.10

#########################Install Oracle  APEX 24.1################################ ----------------------------------------------------...