@ishan:
there is error in your loop bro...
for(k=31;k>=0;k++)

it should be k--

.....
On Tue, Sep 20, 2011 at 3:10 PM, vijay singh <[email protected]>wrote:

>
>
> On Tue, Sep 20, 2011 at 2:16 PM, Ishan Aggarwal <
> [email protected]> wrote:
>
>> Hi,
>>
>> When I am running this program, I am getting segmentation fault. Can u plz
>> confirm where is the error.
>>
>> #include<stdio.h>
>> void main()
>> {
>> int Num[31]={0};
>> int Mum[31]={0};
>> int n = 64,m = 7  ,i=0,j=3,k;
>> for(k=31;k>=0;k++)                       // k's value should start from 30
>> because Num[31] doesn't exist and hence it is giving
>> {                                                  // segmentation fault.
>> Olny 0...30 indices exist.
>> Num[k]=n & 1;
>> Mum[k]=m & 1;
>> n=n>>1;
>> m=m>>1;
>>  }
>>
>> for(k=i;k<=j;k++)
>> Num[k]=Mum[k];
>>
>> for(k=0;k<=31;k++)
>> printf("%d ", Num[k]);
>> }
>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to