TCS Command Line Programming Questions – 3

Area of a Triangle(Using Command Line Programming)

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 .

Please follow Command Line Programming here.

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

int main(int argc, char *argv[])
{
if(argc==1)
{
printf(“No command line argument present, pls add them first”);
return 0;
}
else
{
int a, b, c;
float area,s;
a=atoi(argv[1]);
b=atoi(argv[2]);
c=atoi(argv[3]);
s=(a+b+c)/3;
area=sqrt(s*(s-a)*(s-b)*(s-c));
printf(“Area is %f”,area);
return 0;
}
}