Answer to Quiz 1(a) Tue 21 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)
{                                          {
   print("Have a nice day!);                  printf("Have a nice day!");
   return 0                                   return 0;
}                                          }

2 The problem is to write a program that converts
  a time given in seconds into minutes and seconds.

For example, if the user gives 87 as input, then your program prints :

  87 sec = 1 min and 27 sec

Complete the program below with the C code to compute
number of minutes and seconds from the input,
and to write the result on the screen.

#include <stdio.h>

int main(void)
{
   int input;

   int min,sec;

   printf("Give number of seconds passed : ");
   scanf("%d",&input);
   printf("-> user input is %d\n", input);

   min = input/60;
   sec = input%60;

   printf("%d sec = %d min and %d sec\n", input, min, sec);

   return 0;
}