Write a C program to accept a string as command line argument and print the arguments in the even positions.
Sample Input (Command Line Argument):
Anu
Manu
Heera
Seema
Madhu
Malini
Ravi
Sunny
Ruby
Sample Output:
Names in even position :
Manu
Seema
Malini
Sunny
Implementation of the above problem:
#include <stdio.h>
int main(int argc, char *argv[])
{
int counter;
printf("Names in even position :\n");
for(counter=2; counter<argc; counter=counter+2)
printf("%s\n",argv[counter]);
return 0;
}
Thanks
Mukesh Rajput
Post A Comment:
0 comments: