![]() |
| | #1 |
| Registered User Join Date: Jun 2008 Location: Germany
Posts: 2
| Basic problem - need help I am really new to programming and trying to teach myself c and it's not easy! Could someone please tell me why this won't work. it's not finished yet still need to add the sqrt statement. I get stuck at the average calculations. thanks in advance... jasemca ![]() Code: #include <stdio.h>
#include <math.h>
int main()
{
// Create two new integers to gather values
int a = 0;
int b = 0;
int a+b =c;
// Get me a number from the user (a)
printf("Enter a positive whole number.\n");
scanf("%d", &a);
printf ("You entered %d.\n", a);
// Get another number (b)
printf("Enter a positive whole number.\n");
scanf("%d", &b);
printf ("You entered %d.\n", b);
// Print the average
scanf("%f",c = (a+b)/2);
printf ("Average is: %f.\n", c);
// Print another math function
return 0;
}
|
| jasemca is offline | |
| | #2 |
| Deathray Engineer Join Date: Mar 2007
Posts: 3,211
| Yeah, that's wrong. I could point out all the errors, but I think you would do best to go over your tutorials/books again.
__________________ |
| MacGyver is offline | |
| | #3 | |
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,099
| If you study your book(s)/tutorial(s) carefully, I'm sure you'll find the errors. You are thinking too much math and too little computer/C.
__________________ Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System I dedicated my life to helping others. This is only a small sample of what they said: "Thanks Elysia. You're a programming master! How the hell do you know every thing?" Quoted... at least once. Quote:
| |
| Elysia is offline | |
| | #4 |
| Registered User Join Date: Jun 2008 Location: Germany
Posts: 2
| thanks Ok guys, thanks....I think! :-) |
| jasemca is offline | |
| | #5 | |
| Registered User Join Date: Sep 2006
Posts: 2,506
| Quote:
| |
| Adak is online now | |
![]() |
| Tags |
| basic, beginner, c-code, problem |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [ANN] New script engine (Basic sintax) | MKTMK | C++ Programming | 1 | 11-01-2005 10:28 AM |
| what are your thoughts on visual basic? | orion- | General Discussions | 16 | 09-22-2005 04:28 AM |
| Problem with basic encryption program. | mmongoose | C++ Programming | 5 | 08-27-2005 04:41 AM |
| Bin packing problem.... | 81N4RY_DR460N | C++ Programming | 0 | 08-01-2005 05:20 AM |
| Words and lines count problem | emo | C Programming | 1 | 07-12-2005 03:36 PM |