Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
TCS NQT Technical and Managerial Round Interview Questions

Program Discussion :: Basics

Home > Programs > Basics

10 / 265

Write a program using command line argument to input two number and Calculate the Sum of numbers.

Answer:

#include 
#include 

int main(int argc, char * argv[])
{
  int x,y;
  if (argc == 1 || argc > 3)
  {
    printf("Enter Two Number\r\n");
    exit(0);
  }
  x=atoi(argv[1]);
  y=atoi(argv[2]);
  printf("\nSum of two number %d and %d is : %d\r\n",x,y,x+y) ;
return 0;
}

Asked In :: TCS

Post Your Answer Here:

Language:

Post Your Reply Here:



Language:

Post Your Reply Here: