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; }

8th Apr 2024, 9:58 PM
Zian Pinon
Zian Pinon - avatar
2 Answers
+ 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";
8th Apr 2024, 10:15 PM
Bob_Li
Bob_Li - avatar
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; }
10th Apr 2024, 2:45 PM
Vidhya Tharan
Vidhya Tharan - avatar