It is showing warning “non void function contains no return function” as an error , please help
Von Neumann problem
#include
using namespace std;
int convert(int arr[], int n)
{
int dec_value [50]={0};
for(int i=0; i<n ;i++)
{
int base = 1;
while (arr[i]>0) {
int last_digit = arr[i] % 10;
arr[i] = arr[i] / 10;
dec_value[i] += last_digit * base;
base = base * 2;
}
// cout<<dec_value[i]<<endl;
}
for(int i=0; i<n ;i++)
{
cout<<dec_value[i]<<endl;
}
}
int main()
{
int n;
cin>>n;
int arr[50];
for(int i=0; i<n ;i++)
{
cin>>arr[i];
}
convert(arr, n);
return 0;
}
It is still showing the same error.
#include
using namespace std;
void convert(int arr[], int n)
{
int dec_value [50]={0};
for(int i=0; i<n ;i++)
{
int base = 1;
while (arr[i]>0) {
int last_digit = arr[i] % 10;
arr[i] = arr[i] / 10;
dec_value[i] += last_digit * base;
base = base * 2;
}
}
for(int i=0; i<n ;i++)
{
cout<<dec_value[i]<<endl;
}
}
int main()
{
int n;
cin>>n;
int arr[50];
for(int i=0; i<n ;i++)
{
cin>>arr[i];
}
convert(arr, n);
return 0;
}
see below using namespace std;
it should be void not int
#include
using namespace std;
void convert(int arr[], int n)
{
int dec_value [50]={0};
for(int i=0; i<n ;i++)
{
int base = 1;
while (arr[i]>0) {
int last_digit = arr[i] % 10;
arr[i] = arr[i] / 10;
dec_value[i] += last_digit * base;
base = base * 2;
}
}
for(int i=0; i<n ;i++)
{
cout<<dec_value[i]<<endl;
}
}
int main()
{
int n;
cin>>n;
int arr[50];
for(int i=0; i<n ;i++)
{
cin>>arr[i];
}
convert(arr, n);
return 0;
}
It is still not working I have sent you the pic of compiled output
copy this code correct and paste in hackerblocks then submit and tell
Is it possible i can share my screen with you in real time
have u submitted the code that i provide link of?
just submit it one time then i can see what you have submitted then we can talk
yeah I have done it, the code is working fine there
ok so the problem is in your system compiler?
I have no idea, when i am trying run it on the code editor provided to submit the solution it is showing error.
can you talk to me on whatsapp ?there you can send me the photos efficiently

