0

Hi, in my output 4620160 is added extra. When nhr excuete. Why it is added in output. What is the error in the code.

https://code.sololearn.com/cg3e25ps41FI/?ref=app

11th Mar 2018, 10:17 AM
Arumugam
Arumugam - avatar
4 Respuestas
+ 3
You should just change the return type of all your self-defined functions to void and call them. #include <iostream> using namespace std; void nh(int n1){ for(int i=0; i<n1;i++) cout<<i; } void nhr(int n2){ for(int j=n2; j>=0; j--) cout<<j; } void nv(int n3){ for(int k=0;k<n3; k++) cout<<k<<endl; } void nvr(int n4){ for(int l=n4; l>=0; l--) cout<<l<<endl; } void grid(int n5){ for(int m=0; m<n5; m++) {cout<<m; for(int o=m+1; o<n5+m; o++) {cout<<o;} cout<<endl;} } int main(){ int n; cin>>n; nh(n); nhr(n); grid(n); nv(n); nvr(n); return 0; }
11th Mar 2018, 11:49 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
If your function has return type int, your function should return some integer value, e.g. int add2(int value) { return (value + 2); }
11th Mar 2018, 12:30 PM
Hatsy Rei
Hatsy Rei - avatar
0
thanks. but my return type is int only. so why I can't use int type correct
11th Mar 2018, 12:14 PM
Arumugam
Arumugam - avatar
0
ok. got it thanks
11th Mar 2018, 12:34 PM
Arumugam
Arumugam - avatar