Ask your own question, for FREE!
Computer Science 9 Online
Ballery1:

can someone tell me exactly what am i doing wrong in this program?

Ballery1:

@imqwerty

1 attachment
mhchen:

The error log says in line 7, that there should be a filename after ``` #include ```

Ballery1:

wait, how do i post my code on here?? i forgot

Ballery1:

i tried *<iostream> * but it didn't work

Ballery1:

```/************************************************* * Program to determine sum of two integer numbers* **************************************************/ //Header files #include #include using namespace std; int main() { //declare and initialize two integer numbers int first=50; int second=100; //declare integer type variable int total; //display both integer on screen cout<<"The first integer number:" <<first; cout<<"The second intefer number:" <<second; //determine sum of two intefer number total=first + second; //display sum on the screen "<<total<<endl; system ("pause"); return 0; }

mhchen:

Try getting rid of both ``` #include ``` And btw you write code like this: \``` #include \```

Ballery1:

``` /************************************************* * Program to determine sum of two integer numbers* **************************************************/ //Header files #include #include using namespace std; int main() { //declare and initialize two integer numbers int first=50; int second=100; //declare integer type variable int total; //display both integer on screen cout<<"The first integer number:" <<first; cout<<"The second intefer number:" <<second; //determine sum of two intefer number total=first + second; //display sum on the screen "<<total<<endl; system ("pause"); return 0; } ```

Ballery1:

Ahh thanks :)

Ballery1:

1 attachment
mhchen:

uh.... try this instead ```c #include <iostream> using namespace std; ```

Ballery1:

i did try to add <iostream> but it didn't work...let me do it again one sec plz

Ballery1:

1 attachment
mhchen:

put a space between them like ```c #include <iostream> ```

Ballery1:

oh ok

Ballery1:

1 attachment
Ballery1:

``` /************************************************* * Program to determine sum of two integer numbers* **************************************************/ //Header files #include <iostream> using namespace std; int main() { //declare and initialize two integer numbers int first=50; int second=100; //declare integer type variable int total; //display both integer on screen cout<<"The first integer number:" <<first; cout<<"The second intefer number:" <<second; //determine sum of two intefer number total=first + second; //display sum on the screen "<<total<<endl; system ("pause"); return 0; } ```

mhchen:

Do you have to use C? I went online and found this: https://stackoverflow.com/questions/30543286/fatal-error-iostream-no-such-file-or-directory-in-compiling-c-program-using-gc I'm not good with C or C++ so I'm not sure how they work

Ballery1:

yeah i'm studying programming in cpp so yeah i'm stuck with code blocks for now

Ballery1:

this dude: "30 Neither <iostream> nor <iostream.h> are standard C header files. Your code is meant to be C++, where <iostream> is a valid header. Use g++ (and a .cpp file extension) for C++ code. Alternatively, this program uses mostly constructs that are available in C anyway. It's easy enough to convert the entire program to compile using a C compiler. Simply remove #include <iostream> and using namespace std;, and replace cout << endl; with putchar('\n');... I advise compiling using C99 (eg. gcc -std=c99)"

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!