Advertisement
Niloy007

Pranto's Problem 6

Mar 23rd, 2021
845
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5.     int sum = 0, n;
  6.     printf("Enter any integer:\n");
  7.     scanf("%d", &n);
  8.     int num = n;
  9.  
  10.     while (n > 0) {
  11.         sum += (n % 10);
  12.         n /= 10;
  13.     }
  14.    
  15.     printf("Sum of its digits = %d. ", sum);
  16.     for (int i = 2; i < sum; i++) {
  17.         if (sum % i == 0) {
  18.             printf("It is not a prime number.\n");
  19.             return 0;
  20.         }
  21.     }
  22.     printf("It is a prime number.\n");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement