Exercise 1 Twice By Value Vs By Reference Exercise Objectives Creating Initializing And Using Pointers Function Call 1 (52.86 KiB) Viewed 18 times
Exercise 1 Twice By Value Vs By Reference Exercise Objectives Creating Initializing And Using Pointers Function Call 2 (40.46 KiB) Viewed 18 times
Exercise 1-Twice by Value vs. by Reference Exercise Objectives Creating, initializing, and using pointers Function call by Value vs. call by Reference Problem Description Write and run a C program that performs the following: o Asks the user to input an integer numbers (n) and (m). o Prints the value of n and m. o Passes the number to a function named addTwoNumbers, which add numbers. The function then returns the result to the main function to be printed. o In the main function, print the value of n o Passes the number to a function named addByRef, which add numbers using call by reference and stores the value in the parameter. The function prints the result. o In the main function, Reprint the value of n and m. Sample run Pointer : Add two numbers using call by valuee: Input the first number: 3 Input the second number: 7 The sum by val of 3 and 7 is 10 Pointer : Add two numbers using call by valuee: The sum by ref of 3 and 7 is 10
Exercise 2- Exercise Objectives ✓ Manipulating strings using pointers Problem Description Write and run a C program that performs the following: o Create an arrays of charecters with of size 4. o prompts the user to enter strings and store it in the character array. O Passes the string to a recursive user defined function named charPermu that takes an input array of type char*, start number, and size of an array. The function should print all permutations of a given string. o Call the function from inside the main. Sample run Please enter the string : abcd Pointer Generate permutations of a given string : The permutations of the string are : abcd abdc acbd acdb adcb adbc bacd badc bcad beda bdc a bdac cbad cbda cabd cadb cdab cdba dbca dbac dcba dcab dacb dabc
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!