Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

sum of two no. using command line program

–1 vote
asked Jun 21, 2018 by Sulekha Gorai (110 points)

2 Answers

0 votes
answered Jun 27, 2018 by rodrigosul28 (180 points)
#include <stdio.h>

int main() {
   int a, b, total;
   
    printf("Imput the first number: ");
    scanf("%d",&a);
    printf("Imput the second number: ");
    scanf("%d",&b);

   total = a + b;

printf("The result is: %d " ,total);
    return 0;
}

trade ints for floats if u want decimal numbers!
commented Jun 27, 2018 by shubham kumar (240 points)
This program is not for Command Line Argument
0 votes
answered Jun 27, 2018 by shubham kumar (240 points)
#include <stdio.h>
#include <stdlib.h>

int main(int c, char *args[]){
    int num1 = atoi(args[1]);
    int num2 = atoi(args[2]);
    int sum = num1 + num2;
    printf("Sum of %d and %d is %d.",num1, num2, sum);
    return 0;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...