+ 1
when i run my code suppose with input 1 then from 0 to 10 output is correct but i get 11 th value as garbage value! why so??
#include <iostream> using namespace std; int mult(int a,int b,int c) { if(a>=0) { cin>>a; for(b=0;b<=10;b++) { c=a*b; cout<<c<<endl; } } } int main() { int a,b,c; cout <<mult(a,b,c); return 0; }
7 Réponses
+ 1
i tried that @rosen.. its not  working.. The same problem persists.. 
+ 1
thanks @ASNM.. when i wrote just mult(a, b, c)  in the main function instead of cout <<mult(a, b, c)  it worked.i am no longer getting a garbage value. But why is it so?? can anyone explain it? 
0
Your first if statement has to be after cin>>a;
0
mult
return c;
if you want no output 
int main()
{
   int a,b,c;
   mult(a,b,c);
   return 0;
}
0
I think it is because you are counting the 0 too. Try b=1 in the for loop.
0
#include <iostream>
using namespace std;
int mult(int a,int b,int c)
{
   if(a>=0)
   {
      cin>>a;
      for(b=0;b<=10;b++)
      {
         c=a*b;
         cout<<c<<endl;
      }
   }
   return c;
}
int main()
{
   int a,b,c;
  cout<< mult(a,b,c);
   return 0;
}
0
can you please give me your WhatsApp number for more contact



