Numeric Argument and Calculate its Sum

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main(int argc,char *argv[])
 {
    int i,no,s=0;
    float avg;
    clrscr();
    printf("\n Total argument : %d",argc);
    printf("\n file name = %s ",argv[0]);
    for(i=1;i<argc;i++)
     {
          // Convert string to number
          no=atoi(argv[i]);
          printf("\n no = %d ",no);
          s=s+no;
     }
    avg=s/argc;
     printf("\n Sum = %d",s);
    printf("\n average = %f",avg);
    getch();
 }

Post a Comment

Previous Post Next Post