PRIME NUMBER OR NOT
#include<stdio.h>
main()
{
int n, c = 2; printf("Enter a number to check if it is prime\n"); scanf("%d",&n); for ( c = 2 ; c <= n - 1 ; c++ ) { if ( n%c == 0 ) { printf("%d is not prime.\n", n); break; } } if ( c == n ) printf("%d is prime.\n", n); return 0;
}
ARMSTRONG OR NOT
#include <stdio.h> int main()
{
int number, sum = 0, temp, remainder; printf("Enter an integer\n"); scanf("%d",&number); temp = number; while( temp != 0 ) { remainder = temp%10; sum = sum + remainder*remainder*remainder; temp = temp/10; } if ( number == sum ) printf("Entered number is an armstrong number.\n"); else printf("Entered number is not an armstrong number.\n"); return 0;
}
OR
#include<stdio.h>
void main()
{
int num,num1,arms=0,rem; printf("Enter the number:\n"); scanf("%d",&num); num1=num; while(num>0) { rem=num%10; arms=arms+rem*rem*rem; num=num/10; } if(num1==arms) { printf("