#include<stdio.h>  
 #include<conio.h>  
 #include<stdlib.h>  
 void main(int argc,char *argv[])  
 {  
 int sum=0,i;  
 //if wrong number of command line arguments
 if(argc<3)  
 {  
 printf("Incorrect number of arguments:\n");  
 getch();  
 return 0;  
 }  
 //Add all the numbers entered using atoi function  
 for(i=1;i<argc;i++)  
 {  
 sum+=atoi(argv[i]);  //string to number
 }  
 //print the sum  
 printf("Ans=%d",sum);  
 getch();  
 }  Do you like this Tutorial? Please link back to this article by copying one of the codes below.
URL: HTML link code: BB (forum) link code: 
No comments: