How can i make a program that asks a number and says if it is divisible by 5. and when it is divisible it just keeps asking me and when the number is is not divisible anymore it will end the program?
Turbo C codes?
printf("enter a number ");
scanf("%d",%26amp;num);
check= num%5;
if(check==0)
printf("number divisible by 5");
else
printf("number is not divisible by 5");
Reply:To see if a number is evenly divisible by 5 use the modulo operator (%). n % 5 == 0 if n is evenly divisible by 5.
The rest is easy. If you were paying attention in class and keeping up with the reading you should be able to do it. If you have specific questions (i.e. questions other than "how do I write this program") be sure to ask and we'll be happy to help.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment