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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: