1. Too many arguments. Write an empty main function. Write a function called simple that takes a single int parameter and prints it. The function simple should not return anything (return type of void). Place this function below main. Above main, add a declaration for simple that does not indicate any arguments, as in void simple(); Add a call to main that calls simple, but with the arguments 1,2,3....12 answer the following questions about this program: . What does this do? . Do the extra arguments break the code? • Which argument(s) gets printed? . Why? 2. Too few parameters Add a second call to printf in simple. Put 20 %d's in the format string, but provide no other arguments. answer the following questions about this program: • What gets printed? . Where do the values come from? • Why? To help figure this out, you can add some random local variables and observe the changes to your results. 3. Too small array Create a new function called arr. In arr, create struct that contains a five element array of int, followed by an int. Add a for loop that uses the int from inside the structure as the loop variable, and within the for loop set the first 10 elements of the array to 0. Call this arr method from simple. . What happens? Why? answer the following questions about this program:
This is what I have so far
1. Too many arguments.
#include <stdio.h>
Void simple();
Int main()
{
Int n;
simple(1,2,3,4,5,6,7,8,9,10,11,12);
Return0;
}
Void simple(int n){
printf(“%d”,n);
}
What does this do?
This code prints the first argument passed to the simple function called. That is (1).
Does the extra argument break the code?
No, the extra argument does not break the code as the remaining argument are ignored by the function.
Which argument(s) gets printed?
The arguments are printed in the order they are called in the function.
Here, the argument to be passed first is 1 and that is printed.
The first argument is printed.
Why?
This is because the remaining arguments are evaluated by the function and then ignored.
2. Too few parameters
#include <stdio.h>
Void simple();
Int main()
{
Int n;
simple(1,2,3,4,5,6,7,8,9,10,11,12);
Return0;
}
Void simple(int n){
printf(“%d”,n);
printf(%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d)
}
What gets printed?
The values 1 and the garbage values get printed.
Where do the values come from?
The values are some random values generated for the storage part failures like this where we are not allocating values but using them.
Why?
1 is printed as per the statement.
Garbage values are generated because of not having any argument passed to them to locate a specific location.
3. Too small array
Step by step
Solved in 3 steps