0

what is wrong in this code playground is showing it wrong

#include <iostream.h> #include <conio.h> void main() { clrscr(); for(int i=1;i<=5;i++) cout <<"\n"; for(int j=1;j<=i;j++) cout<<"*"; }

27th Sep 2016, 3:33 PM
Prakash Chandra Joshi
Prakash Chandra Joshi - avatar
3 Answers
+ 3
- Use <iostream> instead of <iostream.h> - no need for conio.h/clrscr() - Put "using namespace std" to not have to put std:: in front of std elements (like std::cout) - main() must return an int - put brackets { } to nest the second for loop inside the first one. #include <iostream> using namespace std; int main() { for(int i=1;i<=5;i++) { for(int j=1;j<=i;j++) cout<<"*"; cout <<"\n"; } return 0; }
27th Sep 2016, 4:20 PM
Zen
Zen - avatar
+ 1
Use #include<iostream> in the first line .This is because using .h in including files is an old method that's outdated in most ide and terminals nowadays .
27th Sep 2016, 3:51 PM
Nantha kumar .R
Nantha kumar .R - avatar
+ 1
The Program is right most of the ide dont support #include<iostream.h> only in Turbo C the #include<iostream.h> is accepted .... ide like code block , and dev c++ support only this format of header file syntax #include<iostream> . No .h should be included
27th Sep 2016, 4:01 PM
coolboy