arrays - Not printing all the values of a function in C -


#include <stdio.h> void pp(int); int main() {     int a[5]={4,5,7,1,9};     int i;     for(i=0;i<5;++i)     pp(a[i]);       return 0; } void pp(int n) {     char a[6]={'0','0','0','0','0','\0'};     int x,i;     int l=4;     while(n)     {         x=n%2;         a[l--]=x+'0';         n=n/2;     }     for(i=0;i<6;++i)     printf("%c",a[i]);     printf(" "); } 

a int array 5 decimal values in it.
pp function converts decimal numbers 5 bit binary no return type.
when code being executed prints result of a[0] i.e. value of 1st data in , stops! cant understand why :3 pls hlp me out!

my code o/p : 00100
should : 00100 00101 00111 00001 01001

looks wrong compiler on hackerearth.com.

i'd recommend getting real compiler. if you're on windows, visual studio. there's free version available download. alternately, install vmware , install linux virtual machine , use gcc.


Comments