
160 Programming and Data Structures
{
int :c[5 ]b{ 1 , 1 , 1 ,1 ,1 };
in t y a x [ 0 ] , i ;
c l r s c r ();
printf ("\n Values in different Iterations. \n");
printf ("====== == ========= ===========\n">;
for (t=0;i<4;f++)
{
y=y*2+x[i+l];
printf ("[%d] %d\t",i+l,y);
I
printf ("\nEquivalent o f[ ");
fo r (I=0;i<5;f++)
printf ("%d ",x[i]);
printf (" ] in Decimal Number is : ");
printf ("%d\t",y);
getcheO;
)
OUTPUT;
Values in different Iterations.
[113 [2] 7 [3] 15 [4] 31
Equivalent of
[11111 ] in Decimal Number is : 31
Explanation A binary number is initialized in an array. The first element of an array is assigned to
the variable ' y '. The ...