Font size
WorksheetsC Programming : Data types and Operators
Total questions: 39
Worksheet time: 20mins
What is short int in C programming?
Qualifier
Short is the qualifier and int is the basic data type
All of the mentioned
The basic data type of C
What will be the output of the following C code?
#include
None of the mentioned
-128
128
Depends on the compiler
Which data type is most suitable for storing a number 65000 in a 32-bit system?
signed short
int
unsigned short
long
What will be the output of the following C code?
#include
The compiler will flag an error
The program will compile and print the ASCII value of 5
The program will compile and print FAIL for 5 times
The program will compile and print the output 5
What is the size of an int data type?
Cannot be determined
Depends on the system/compiler
4 Bytes
8 Bytes
The format identifier '%i' is also used for _____ data type.
char
int
double
float
Which is correct with respect to the size of the data types?
char > int > float
double > char > int
int > char > float
char < int < double
Which of the data types has the size that is variable?
double
struct
int
float
What will be the output of the following C code?
#include
equal
output depends on the compiler
not equal
error
What will be the output of the following C code?
#include
a
a.0000000
97.000000
run time error
What will be the output of the following C code on a 32-bit machine? #include <stdio.h> int main() { int x = 10000; double y = 56; int *p = &x; double *q = &y; printf("p and q are %d and %d", sizeof(p), sizeof(q)); return 0; }
compiler error
p and q are 4 and 4
p and q are 2 and 8
p and q are 4 and 8
Predict the output of following program. Assume that the numbers are stored in 2's complement form.
#include
same
not same
Which of the following is not a valid declaration in C?
1. short int x;
2. signed short x;
3. short x;
4. unsigned short x;
3 and 4
2
1
All are valid
Predict the output #include <stdio.h> int main() { float c = 5.0; printf ("Temperature in Fahrenheit is %.2f", (9/5)*c + 32); return 0; }
Temperature in Fahrenheit is 41.00
Temperature in Fahrenheit is 37.00
Temperature in Fahrenheit is 0.00
C
Predict the output of following C program #include <stdio.h> int main() { char a = 012; printf("%d", a); return 0; }
Compiler Error
12
10
Empty
In C, sizes of an integer and a pointer must be same.
True
False
Predict the output of following C program #include<stdio.h> int main() { void *vptr, v; v = 0; vptr = &v; printf("%v", *vptr); getchar(); return 0; }
0
Compiler Error
Garbage Value
Predict the output of following C program #include<stdio.h> int main() { char c = 125; c = c+10; printf("%d", c); return 0; }
135
+INF
-121
-8
Predict the output of following C program #include <stdio.h> int main() { if (sizeof(int) > -1) printf("Yes"); else printf("No"); return 0; }
Yes
No
Compiler Error
Runtime Error
In a C program, following variables are defined: float x = 2.17; double y = 2.17; long double z = 2.17; Which of the following is correct way for printing these variables via printf.
printf("%f %lf %Lf",x,y,z);
printf("%f %f %f",x,y,z);
printf("%f %ff %fff",x,y,z);
printf("%f %lf %llf",x,y,z);
"typedef" in C basically works as an alias. Which of the following is correct for "typedef"?
typedef can be used to alias compound data types such as struct and union.
typedef can be used to alias pointer to compound types
typedef can be used to alias a function pointer.
All of the above.
In a C program snippet, followings are used for definition of Integer variables signed s; unsigned u; long l; long long ll; Pick the best statement for these.
All of the above variable definitions are incorrect because basic data type int is missing.
All of the above variable definitions are correct because int is implicitly assumed in all of these.
Only "long l;" and "long long ll;" are valid definitions of variables.
Only "unsigned u;" is valid definition of variable.
What will be the output of the following C code? #include<stdio.h> #include<string.h> int main() { char *str = "x"; char c = 'x'; char ary[1]; ary[0] = c; printf("%d %d", strlen(str), strlen(ary)); return 0; }
1 0
2 1
1 1
2 2
What will be the output of the following C code?
#include <stdio.h>
int main()
{
enum {ORANGE = 5, MANGO, BANANA = 4, PEACH};
printf("PEACH = %d\n", PEACH);
}
PEACH = 6
PEACH = 3
PEACH = 4
PEACH = 5
What will be the output of the following C code?
#include <stdio.h>
#define a 10
int main()
{
const int a = 5;
printf("a = %d\n", a);
}
a = 5
Compilation error
Runtime error
a = 10
What will be the output of the following C function?
#include <stdio.h>
enum birds {SPARROW, PEACOCK, PARROT};
enum animals {TIGER = 8, LION, RABBIT, ZEBRA};
int main()
{
enum birds m = TIGER;
int k;
k = m;
printf("%d\n", k);
return 0;
}
1
Compile time error
0
8
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = -3;
int k = i % 2;
printf("%d\n", k);
}
Implementation defined
Compile time error
-1
1
What will be the output of the following C code?
#include <stdio.h>
void main()
{
int y = 3;
int x = 5 % 2 * 3 / 2;
printf("Value of x is %d", x);
}
Value of x is 3
Compile time error
Value of x is 1
Value of x is 2
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 3;
int l = i / -2;
int k = i % -2;
printf("%d %d\n", l, k);
return 0;
}
Implementation defined
Compile time error
-1 1
1 -1
What will be the output of the following C code? #include <stdio.h> int main() { int x = 1, y = 0, z = 3; x > y ? printf("%d", z) : return z; }
Compile time error
3
Run time error
1
What will be the output of the following C code? #include <stdio,h> void main() { int x = 0, y = 2, z = 3; int a = x & y | z; printf("%d", a); }
3
Run time error
0
2
What will be the final value of j in the following C code? #include int main() { int i = 10, j = 0; if (i || (j = i + 10))
printf("%d",j) ; }
0
Depends on language standard
20
Compile time error
What will be the output of the following C code?
#include
8
Run time error
-2147483648
-1
What is the type of the following assignment expression if x is of type float and y is of type int? y = x + y;
there is no type for an assignment expression
double
int
float
What will be the value of the following C expression? (x = foo()) != 1 considering foo() returns 2
0
True
2
1
Operation "a = a * b + a" can also be written as ___________
All of the mentioned
a *= b + 1;
(c = a * b)!=(a = c + a);
a = (b + 1)* a;
Which of the following is an invalid assignment operator?
a /= 10;
a %= 10;
a |= 10;
None of the mentioned
What will be the output of the following C code?
#include
2
Compile time error
Undefined behaviour
1
What is short int in C programming?
Qualifier
Short is the qualifier and int is the basic data type
All of the mentioned
The basic data type of C
