#include<iostream>
usingnamespace std;
int main ()
{
int v[50];
int m,a,x,g,i,b,s;
longint n;
cout<<"enter the value of n"<< endl;
cin>>n;
g=n;
if (n>=1)
{
while (n!=0)
{
a=n%10;
if (a%2!=0)
{ v[i]=a;
m++;
}
n=n/10;
}
if (m==0)
cout<<"0";
do
{
s=0;
for (i=0;i<=m;i++)
{
if (v[i]<v[i+1])
{ b=v[i];
v[i]=v[i+1];
v[i+1]=b;
s=1;
}
}
}
while (s==0);
for (i=0;i<=n;i++)
x=x*10+v[i];
if (x==g)
cout<<"no";
else
cout<<x-g;
}
}
it was supposed to analyze a number, extract the odd numbers, count how many there are, rearrange the number and decrease the first number from the second, reaarranged one.
and the problem is a don't send message, the snippet just won't run
Okay, I've read a little more and I see twothree things:
1: You never initialize x used on line 39.
2: In line 38 you use i<=n. if n is 50, then you go out of bounds.
3: You don't initialize i before use in line 17. This means that is is almost guaranteed to be above 50 and you're going out of bounds.