February 12th, 2022
[Scroll to the bottom of this page to discuss stuff].
utility.h
containing the required table printing function.Find the output of the following code:
#include <stdio.h>
int main()
{
int x = 1, y = 2, z = 3;
printf(" x = %d, y = %d, z = %d \n", x, y, z);
{
int x = 10;
float y = 20;
printf(" x = %d, y = %f, z = %d \n", x, y, z);
{
int z = 100;
printf(" x = %d, y = %f, z = %d \n", x, y, z);
}
}
return 0;
}
Options:
Output:
x = 1, y = 2, z = 3
x = 10, y = 20.000000, z = 3
x = 1, y = 2, z = 100
Output:
x = 1, y = 2, z = 3
x = 10, y = 20.000000, z = 3
x = 10, y = 20.000000, z = 100
Compilation Error
Output:
x = 1, y = 2, z = 3
x = 1, y = 2, z = 3
x = 1, y = 2, z = 3
Attempt this worksheet on variable scoping. You should read about extern
keyword (see below) before attempting this.
extern
keyword. You can use this.