My Courses
C Programming Questions and Answers – Register Variables
C Programming Questions and Answers – Register Variables 1.What is the output of this C code? #include <stdio.h> int main() { register int i = 10; int *p = &i; *p = 11; printf(“%d %d\n”, i, *p); } a) Depends on whether i is actually stored in machine register b) 10 10 c) 11 11…
C Programming Questions and Answers – Static Variables
C Programming Questions and Answers – Static Variables 1.What is the output of this C code? #include <stdio.h> void main() { m(); m(); } void m() { static int x = 5; x++; printf(“%d”, x); } a) 6 7 b) 6 6 c) 5 5 d) 5 6 2.What is the output of…
C Programming Questions and Answers – Scope of a Variable
C Programming Questions and Answers – Scope of a Variable 1.What is the output of this C code? #include <stdio.h> int i; int main() { extern int i; if (i == 0) printf(“scope rules\n”); } a) scope rules b) Compile time error due to multiple declaration c) Compile time error due to not…
C Programming Questions and Answers – External Variables
C Programming Questions and Answers – External Variables 1.What is the output of this C code? #include <stdio.h> void main() { m(); printf(“%d”, x); } int x; void m() { x = 4; } a) 4 b) Compile time error c) 0 d) Undefined 2.What is the output of this C code?…
C Programming Questions and Answers – Functions Returning Non-integers
C Programming Questions and Answers – Functions Returning Non-integers 1.What is the return-type of the function sqrt() a) int b) float c) double d) Depends on the data type of the parameter 2.Which of the following function declaration is illegal? a) double func(); int main(){} double func(){} b) double func(){}; int main(){} c)…
C Programming Questions and Answers – Basics of Functions
C Programming Questions and Answers – Basics of Functions 1.What is the output of this C code? #include <stdio.h> int main() { void foo(); printf(“1 “); foo(); } void foo() { printf(“2 “); } a) 1 2 b) Compile time error c) 1 2 1 2 d) Depends on the compiler 2.What…
C Programming Questions and Answers – Goto & Labels
C Programming Questions and Answers – Goto & Labels 1.What is the output of the code given below? #include <stdio.h> int main() { printf(“%d “, 1); goto l1; printf(“%d “, 2); l1:goto l2; printf(“%d “, 3); l2:printf(“%d “, 4); } a) 1 4 b) Compilation error c) 1 2 4 d) 1 3…
C Programming Questions and Answers – Break and Continue
C Programming Questions and Answers – Break and Continue 1.Which keyword can be used for coming out of recursion? a) break b) return c) exit d) Both (a) and (b) 2.What is the output of this C code? #include <stdio.h> int main() { int a = 0, i = 0, b; for…
C Programming Questions and Answers – Bitwise Operators
C Programming Questions and Answers – Bitwise Operators 1.What is the output of this C code? #include <stdio.h> int main() { int c = 2 ^ 3; printf(“%d\n”, c); } a) 1 b) 8 c) 9 d) 0 2.What is the output of this C code? #include <stdio.h> int main() {…
C Programming Questions and Answers – Assigment Operators & Expressions
C Programming Questions and Answers – Assigment Operators & Expressions 1.What is the output of this C code? #include <stdio.h> void main() { int x = 0; if (x = 0) printf(“Its zero\n”); else printf(“Its not zero\n”); } a) Its not zero b) Its zero c) Run time error d) None 2.What…