Click here to Skip to main content
15,892,517 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include<iostream>
using namespace std; 
int main()
{
	int x = 0 ;
	int y = 0 ;
	int average = 0 ;
	int sum = 0 ; 
	float=0.0;
	cout << " please enter the first number: " << endl;
	cin >> x;
	cout << " please enter the second number: " << endl;
	cin >> y; 
	sum = x + y;
	cout << "the sum of number " << x << " and " << y << " is " << sum<<endl ;
="" average="sum" 2;="" 
="" cout="" <<="" "="" the="" of="" both="" numbers="" is:="" endl;="" 

="" return="" 0;="" 
}


What I have tried:

I tried to run it without the float statement and it worked so the problem is in the float statement I want to know why
Posted
Updated 16-Mar-22 7:25am
v2
Comments
jeron1 16-Mar-22 13:11pm    
"float=0.0;" is not a valid statement (no variable name), probably will not compile.

add a variable name, something like,

"float abc = 0.0;"

1 solution

Quote:
I tried to run it without the float statement and it worked so the problem is in the float statement I want to know why

Because the float line is not C.
C++
int average = 0 ;
float=0.0;

Because just like for any other variables, when you declare it, it is datatype, then variable name.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900