Write a C program to read two numbers at the command line and perform arithmetic operations on it.
Algorithm:
1. Start
2. Pass a to arguments argc and argv in the main function
3. If argc is equal to 3 then perform addition between the argv[1] and argv[2].
4. Print the sum value
5. Stop
Program Code:
#include<stdio.h>
void main(int argc,char * argv[])
{
int sum=0;
if(argc<2)
{
printf("\n insufficient arguments");
return;
}
sum=atoi(argv[1])+atoi(argv[2]);
printf("\n sum=%d",sum);
getch();
}
Thanks
Mukesh Rajput
Post A Comment:
0 comments: