This document is a tutorial for the B. Tech. Sem.I (EC) course at Dharmsinh Desai University for the academic year 2024-2025. It includes multiple-choice questions, true or false statements, and code prediction tasks related to the C programming language. The content covers escape sequences, data types, constants, and basic programming concepts.
This document is a tutorial for the B. Tech. Sem.I (EC) course at Dharmsinh Desai University for the academic year 2024-2025. It includes multiple-choice questions, true or false statements, and code prediction tasks related to the C programming language. The content covers escape sequences, data types, constants, and basic programming concepts.
Department of Electronics & Communication Engineering
(Faculty of Technology, Dharmsinh Desai University, Nadiad)
Academic Year: 2024 - 2025
Tutorial – 2
Subject : PPS Class : B. Tech. Sem.I (EC)
Q.1 Select the most appropriate option.
(1) Which of the following escape sequences moves the cursor position to the new line? (a) \n (b) \r (c) \t (d) \e (2) Which of the following escape sequences represents the backspace character in C? (a) \n (b) \b (c) \t (d) \r (3) Which of the following escape sequences represents a single quotation mark in C? (a) \' (b) \" (c) \n (d) \t (4) Which of the following is not a C language keyword? (a) Volatile (b) enum (c) unsigned (d) go (5) Which of the following is a valid way to declare a constant variable in C? (a) constant int x = 5; (b) int constant x = 5; (c) const int x = 5; (d) int x = constant 5; (6) How many byte(s) does a char type take in C? (a) 1 (b) 2 (c) 3 (d) 4 (7) Which is correct with respect to the size of the data types in C? (a) char > int > float (b) char < int < float (c) int < char < float (d) int < chat > float Q.2 State True or False (1) C allows its keywords to be also used as identifiers. (2) ANSI C treats the variables' name and Name to be the same. (3) An integer constant in C must have at least one decimal point. (4) 256 is the largest value that an unsigned short int type variable can store. (5) The keyword typedef can be used to create a data type identifier. (6) Character constants are coded using double quotes. Q.3 Predict the output. (1) #include <stdio.h> int main() { signed char chr; chr = 128; printf("%d\n", chr); return 0; } (2) #include <stdio.h> int main() { float x = 'a'; printf("%f", x); return 0; } (3) #include <stdio.h> int main() { enum {ORANGE = 5, MANGO, BANANA = 4, PEACH}; printf("PEACH = %d\n", PEACH); } (4) #include <stdio.h> #define a 10 int main() { const int a = 5; printf("a = %d\n", a); } (5) #include <stdio.h> int main() { int var = 010; printf("%d", var); } (6) #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; } (7) #include <stdio.h> #define MAX 2 enum bird {SPARROW = MAX + 1, PARROT = SPARROW + MAX}; int main() { enum bird b = PARROT; printf("%d\n", b); return 0; } (8) #include <stdio.h> int main() { printf("ec\rclass\n"); return 0; } (9) #include <stdio.h> int main() { printf("ec\r\nclass\n"); return 0; } (10) #include <stdio.h> int main() { const int p; p = 4; printf("p is %d", p); return 0; } (11) #include <stdio.h> void main() { int k = 4; int *const p = &k; int r = 3; p = &r; printf("%d", p); }