TCS Command Line Argument Area of a Triangle

Ques. Write a C program to find the area of a triangle given the base and the corresponding height. The values base and height are both positive integers passed to the program as the first and second command line parameters respectively. Write the output to stdout formatted as a floating point number rounded to EXACTLY 2 decimal precision WITHOUT any other additional text. Scientific format(such as 1.00E+5) should NOT be used while printing the output. You may assume that the inputs will be such that the output will not exceed the largest possible real number that can be stored in a float type variable.

Note: Please go through Command Line Arguments Post before preparing for these questions. The theory there for TCS command line Program will help you in better understanding.

#include<stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
  if (argc < 3)// as number of arguments needed are 2 and 1 is default arg.
  {
   printf(" Please provide values for both base and height \n");
   return 0;
  }
else
 {
  int base = atoi(argv[1]);
  int height = atoi(argv[2]);
  float area = 0.5*base*height;
  printf("%.2f",area);
  return 0;
 }
}