Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: new.programmer on May 20, 2014, 08:20:24 PM

Title: cout was not declared in this scope error
Post by: new.programmer on May 20, 2014, 08:20:24 PM
#include<iostream>
int main()
{
   cout << "a= ";
   double a;
   cin >> a;

   cout "b= ";
   double b;
   cin >> b;

   double p;
   p=2*(a+b);

   double s;
   s=a*b;

   cout << "p= " << p << "\n";
   
   cout << "s= " << s << "\n";
   return 0;
}

I get the following error: line 5 'cout' was not declared in this scope, how to fix it?
Title: Re: cout was not declared in this scope error
Post by: stahta01 on May 20, 2014, 08:57:03 PM
Read this FAQ http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
I suggest reading the others and finding a C++ book or support website.

Edit: C++ Website http://cboard.cprogramming.com/cplusplus-programming/ (http://cboard.cprogramming.com/cplusplus-programming/)

Tim S.
Title: Re: cout was not declared in this scope error
Post by: Jenna on May 20, 2014, 10:47:14 PM
Topic locked, because it violates our forum rules!