Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pointer1.c Type the following C program. Save as pointerl.c. Compile and run the program. Use gdb (a debugger for c) to trace the program so

image text in transcribed
image text in transcribed
image text in transcribed
pointer1.c Type the following C program. Save as pointerl.c. Compile and run the program. Use gdb (a debugger for c) to trace the program so you can answer the questions listed below. GDB Tutorial. 1) Add header comments to the program as shown in the Documentation and Style Requirements 2) Add comments to the top of the program to answer the following questions: A) What does the program do? B) What type is the formal parameter to the mysteryl function? c) What type is the actual parameter to the mysteryl function? D) What role does the *s play in the for loop? #include int mysteryl (char *s) int i for (1-0 ; *s; i++, s++); /* empty body */ return i; ) // end function mysteryl int main (void) printf ("%d ", mystery! ( "asdx ddf gf")); ) I/ end function main 3) Add const to the function parameter (to the data type, the pointer, or both) so that the function satisfies the principle of least privilege. [It is recommended that you test the program with the most restricted parameter type first, then add privileges as needed.1 pointer2.c Enter the following C program. Save it as pointer2.c. Compile and run the program. Use gdb (a debugger for C) to trace the program so you can answer the questions listed below. GDB Tutorial. 4) Add header comments to the program as shown in the Documentation and Style Requirements. 5) Add comments to the top of the program to answer the following questions: A) What does the program do? B) After the line char s[6]. "ab x", what values are in the 6 elements of the s array? c) What causes the for loop to terminate? D) What is the output of the program? #include void mystery2 (char *s) char *t for (test st+) ) // end function mystery2 int main (void) t char s [6] "ab x"; printf("%s ", s); mystery2(s): printf("%s ", s); ) 1/ end function main 6) Add const to the function parameter (to the data type, the pointer, or both) so that the function satisfies the principle of least privilege. It is recommended that you test the program with the most restricted parameter type first, then add privileges as needed. pointer3.c 7) Write a program that has 2 functions and a main (explained below). Save it as pointer3.c Add header comments to the program as shown in the Documentation and Style Requirements. 8) Place the function prototypes above the main and the function implementations below the main function (in the same file). The following are descriptions of the two functions: I. int input (int *a, int *b, int *c) This function should attempt to input 3 integers from the keyboard and store them in the memory locations pointed to by a, b, and c. The input may not be successful in reading all three values. (See "Checking for end of input in C"). The function should return the number of values that were successfully read. II. int sumsort (int *a, int *b, int c) This function should arrange the 3 values in the memory locations pointed to by a, b, and c in ascending order and also return the sum of the contents of the memory locations a, b, and c. 9) The main function should do the following: while eof has not been reached call input if 3 values were successfully read print the 3 values call sumsort and store the returned value in a separate variable print the 3 integers in ascending order folloved by the sum end while

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

More Books

Students also viewed these Databases questions