Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Help for a New programmer

Help for a New programmer

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    Hi. I am taking my first programming class and I am trying to write a sample void function. Would anyone be willing to show me what I am doing wrong? Here is what I have so far: #include using namespace std; void GetNumbers(int&, int&, int&); int main () { int a; int b; int c; int average; GetNumbers (a,b,c); average=(a+b+c)/3; cout << "The average of your numbers is"<< average << endl; } Void GetNumbers(int& firstnumber, int& secondnumber, int& thirdnumber) { cout<< "enter three numbers" <>firstnumber>>secondnumber>>thirdnumber; }

    A J C 3 Replies Last reply
    0
    • A Anonymous

      Hi. I am taking my first programming class and I am trying to write a sample void function. Would anyone be willing to show me what I am doing wrong? Here is what I have so far: #include using namespace std; void GetNumbers(int&, int&, int&); int main () { int a; int b; int c; int average; GetNumbers (a,b,c); average=(a+b+c)/3; cout << "The average of your numbers is"<< average << endl; } Void GetNumbers(int& firstnumber, int& secondnumber, int& thirdnumber) { cout<< "enter three numbers" <>firstnumber>>secondnumber>>thirdnumber; }

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      umm... you have a capital on Void in the definition of GetNumbers?

      A 1 Reply Last reply
      0
      • A Anonymous

        Hi. I am taking my first programming class and I am trying to write a sample void function. Would anyone be willing to show me what I am doing wrong? Here is what I have so far: #include using namespace std; void GetNumbers(int&, int&, int&); int main () { int a; int b; int c; int average; GetNumbers (a,b,c); average=(a+b+c)/3; cout << "The average of your numbers is"<< average << endl; } Void GetNumbers(int& firstnumber, int& secondnumber, int& thirdnumber) { cout<< "enter three numbers" <>firstnumber>>secondnumber>>thirdnumber; }

        J Offline
        J Offline
        J Eric Vaughan
        wrote on last edited by
        #3

        It would help to know what the output is, but (a+b+c)/3 is integer arithmetic and the decimal part of the answer will be truncated. Try using "float"s instead of "int"s The maximum characters for the signature is five hundred. I was wondering how long a five hundred characters message would be, so I decided to make my signature 500 characters long. I'm sure if I had some cool html stuff in my signature, I could eat up five hundred characters, but just typing five hundred characters takes quite some time. The trick I think is finding something to say, but I'm usually a man of few words. So I guess I'll tell you what I've discovered is the secret to life. It

        A 1 Reply Last reply
        0
        • A Anonymous

          Hi. I am taking my first programming class and I am trying to write a sample void function. Would anyone be willing to show me what I am doing wrong? Here is what I have so far: #include using namespace std; void GetNumbers(int&, int&, int&); int main () { int a; int b; int c; int average; GetNumbers (a,b,c); average=(a+b+c)/3; cout << "The average of your numbers is"<< average << endl; } Void GetNumbers(int& firstnumber, int& secondnumber, int& thirdnumber) { cout<< "enter three numbers" <>firstnumber>>secondnumber>>thirdnumber; }

          C Offline
          C Offline
          Cpudood
          wrote on last edited by
          #4

          maybe you should try acquiring each number one at a time within your void function. Also, what are you including?

          A 1 Reply Last reply
          0
          • A Anonymous

            umm... you have a capital on Void in the definition of GetNumbers?

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Thank you. Sorry for the dumb question. Like I said, I am very new to this.

            1 Reply Last reply
            0
            • J J Eric Vaughan

              It would help to know what the output is, but (a+b+c)/3 is integer arithmetic and the decimal part of the answer will be truncated. Try using "float"s instead of "int"s The maximum characters for the signature is five hundred. I was wondering how long a five hundred characters message would be, so I decided to make my signature 500 characters long. I'm sure if I had some cool html stuff in my signature, I could eat up five hundred characters, but just typing five hundred characters takes quite some time. The trick I think is finding something to say, but I'm usually a man of few words. So I guess I'll tell you what I've discovered is the secret to life. It

              A Offline
              A Offline
              Anonymous
              wrote on last edited by
              #6

              Thank you, I included float and it works much better.

              1 Reply Last reply
              0
              • C Cpudood

                maybe you should try acquiring each number one at a time within your void function. Also, what are you including?

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                I really appreciate the tip. I put using std because I don't know when not to use it , so I just put it in.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups