943,948 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 693
  • C++ RSS
Sep 5th, 2007
0

Compliler errors

Expand Post »
[6 #include <stdio.h>
7 int main ()
8 /* Declare and initialize variables. */
9 int number1 = 4, number2 = 7, sum;
10 /* Calculate sum. */
11 sum = numberl + number2;
12 /* Print the sum. */
13 printf("The sum is */.d \n", sum);
14 /* Exit program. */
15 system ("pause");
16 return 0;]

We HAVE to work within Bloodshed 4.9.9.2.

Please help me.

Errors per compiler:
In function 'main'
line 9 parameter 'number1' is initilaized
line 9 parameter 'number2' is initialized
line 11 syntax error b4 sum
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
SammyHasibi is offline Offline
6 posts
since Oct 2006
Sep 5th, 2007
1

Re: Compliler errors

Well loads of problems. Lets discuss each pf the:

1. Learn to indent your code and do not insert linenumbers before each line. We dont need that, [ code ] tags does it for you. See this.

2. Now the problems with code. First one is that you havn't inserted '{' at beginning and '}' at end of main() function.

3. In sum = numberl + number2;line you have typed numberl instead of number1.

4. You have use printf() function improperly. It must be
printf("The sum is %d \n", sum);. Read This.

5. Dont use system("pause"). Although it has nothing to do with errors but try using getchar() instead. Read This.
Last edited by vishesh; Sep 5th, 2007 at 3:41 am.
Reputation Points: 85
Solved Threads: 42
Nearly a Posting Virtuoso
vishesh is offline Offline
1,362 posts
since Oct 2006
Sep 5th, 2007
0

Re: Compliler errors

Team Colleague
Reputation Points: 5862
Solved Threads: 950
Posting Sage
Salem is offline Offline
7,164 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Newbie question(open a file)
Next Thread in C++ Forum Timeline: Function to convert a binary to decimal





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC