htdefiant 0 Report post Posted December 14, 2007 What does the % symbol do?For example, if num1 has the value of 120 and num2 has the value 2, what will num1%num2 generate?Thanks Share this post Link to post Share on other sites
bhavesh 0 Report post Posted December 15, 2007 It is called the mod operator and gives remainder.That is num1%num2 will divide num1 from num2 and will display the remainder.In your example it will return 0, as 120 is completely divisible by 2. Share this post Link to post Share on other sites
htdefiant 0 Report post Posted December 15, 2007 So, if num2 was 24, it would give me 5 with a remainder of 0? Share this post Link to post Share on other sites
truefusion 3 Report post Posted December 15, 2007 So, if num2 was 24, it would give me 5 with a remainder of 0?It wouldn't, or i should say, shouldn't give you the 5. It's purpose is to return the remainder—nothing else. You see this in PHP, too, since PHP is based on C, as well as other programming languages. Share this post Link to post Share on other sites
htdefiant 0 Report post Posted December 15, 2007 Ah, ok. Thank you very much for your help. Share this post Link to post Share on other sites
bhavesh 0 Report post Posted December 15, 2007 I think you are not getting it. Try this program in C main(){ int num1,num2; printf("Enter num1 : "); scanf("%d",&num1); printf("Enter num2 : "); scanf("%d",&num2); printf("num1%num2 is %d", num1%num2);} Share this post Link to post Share on other sites
htdefiant 0 Report post Posted December 15, 2007 That program crashes my DOS window for some reason. But I think I understand - if I put in 120 and 24, the output would be 0? Thanks for your patience Share this post Link to post Share on other sites
rvalkass 5 Report post Posted December 15, 2007 Yes, as 120 divided by 24 is exactly 5. If you used 50 and 7 then the output would be 1. If you used 99 and 4 then the output would be 3. Share this post Link to post Share on other sites
htdefiant 0 Report post Posted December 15, 2007 Alright, thank you. Share this post Link to post Share on other sites
Csshih 0 Report post Posted December 17, 2007 You can also try those numbers on google, but I'm not sure it will return the same results as it would in a program.Just enter what you want to calculate onto the search bar and press search.Google has its built in calculator. Share this post Link to post Share on other sites