My Courses
C Programming Questions and Answers – Character Pointers and Functions
C Programming Questions and Answers – Character Pointers and Functions 1.What is the output of this C code? #include <stdio.h> int main() { char *str = “hello, world\n”; char *strc = “good morning\n”; strcpy(strc, str); printf(“%s\n”, strc); return 0; } a) hello, world b) Crash/segmentation fault c) Undefined behaviour d) Run time error…
C Programming Questions and Answers – Address Arithmetic
C Programming Questions and Answers – Address Arithmetic 1.What is the output of this C code? #include <stdio.h> int main() { double *ptr = (double *)100; ptr = ptr + 2; printf(“%u”, ptr); } a) 102 b) 104 c) 108 d) 116 2.Comment on the output of this C code? #include…
C Programming Questions and Answers – Pointers and Arrays
C Programming Questions and Answers – Pointers and Arrays 1.What is the output of this C code? #include <stdio.h> void main() { int a[3] = {1, 2, 3}; int *p = a; printf(“%p\t%p”, p, a); } a) Same address is printed. b) Different address is printed. c) Compile time error d) Nothing …
C Programming Questions and Answers – Pointers and Function Arguments
C Programming Questions and Answers – Pointers and Function Arguments 1.What is the output of this C code? #include <stdio.h> void foo(int*); int main() { int i = 10; foo((&i)++); } void foo(int *p) { printf(“%d\n”, *p); } a) 10 b) Some garbage value c) Compile time error d) Segmentation fault/code crash …
C Programming Questions and Answers – Pointers and Addresses
C Programming Questions and Answers – Pointers and Addresses 1.What is the output of this C code? #include <stdio.h> int main() { char *p = NULL; char *q = 0; if (p) printf(” p “); else printf(“nullp”); if (q) printf(“q\n”); else printf(” nullq\n”); } a) nullp nullq b) Depends on the compiler c)…
C Programming Questions and Answers – Conditional Inclusion
C Programming Questions and Answers – Conditional Inclusion 1.What is the output of this C code? #include <stdio.h> #define SYSTEM 20 int main() { int a = 20; #if SYSTEM == a printf(“HELLO “); #endif #if SYSTEM == 20 printf(“WORLD\n”); #endif } a) HELLO b) WORLD c) HELLO WORLD d) No Output 2.Comment on…
C Programming Questions and Answers – Macro Substitution
C Programming Questions and Answers – Macro Substitution 1. What is the output of this C code? #include #define foo(m, n) m ## n int main() { printf(“%s\n”, foo(k, l)); } a) k l b) kl c) Compile time error d) Undefined behaviour 2. What is the output of this C code? #include #define foo(m,…
C Programming Questions and Answers – File Inclusion
C Programming Questions and Answers – File Inclusion 1.What is the sequence for preprocessor to look for the file within <> ? a) The predefined location then the current directory b) The current directory then the predefined location c) The predefined location only d) The current directory location 2.Which directory the compiler first…
C Programming Questions and Answers – C-Preprocessor
C Programming Questions and Answers – C-Preprocessor 1.Property which allows to produce different executable for different platforms in C is called? a) File inclusion b) Selective inclusion c) Conditional compilation d) Recursive macros 2.#include <stdio.h> is called a) Preprocessor directive b) Inclusion directive c) File inclusion directive d) None of the mentioned …
C Programming Questions and Answers – Automatic Variables
C Programming Questions and Answers – Automatic Variables 1.The scope of an automatic variable is: a) Within the block it appears b) Within the blocks of the block it appears c) Until the end of program d) Both (a) and (b) 2.Automatic variables are allocated space in the form of a: a) stack…