I am beginner in C++ language programming and using Microsoft Visual 2010.
The simple code I wrote myself as follow:
I got error message as below. Can anyone help me?
1>------ Build started: Project: Hello world, Configuration: Debug Win32 ------
1> Hello world.cpp
1>Hello world.cpp(26): error C2065: 'cout' : undeclared identifier
1>Hello world.cpp(26): error C2065: 'endl' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The simple code I wrote myself as follow:
Code:
// Hello world.cpp : main project file.
#include "stdafx.h"
#include "iostream"
using namespace System;
int main(array<System::String ^> ^args)
{
//define variables
float num1;
float num2;
float total;
//enter data for variables
std::cout << "Enter a value for a first variable: ";
std::cin >> num1;
std::cout << "Enter a value for a second variable: ";
std::cin >> num2;
//add two numbers together
total= num1 + num2;
//display the results
cout << "The sum of the variables =" <<total << endl;
}
I got error message as below. Can anyone help me?
1>------ Build started: Project: Hello world, Configuration: Debug Win32 ------
1> Hello world.cpp
1>Hello world.cpp(26): error C2065: 'cout' : undeclared identifier
1>Hello world.cpp(26): error C2065: 'endl' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Comment