TCS Command Line Program for Binary to Octal

Note: Please go through Command Line Arguments Post before preparing for these questions. The theory there  for TCS command line Program will help you in better understanding .

#include<stdio.h>
void main(int argc,char *argv[])
{ 
 long int n,r,c,b=1,s=0;
 n=atoi(argv[1]);
 c=n;
 while(c!=0)
 {
 r=c%10;
 s=s+r*b;
 c=c/10;
 b=b*2;
 }
 printf("%lo",s);
 getch();
}