Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- KAHOOT ANSWERS LINK:
- https://pastebin.com/3MVhyWxV
- WARMUP (Review from Last Week): Array Reversal
- Write a program that creates an array of 5 integer values {1, 2, 3, 4, 5}, and "reverses" it.
- You will copy the first array's values into an empty second array, but backwards. Effectively making
- the second array a "reverse" of the first.
- You will have about 4 loops total. One loop to fill the first array (Array A) with values,
- a second loop to print Array A, a third loop to fill the second array (Array B) with A's values backwards,
- and a fourth loop to print Array B.
- SAMPLE OUTPUT
- A: 1 2 3 4 5
- B: 5 4 3 2 1
- PROBLEM #1: Taking Multiple Strings and Data as Input
- Create a program that will prompt the user to enter string values for their first name, last name, and age.
- However, you must take all 3 inputs IN A SINGLE scanf statement. Then print them back out to the user.
- First name will be stored in a string, last name will be stored in a second string, and age is a normal integer.
- SAMPLE OUTPUT:
- Enter in your first name, last name, and age:
- Justin Bentley 21
- Hello Justin Bentley age 21
- PROBLEM #2: Using fgets(), Strings and String Functions
- Compose a program that prompts the user to enter 3 separate sentences
- as input and store them in 3 separate strings (Each array will be 40 in length).
- Then copy/concatenate all 3 sentences into one huge string of length 120.
- Prompt the user and use fgets() to read the input into the first array.
- Then prompt the user for a second sentence and store it in the second array.
- Then do the same again storing a third string into a third array.
- Next, use the strcpy() function to copy the first array into the fourth array.
- Then use the strcat() function to concatenate the second array to the end of the fourth array.
- Then do it again, concatenating the third array into the fourth array.
- Then print the fourth array using the %s modifier, and the length using strlen().
- SAMPLE OUTPUT:
- Enter in your first name: Justin
- Enter in your middle name: William
- Enter in your last name: Bentley
- JustinWilliamBentley
- Length is 23
- PROBLEM #3: String Reversals
- Create a program that will reverse a string
- Declare and initialize a string with the value: "This is a sentence"
- Then use a loop and the strlen() function and print the string one character at a time backwards.
- SAMPLE OUTPUT:
- ecnetnes a si sihT
- SAMPLE OUTPUT (With the input https://www.youtube.com/watch?v=dQw4w9WgXcQ):
- QcXgW9w4wQd=v?hctaw/moc.ebutuoy.www//:sptth
- PROBLEM #4: Converting Strings to Uppercase
- Compose a program with a character array of 81 characters in size. Also declare
- an integer variable to store the size of a sentence later on.
- Prompt the user to enter in a sentence up to 80 characters and then store it in the array using fgets().
- Get the sizeof() the sentence, and store it in the integer you made earlier.
- Now, using a for loop, go through the sentence one character at a time check if they are uppercase using the isupper() function.
- If it ISN'T uppercase, then make it uppercase using the toupper() function.
- Finally, print out the new string using printf.
- Also, remove the carriage return ā\nā character from the array if you used fgets() to get the input string.
- SAMPLE OUTPUT:
- Enter in a sentence: This is a sentence
- THIS IS A SENTENCE
- PROBLEM #5: Counting Specific Characters in a String
- Re-using your solution to problem #4, modify the program to read in a sentence up to 80
- characters but this time count the number characters THAT ARE NOT spaces, periods,
- exclamation points or commas.
- Print out the total and this should be the number of characters that weren't specified.
- SAMPLE OUTPUT:
- Enter in a sentence: This, is a sentence!
- There are 15 characters.
Add Comment
Please, Sign In to add comment