Write a program to sum N numbers using command line arguments. The following program must be executed in the command prompt or with the arguments set in the environment.
/* Write a program to sum N numbers using command line arguments*/
#include
<stdio.h>
#include
<ctype.h>
void
main(char *argv[],int argc)
{
int i,s=0;
for(i=1;i<argc;i++)
{
printf("Value at %u is
%s\n",argv[i],argv[i]);
s+=atoi(argv[i]);
}
printf("Sum is %d\n",s);
getch();
}
Comments
Post a Comment