Question
USING C- PROGRAMING LANGUAGE First Program [10 points] Use editor to create branchloop.c file Content of the program Enter your name while running your program
USING C- PROGRAMING LANGUAGE
First Program [10 points]
- Use editor to create branchloop.c file
- Content of the program
- Enter your name while running your program as you did with hello2.c (using argc and argv) name has to be 2 words exactly (e.g. Jose Lopez, Maria Rodrigues). Make sure to check properly.
- Print your name 10 times using a loop. 10 is a fixed number.
- Compare your first name and last name (use String compares).
- If the number of characters of your first name is greater than last name print my first name is bigger than my last name.
- If the number of characters of your first name is less than last name then print my last name is bigger than my first name.
- If the number of characters is equal then print my first and last name have the same number of characters.
- Compile the program using: gcc -o branchloop branchloop.c
- Run the program using: ./branchloop firstname lastname
Please use the following INPUTS to test first program:
./branchloop Jose Lopez
./branchloop James
./branchloop James Lopez
./branchloop jose escalante
./branchloop Frederick Cohen
./branchloop Carlos Alonso
Second Program [10 points]
- Copy branchloop.c to branchloop2.c
- Restructure program to add the following functionality
- Enter a number at command line representing an index to your name along with your name. e.g. ./branchloop2 carlos alonso 5
- Note: Index is a number from 1 to N. Don't be confused with how arrays start counting at zero.
- The index number must be within the size of your full name - if is not an error should be provided (number is larger than your full name) and exit program with error. The blank between your first and second name should be ignored.
- Use the number as an index to find the letter correspond to it by indexing.
- Finally print your name in all upper case, print index number, and print character indexed in lower case.
Please use the following INPUTS to test first program (and see some of the output):
./branchloop2 Jose Rodrigues 8
JOSE RODRIGUEZ 8 r
./branchloop2 James 4
Error- missing name
./branchloop2 Carlos Lopez 15
Error - index too long
./branchloop2 jose escalante 2
JOSE ESCALANTE 2 o
./branchloop2 Frederick Cohen 0
Error - index is a 0
./branchloop2 Jim Rosario 7
JIM ROSARIO 7 a
./branchloop2 5
Error - missing name
Third program [10]
- Copy branchloop2.c to branchloop3.c
- Use the number entered in command line to:
- Print your name that many times
- Use a Do-While loop
- Number cannot be bigger than 10
- Count the number of letters in your name.
- Print the number of characters in your name followed by your name backwards.
Please use the following INPUTS to test first program (and see some of the output):
./branchloop3 Jose Lopez 2
Jose Lopez Jose Lopez 9 zepol esoj
./branchloop3 James 20
./branchloop3 James Lopez 1
./branchloop3 jose escalante 5
./branchloop3 Frederick Cohen 7
./branchloop3 Carlos Perez 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started