Write a complete program that accepts up to six argument atthe command line prom
ID: 3613925 • Letter: W
Question
Write a complete program that accepts up to six argument atthe command line prompt. The program should print the firstcharacter of any odd-numbered arguments (numbers 0, 2, and 4), andthe second character of any even-numbered arguments (number 1, 3,and 5). The characters printed should be separated by spaces. Theprogram should inform the user of the correct program usage iffewer than two or more than six argument are provided. Assume eachargument contains at least two characters.For example: ahoover@video> myprog arg1 200 list all arg5 m r 2 i a r ahoover@video> Write a complete program that accepts up to six argument atthe command line prompt. The program should print the firstcharacter of any odd-numbered arguments (numbers 0, 2, and 4), andthe second character of any even-numbered arguments (number 1, 3,and 5). The characters printed should be separated by spaces. Theprogram should inform the user of the correct program usage iffewer than two or more than six argument are provided. Assume eachargument contains at least two characters.
For example: ahoover@video> myprog arg1 200 list all arg5 m r 2 i a r ahoover@video>
Explanation / Answer
please rate - thanks #include<stdio.h>#include <string.h>
#include <conio.h>
int main(int argc, char * argv[])
{int i;
if(argc<2||argc>6)
printf("Program aborted--must have between 2 and6 inputs! ");
else
for(i=0;i<argc;i+=2)
printf("%c %c ",argv[i][0],argv[i+1][1]);
printf(" ");
getch();
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.