Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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]

  1. Use editor to create branchloop.c file
  2. Content of the program
    1. 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.
    2. Print your name 10 times using a loop. 10 is a fixed number.
    3. Compare your first name and last name (use String compares).
    4. If the number of characters of your first name is greater than last name print my first name is bigger than my last name.
    5. 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.
    6. If the number of characters is equal then print my first and last name have the same number of characters.
  3. Compile the program using: gcc -o branchloop branchloop.c
  4. 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]

  1. Copy branchloop.c to branchloop2.c
  2. Restructure program to add the following functionality
  3. Enter a number at command line representing an index to your name along with your name. e.g. ./branchloop2 carlos alonso 5
  4. Note: Index is a number from 1 to N. Don't be confused with how arrays start counting at zero.
  5. 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.
  6. Use the number as an index to find the letter correspond to it by indexing.
  7. 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]

  1. Copy branchloop2.c to branchloop3.c
  2. Use the number entered in command line to:
    1. Print your name that many times
    2. Use a Do-While loop
    3. Number cannot be bigger than 10
  3. Count the number of letters in your name.
  4. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

3. Existing organizations and programs constrain behavior.

Answered: 1 week ago