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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: