Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include<stdio.h>
  2. void main()
  3. {
  4.     int n,s=0,p=1;
  5.     printf ("Introdu un numar intreg: \n ");
  6.     scanf ("%d",&n);
  7.     if (n%2==0)
  8.     {
  9.         while (n!=0)
  10.         {
  11.             s=s+n%10;
  12.             n=n/10;
  13.         }
  14.         printf ("Suma cifrelor este %d \n ", s);
  15.     }
  16.     else
  17.     {
  18.         while (n!=0)
  19.         {
  20.             p=p*n%10;
  21.             n=n/10;
  22.         }
  23.         printf ("Produsul cifrelor este %d \n ", p);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement