A Sneak Peak Into My Crazy Life as I Try to Get Through Nursing School,
and the Technology, Books, Movies, Music & Lyrics I Enjoy
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!
RSS feed for comments on this post. TrackBack URI
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>
[powered by WordPress.]
![]()
Alliance of Free Blogs - I found You Know You Wanna while searching for kitty porn. No, that's not a typo.A work in progress.
21 queries. 2.366 seconds
#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
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
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
I think.
Comment by 787style — December 8, 2005 @ 3:28 pm
I keep getting one of those “This program has encountered an error and must close…”
Comment by jaxia — December 8, 2005 @ 3:40 pm
Programming is a pain!
(I do appreciate your help!)
Any more ideas?
Comment by jaxia — December 8, 2005 @ 3:41 pm
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
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
where the hell have you been darling?
you all but vanished!
Comment by frogboy3 — December 8, 2005 @ 3:50 pm
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?
)
Comment by jaxia — December 8, 2005 @ 3:52 pm
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
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
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
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
AHHHH! Flashbacks!!
NOOOOOOOOOOOOOOOOOOOOOOOOO!
Comment by maskedfencer — December 8, 2005 @ 4:15 pm
/*
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