+ 1

make This smaller?

https://code.sololearn.com/c1h37yDst4Ft/?ref=app I only know a few about c++, anyone knows to make this code shorter?

26th Sep 2023, 7:09 AM
Navaneeth
Navaneeth - avatar
4 Réponses
+ 5
Navaneeth, For make the code shorter, just use a `for loop` instead of a `while loop`. See this code& learn.. https://code.sololearn.com/cTm4vMheox4i/?ref=app And for your second question: Learn c++ course with carefully.. https://www.sololearn.com/learn/courses/c-plus-plus-intermediate https://www.sololearn.com/learn/courses/c-plus-plus-intermediate
26th Sep 2023, 9:58 AM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 1
#include<iostream> using namespace std; int main() { int x, l; cout<<"enter no.of lines: "; cin>>l; cout<<"\n\n"; for(x=1;l;x+=2,l--) cout<<string(l,' ')+string(x,'*')<<endl; }
26th Sep 2023, 1:47 PM
Brian
Brian - avatar
0
.. and why cout<<"*" *3 ; doesn't print *** like python?
26th Sep 2023, 7:14 AM
Navaneeth
Navaneeth - avatar
0
thanks
26th Sep 2023, 10:52 AM
Navaneeth
Navaneeth - avatar