write a program to accept a number and check whether it is even number, prime number or Armstrong number on the user's choice and call different methods to check the above-mentioned
Answers
Answered by
1
Answer:
an Armstrong number or not
Example: Check Prime and Armstrong
#include <math.h>
#include <stdio.h>
int checkPrimeNumber(int n);
int checkArmstrongNumber(int n);
int main() {
int n, flag;
printf("Enter a positive integer: ");
scanf("%d", &n);
// check prime number
flag = checkPrimeNumber(n);
if (flag == 1)
printf("%d is a prime number.\n", n);
else
printf("%d is not a prime number.\n", n);
// check Armstrong number
flag = checkArmstrongNumber(n);
if (flag == 1)
printf("%d is an Armstrong number.", n);
else
printf("%d is not an Armstrong number.", n);
return 0;
Similar questions