TO FIND SUM OF DIGITS , USING C
- Get link
- X
- Other Apps
TO FIND SUM OF DIGITS , USING C
#include<stdio.h>
int main()
{
int a,b,c,sum;
printf("ENTER THE DIGIT TO FIND THE SUM");
scanf("%d",&a);
b=a;
while(b!=0)
{
c=b%10;
sum=sum+c;
b=b/10;
}
printf("Sum of the digits=%d",sum);
return(0);
}
return(0);
}
- Get link
- X
- Other Apps
Popular posts from this blog
FIND NUMBER OF VOWELS IN A STRING
FIND NUMBER OF VOWELS IN A STRING c=raw_input("Enter A String:") b=c.lower() x=0 for letter in b: if letter in "aeiou": x+=1 print "Total Number Of Vowels = " + str(x) print "Number Of Vowels In Each" d,e,f,g,h=0,0,0,0,0 for letter in b: if letter in "a": d+=1 print "a=" +str(d) for letter in b: if letter in "e": e+=1 print "e=" +str(e) for letter in b: if letter in "i": f+=1 print "i=" +str(f) for letter in b: if letter in "o": g+=1 print "o=" +str(g) for letter in b: if letter in "u": h+=1 print "u=" +str(h) OUTPUT
TO FIND EVEN NUMBERS UP TO N
ENTERED NUMBER IS PRIME OR NOT
ENTERED NUMBER IS PRIME OR NOT n=int(input("enter a number:")) if n<0: print "enter a valid input" elif n<2: print "neither prime nor composite" else: for i in range(2,n/2): if(n%i)==0: print n,"is not a prime number" break else: print n,"is a prime number" OUTPUT --------------------------------------------------------------------------------------------------------------------------
Comments
Post a Comment