BCA

C AND LINEAR DATA STRUCURE

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6

PART C

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 . .

6. Program to convert decimal to binary.

    
  /*

Program to find a^b using union to store the values of a, b and a b (for both int and/or float
values of a and b)

 gcc program1.c -o test -lm
*/

#include< stdio.h >
#include< math.h >

  union var
    {
        int a, b;
        float result;
    };
int main()
{
  
    union var v;
    v.a=2;
    v.b=3;
    printf ("enter value for a: ");
    scanf("%d",&v.a);

    printf ("enter value for b: ");
    scanf("%d",&v.b);

    v.result=pow(v.a,v.b);
    printf (" a^b result : ");
    printf("%f\n", v.result);
    return 0;
}