Hello I just started programming and managed to make some programs, but what I don't get is when I get these errors:

Compiler: Default compiler
Executing gcc.exe...
gcc.exe "D:\Documents and Settings\Riikard\Desktop\Untitled1.c" -o "D:\Documents and Settings\Riikard\Desktop\Untitled1.exe" -g3 -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib" -g3
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:1:20: iostream: No such file or directory
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:3: error: syntax error before "namespace"
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:3: warning: data definition has no type or storage class

D:\Documents and Settings\Riikard\Desktop\Untitled1.c: In function `main':
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:12: error: `cout' undeclared (first use in this function)
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:12: error: (Each undeclared identifier is reported only once
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:12: error: for each function it appears in.)
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:12: error: `endl' undeclared (first use in this function)
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:13: error: `cin' undeclared (first use in this function)
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:17: error: `davarge' undeclared (first use in this function)
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:21: error: `system' undeclared (first use in this function)
D:\Documents and Settings\Riikard\Desktop\Untitled1.c:21: error: syntax error before ';' token

Execution terminated

I include iostream and all these code in the program but I still get these errors, it has happen before aswell and I got no clue why, sometimes it works sometimes it dosent, anyone knows why?

I used to get this problem when i used code blocks aswell, thats why I uninstalled codeblocks and downloaded Dev-C++ version 4.9.9.2 but now I still get the same errors.

Here's the code btw:

#include <iostream>

using namespace std;

int main(void)
{
    double dnumber1 = 0.0;
    double dnumber2 = 0.0;
    double dnumber3 = 0.0;
    double davarage = 0.0;

    cout << "Please enter 3 numbers: " << endl;
    cin >> dnumber1;
    cin >> dnumber2;
    cin >> dnumber3;

    davarge = (dnumber1 + dnumber2 + dnumber3) / 3;

    cout << "The avarge of the numbers are: " << davarage << endl << endl;

    system |"pause"| ;
    return 0;

}

Thank you.

Recommended Answers

All 3 Replies

> gcc.exe "D:\Documents and Settings\Riikard\Desktop\Untitled1.c"

You are trying to compile a C++ code, yet tell the compiler that it is C. Rename your sources to .cpp

So basically the only thing i have to do is to change my codes to .cpp instead? and I won't get these errors?

>>So basically the only thing i have to do is to change my codes to .cpp instead? and I won't get these errors?
It's worth a shot. Try & echo back.

>>D:\Documents and Settings\Riikard\Desktop\Untitled1.c:1:20: iostream: No such file or directory
It can't find iostream. Please see your project settings.

>> system |"pause"|
It should be system("pause"). Advice: Use cin.get() instead.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.