#include 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.
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 with 3 images