May 13, 2008

What Is The Purpose Of The Percentage Symbol In C?

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > C/C++ Programming

free web hosting

What Is The Purpose Of The Percentage Symbol In C?

htdefiant
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

Reply

bhavesh
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.

Reply

htdefiant
So, if num2 was 24, it would give me 5 with a remainder of 0?

Reply

truefusion
QUOTE(htdefiant @ Dec 15 2007, 10:28 AM) *
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.

Reply

htdefiant
Ah, ok. Thank you very much for your help.

Reply

bhavesh
I think you are not getting it. Try this program in C

CODE
main()
{
int num1,num2;
printf("Enter num1 : ");
scanf("%d",&num1);
printf("Enter num2 : ");
scanf("%d",&num2);
printf("num1%num2   is  %d", num1%num2);
}



Reply

htdefiant
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

Reply

rvalkass
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.

Reply

htdefiant
Alright, thank you.

Reply

Csshih
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.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : purpose, percentage, symbol, c,

  1. Addicted To Blogging?
    Know your blog addiction percentage here. (0)
  2. Easter Eggs Is Symbol For Jesus' Resurrection As Well As Fish Image.
    Why Eggs in Easter (9)
    1. Christian use the egg as Symbol of Jesus Resurrection, Some dead was resin by Jesus but Jesus
    was risen by itself as the chicken brooks the egg to get out by itself. 2. Also Christian are using
    fish as symbol for Resurrection because of the story of Jonah in the Whale. As Jonah was inside the
    whale 3 days , Jesus was in the tomb 3 days. Even Jesus said about that : QUOTE Matthew 12:39 -
    But he answered them, "An evil and adulterous generation seeks for a sign; but no sign shall be
    given to it except the sign of the prophet Jonah Matthew 12:40 - For as Jonah w....
  3. Username Warning Percentage Question
    (2)
    i have a warning percentage of 10...how do you get these warnings? how can i find out how i have
    earned a warning? how do get rid of my warnings? what happens when your warning has reached the
    highest??....
  4. My Purpose On This Forum
    Spread my ideas about... (10)
    I'm your typical teenage computer nerd (OK, maybe not sooooo typical /tongue.gif"
    style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> ). I run a web site, I post
    here, I read tech news. So here's what I am trying to accomplich on Trap17: -Spread my belief
    in hybrid buses (especially the Orion VII hybrid, which we use here in NYC) -Get my wonderful free
    hosting -Make a few friends (which I desperately need) -Get away from the rest of my life (ex.
    school, family, etc.) -Occupy unused time -Find free stuff -Learn more in general about computer....
  5. The Trap17 All-purpose Help Desk
    Just an Idea... (4)
    I love what Trap17 is doing here. I love being apat of communities like this, and here you got
    hosting for it! What more could you ask for! Well ive got an idea: The all purpose help
    desk. We have so many users here, all of us together probably have knoweledge about pretty much
    every thing. So why not open a "Help Desk"? At the "Help Desk" Users could submit a question about
    any thing (Probably via email) then us here could sort of "Claim" the message if we know the answer.
    All the question could be posted in a forum here, then once a user "Claims it" the topi....
  6. Symbol Burning
    photoshop (6)
    Oke this is my first tutorial, so be gentle /wink.gif' border='0' style='vertical-align:middle'
    alt='wink.gif' /> . The first part of my tutorial is based on an other tutorial:
    http://ele-st.org/forums/index.php?showtopic=865 This is the first part from that website.
    QUOTE Start out by making a new document, at least 300x300, and size bigger than that is ok as
    well. Fill your background with black, and get out your brush tool. Use a soft round 17 px brush.
    Now to start the brushing. We'll be making a tree like figure, with multiple branches. Start
    from th....
  7. The Best Tv Advert Ever?
    Serves no useful purpose at all! (4)
    Here's a little song for anyone who's ever hated - in the key of "Grrr".
    http://multimedia.honda-eu.com/diesel/Movie.swf Thats a great advert due to its annoying factor.
    Honda have a clever marketing team. Like the famous "Cog" advert... I don't study adverts in
    any great detail, but you have to admit there are some good ones! Any others you've found
    great? "Hate something, change something, make something better..."....
  8. Purpose Of Cgi-bin?
    (5)
    I'm not sure if i'm posting in the right (sub)forum but it certainly has something to do
    with it /cool.gif' border='0' style='vertical-align:middle' alt='cool.gif' /> . Now, i wonder
    what's the meaning of "cgi-bin". When connecting to ftp you find a folder with this name. Can
    anyone tell me what its function is? I also found this folders /blink.gif' border='0'
    style='vertical-align:middle' alt='blink.gif' /> : - _vti_bin - _vti_cnf - _vti_log - _vti_pvt
    - _vti_txt Thanks in advance! /biggrin.gif' border='0' style='vertical-align:middle' a....

    1. Looking for purpose, percentage, symbol, c,

Searching Video's for purpose, percentage, symbol, c,
advertisement



What Is The Purpose Of The Percentage Symbol In C?



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE