C Program To Add Two Numbers Using Command Line Arguments Parameters

How To Write a C Program To Add Two Numbers Using Command Line Arguments Parameters in C Programming Language ?


Solution For C Program To Add Two Numbers Using Command Line Arguments Parameters:
#include<stdio.h>

void main(int argc , char * argv[])
{
    int i,sum=0;

    if(argc!=3)
      {
      printf("you have forgot to type numbers.");
      exit(1);
      }

    printf("The sum is : ");

    for(i=1;i<argc;i++)
        sum = sum + atoi(argv[i]);

    printf("%d",sum);

}
Output :
The sum is : 30
Tags: C Program To Add Two Numbers Using Command Line Arguments Parameters, command line arguments in c example program, sum of two numbers using command line arguments in java, command line arguments in c example with output, how to run command line arguments in turbo c, command line argument program in java, command line arguments in c pdf, how to run command line arguments in c in windows, to find the sum of n float numbers passed through command line arguments.


Learn More :