+ 1
Why the code is giving me garbage vaue + error at the last !!!
#include<iostream> using namespace std; int myname(int a,int b=2){ cout<<"Ashutosh is a Good Boy"<<endl; cout<<a<<endl; cout<<b<<endl; } int main(){ int a; cin>>a; int c=myname(a); cout<<c<<endl; return 0; }
2 Réponses
+ 4
You're not returning a value, that's why it's resulting in a garbage value. I don't know what that random number is, but returning something will fix it. Below's your code fixed
https://code.sololearn.com/cdC80P5Preq8/?ref=app
+ 3
The function myname says it returns an integer value, which you then try and print out. If you don't return a value then it will create an integer with a garbage value and that will be what's printed out