Friday, October 10, 2008



A program to find the sum of n numbers using cmdline arguements. Write another program and use exec() system call to run the above program.

#include
#include

int main(int a, int *ip[ ])
{
int sum=0;
while(a>1)
{
sum = sum + atoi(ip[a-1]);
a--;
}
printf(“sum = %d”,sum);


#include

int main()
{
execl(“./sum.out”,” “ ,”1”,”2”,”3”,”4”,”5”,NULL);
}

TUESDAY, OCTOBER 7, 2008

A program to find the sum of n numbers using cmdline arguements. Write another program and use exec() system call to run the above program.

#include
#include

int main(int a, int *ip[ ])
{
int sum=0;
while(a>1)
{
sum = sum + atoi(ip[a-1]);
a--;
}
printf(“sum = %d”,sum);


#include

int main()
{
execl(“./sum.out”,” “ ,”1”,”2”,”3”,”4”,”5”,NULL);
}

No comments: