YKYW - Nursing Student Blog

A Sneak Peak Into My Crazy Life as I Try to Get Through Nursing School,
and the Technology, Books, Movies, Music & Lyrics I Enjoy

C Programmer?

by @ 7:55 pm on December 8, 2005. Filed under Technology

Are there any C programmers around? I have an assignment due and I cannot figure out how to make this friggin function work:

Write a small program that uses the standard functions printf() and scanf() to:

Input two integers
Compute the sum of those numbers
Output the result, listing both the input values and the sum.


I’m so confused. Help!

16 Responses to “C Programmer?”

Comments

  1. #include
    #include
    main()
    {

    int X, Y, PRODUCT;

    printf(”Enter First Number: “); scanf(”%d”, X);
    printf(”Enter Second Number: “); scanf(”%d”, Y);

    PRODUCT = X*Y

    printf(”Sum of %d AND %d = %d”, X ,Y , PRODUCT);
    }

    Comment by 787style — December 8, 2005 @ 3:13 pm

  2. Woo!
    But we haven’t technically learned the math.h thing yet. Can you do it without it?

    Comment by jaxia — December 8, 2005 @ 3:25 pm

  3. Er, yeah. I forget a ; at the end. That’s ansi C, for visual studio its’

    #include “stdafx.h”

    int main(int X, int Y, int PRODUCT)
    {

    printf(”Enter First Number: “); scanf(”%d”, X);
    printf(”Enter Second Number: “); scanf(”%d”, Y);

    PRODUCT = X*Y;

    printf(”Sum of %d AND %d = %d”, X ,Y , PRODUCT);

    return 0;
    }

    Comment by 787style — December 8, 2005 @ 3:28 pm

  4. I think.

    Comment by 787style — December 8, 2005 @ 3:28 pm

  5. I keep getting one of those “This program has encountered an error and must close…”

    Comment by jaxia — December 8, 2005 @ 3:40 pm

  6. Programming is a pain!

    (I do appreciate your help!)

    Any more ideas?

    Comment by jaxia — December 8, 2005 @ 3:41 pm

  7. Forgot a &

    printf(”Enter First Number: “); scanf(”%d”, &X);
    printf(”Enter Second Number: “); scanf(”%d”, &Y);

    Comment by 787style — December 8, 2005 @ 3:45 pm

  8. Yeah, put that is VS and it worked fine for me.

    Does seeing it in action make sense?

    Comment by 787style — December 8, 2005 @ 3:49 pm

  9. where the hell have you been darling?

    you all but vanished! :(

    Comment by frogboy3 — December 8, 2005 @ 3:50 pm

  10. You are awesome! I just need to change the multiply to addition, and I should be good to go!

    Thank you oh so much!

    (Do you have an IM name in case I need more help? :D )

    Comment by jaxia — December 8, 2005 @ 3:52 pm

  11. IM: AdamSeyer

    God I need to pay attention.

    #include “stdafx.h”

    int main(int X, int Y, int SUM)
    {

    printf(”Enter First Number: “); scanf(”%d”, &X);
    printf(”Enter Second Number: “); scanf(”%d”, &Y);

    SUM = X+Y;

    printf(”Sum of %d and %d = %d”, X ,Y , sum);

    return 0;
    }

    Comment by 787style — December 8, 2005 @ 3:54 pm

  12. I write on my website :) http://www.youknowyouwanna.net
    I still read my friends page every day or so…

    I only posted here because I needed a FAST reply :)

    Comment by jaxia — December 8, 2005 @ 3:55 pm

  13. Yahoo? I tried to add you to my Yahoo IM.
    I have AIM and MSN too though.

    Thanks again!

    Comment by jaxia — December 8, 2005 @ 4:01 pm

  14. No Yahoo, only AIM. April tries to force my hand toward Yahoo, not a fan.

    Speaking of, I guess I should go pick up April’s dog.

    Comment by 787style — December 8, 2005 @ 4:04 pm

  15. AHHHH! Flashbacks!!

    NOOOOOOOOOOOOOOOOOOOOOOOOO!

    Comment by maskedfencer — December 8, 2005 @ 4:15 pm

  16. /*
    main function arguments should be as below.

    the use of arguments on a function to be modified will
    cause bad things in the long run, and should be avoided.

    Make this a console function, or the main will be
    decleared elsewhere in the windows libraries and not be
    available to you
    */

    #include “stdafx.h”

    int main(int argc, char *argv)
    {

    int X, Y, PRODUCT;

    printf(”Enter First Number: “); scanf(”%d”, X);
    printf(”Enter Second Number: “); scanf(”%d”, Y);

    PRODUCT = X*Y;

    printf(”Sum of %d AND %d = %d”, X ,Y , PRODUCT);

    return 0;
    }

    Comment by anonymous — December 18, 2005 @ 4:19 pm

RSS feed for comments on this post. TrackBack URI

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)


Subscribe without commenting

[powered by WordPress.]

YKYW Menu

Interesting Links


Categories

Search YKYW

Archives

Other

A work in progress.

Subscribe to YKYW


Other Stuff

Blogroll

22 queries. 0.825 seconds