Hey, i was trying to make a multiplication word problem type thing and when hit debug it always says what my title is. Here's my code.

#include <iostream>
void main();
{
	// Declare Variables!!!
	char name[15];
	short quantity;
	float amount;
	float totalSale;

	cout << "Enter Customer's Name: ";
	cin.getline(name,15);
	cout << "Enter the cost: ";
	cin >> amount;
	cout << "Enter the quantity: ";
	cin >> quantity;

	totalSale = amount * (float)quantity;

	cout << "The Total is: " << totalSale << endl;
}

If you could help, that would be awesome, seeya

Recommended Answers

All 4 Replies

>>void main();

Remove the semicolon

Whenever i do that though, i get nine errors that say
error C2065: 'cout' : undeclared identifier
error C2065: 'cin' : undeclared identifier

and things like that, what shall i do?

There are several ways to fix it.

#include <iostream>
using namespace std;

or

#include <iostream>
using std::cout;
using std::cin;

or

std::cout << "Enter Customer's Name: ";
std::cin.getline(name,15);

Thank you very much! :)

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.