Answer to Quiz 1(b) Thu 23 Aug 2001


1. The program below has several errors and omissions.

   Write the corrected version of the program at the right
   of the given code.

                                          #include <stdio.h>

int main                                  int main(void)
                                          {
   printf(Good Luck!")                       printf("Good luck!");
   return 0;                                 return 0;
}                                         }


2. The problem is to write a program to convert a given
   weight in pounds (lb) to kilograms (kg), using 1 lb = 0.45 kg.

A sample session of the program goes like

Give weight in pounds : 130
  130.00 lb = 58.50 kg

Complete the program below with the C code to compute
the conversion and to write the result on the screen in the format above.

#include <stdio.h>

#define   LB_to_KG   0.45

int main(void)
{
   float lb;

   float kg;

   printf("Give weight in pounds : ");
   scanf("%f",&lb);

   kg = LB_to_KG*lb;

   printf("  %.2f = %.2f\n", lb, kg);

   return 0;
}