Question: The assignment must be printed and stapled. Include name, course number, and assignment number at the top. Include the source code and a screen shot

 The assignment must be printed and stapled. Include name, course number,

The assignment must be printed and stapled. Include name, course number, and assignment number at the top. Include the source code and a screen shot off the execution results for each program. Make sure to include a header and line comments in the programs. The assignment must be neat and clear. 1) Write a program that asks the user to enter an integer with magnitude less than 1000. The digits (and sign) of the number should then be divided and stored in a structure that contains variables for a ones digit, tens digit, and hundreds digit, as well as a character variable to store a plus sign '+' if the number is positive or a minus sign '-' if the number is negative. Print the values of the structure. For example, if the structure is called "digit" and the number entered was 245, the structure should contain: digit.sign = '+' digit.hundreds = 2 digit.tens = 4 digit.ones = 5 Declare the following structure in a program, along with two instances (s1 and s2) as indicated: struct my_struct (int a; float b;} s1, s2; In the program declare a pointer to the structure. Ask the user to enter the values for each structure. Then, using the pointer, print the values of each structure s1 and s2. Don't access the structure variables directly (i.e. don't use s1.a, s1.b, etc.). Write a program that includes a function (outside of the "main" function) to switch the values of two integer variables using only two pointers as arguments. In the main function, ask the user to enter two numbers. The program should then call the function (using pointers to the variables) to switch the two values and then print the results. Modify the "stack.c" program we looked at in class (available on D2L) such that the variable "top" is a pointer to the "contents" array rather than a regular variable. The pointer should point to the current array element that represents the top of the stack, and should change as values are added and removed. Include a screenshot of the program running ("push" a few values to the stack, "pop" a value or two out of the stack, then display the contents)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!