Question
in c programming Arrays Create a program that declares a variable that contains 10 int values and displays the 10 values. Change the previous program
in c programming Arrays Create a program that declares a variable that contains 10 int values and displays the 10 values.
Change the previous program to display the values through calling a function that takes the array as a parameter.
Change the previous program to also call another function that doubles every second element of the array. Call this function after you display the original values. Then display the revised values before exiting the program.
Change the previous program to set the values in the array using getNum().
Change the previous program to repeat everything in the program 3 times (by using a loop).
Change the previous program to call getNum() before the loop starts and use that value to determine how often to do the loop.
Strings and Console Input Write a program that declares a null-terminated string variable that can hold 20 characters (plus one character for the null-termination) and displays it using printf().
Change the previous program to use fgets() to get that string from the user.
Change the previous program to declare a second similar string variable, get the value for it using fgets(), and display that value.
Use the previous program but enter 30 characters for the first string. See what happens.
Change the previous program to not use printf(). Instead, display the string by using a function that youve created that loops, displaying one character at a time until you reach the null-termination (and then display a at the end of the string).
Change the previous program to append the first string to the end of the second string after you get both values but before you display the second string.
Change the previous program to copy the first string to the second one instead of getting the second string from the user or appending the first string.
Change the previous program to use atoi() and atof() to convert the strings to numbers and display the numeric values.
Change the previous program to separate the different actions into functions that are called with the string variables passed as parameters.
Change the previous program to use sscanf() instead of atoi() and atof().
Change the previous program to make the desired input more complex (e.g. take in two ints and a word on the same line).
Change the program from practice problem #3 to compare the two strings and display something indicating the result.
For, Do-While, Switch, Break, Continue Go back in the previous practice problems and replace loops with do-while where applicable.
Similar to the previous problem, replace loops with for statements where applicable.
In both of the previous practice problems, add breaks to get out of loops where applicable.
Create occasions to use continue statements in the previous practice problems (you might have to be creative).
Change the practice problem from the Strings and Console Input section that uses atoi() to use a switch statement that displays something when certain int values are entered.
Pointers Write a program that declares a null-terminated string variable that can hold 20 characters (plus one character for the null-termination) and displays it using printf() (this is the same as a previous practice problem).
Change the previous program to declare a char * variable that points to the string variable. Use the pointer variable to display the string variable.
Change the previous program to use pointer arithmetic to display the contents of the variable one character at a time. Make sure that you stop at the null-termination.
Change the previous program to use an array of 10 ints instead of a string. You will have to loop to display the array but still use the pointer variable and pointer arithmetic.
Change the previous program to display the address of each element at the same time that you display the value of the element.
Write a program that implements the printAndClearInv() example found in the lecture slides.
Change the previous program to use pointers and pointer arithmetic in the printAndClearInv() function. You will still use an array in main() but you will not use an array in printAndClearInv().
Change the previous program to take two additional parameters to printAndClearInv(): the size of one element and the number of elements in the array. Change the data type of the current first parameter from being a pointer to int to being a pointer to char. Then use casting, along with the new parameters and a switch statement, to make printAndClearInv() work for elements of size 1, 2, 4, and 8 bytes. NOTE: This is harder than the previous ones.
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