0
how do you endl function it c++
how do you use <<endl; function on integer,float and string variables?Because i tried using it and it just gave me an error.My code looks like this: include<iostream> using namespace std; int main{ int mgeffe; mgeffe = (97); float ngft; ngft = (46.776); string io; io = ("you"); cout<<mgeffe <<endl; cout<<ngft <<endl; cout<<io; }
2 odpowiedzi
+ 1
The problem is not in endl.
add the '#' in include.
# include <iostream>
add the '()' in main.
int main(){
...
}
also, you don't have to put your values in (). You can also declare variables and assign value to them in the same line.
int mgfe = 97;
float ngft = 46.776;
string io = "you";
0
you're missing parentheses in the main function declaration.
#include<iostream>
using namespace std;
int main() {
int mgeffe;
mgeffe = 97;
float ngft;
ngft = 46.776;
string io;
io = "hi";
cout << mgeffe << endl;
cout << ngft << endl;
cout << io;
return 0;
}