Thursday, May 3, 2012

Program to check that entered no is divisible by 3 or not.


//program to check that entered no is divisible by 3 or not.
#include<stdio.h>
#include<conio.h>
main()
{ int n,r,s;
 printf("Enter the no ");
 scanf("%d",&n);
 s=0;
 while(r!=0)
 { r=n%10;
  n=n/10;
  s=s+r;
 }
 if(s%3==0)
 printf("Entered no is divisible by 3");
 else
 printf("Not divisible by 3");
getch();
}

No comments:

Post a Comment