Chap 5

¡Supera tus tareas y exámenes ahora con Quizwiz!

c

Comment on the output of this C code? #include <stdio.h> void main() { int k = 4; int *const p = &k; int r = 3; p = &r; printf("%d", p); } a) Address of k b) Address of r c) Compile time error d) Adress of k + address of r

c

Does this compile without error? #include <stdio.h> int main() { for (int k = 0; k < 10; k++); return 0; } a) Yes b) No c) Depends on the C standard implemented by compilers d) None of the mentioned

a

Does this compile without error? #include <stdio.h> int main() { int k; { int k; for (k = 0; k < 10; k++); } } a) Yes b) No c) Depends on the compiler d) Depends on the C standard implemented by compilers

a

#include <stdio.h> int main() { char *var = "Advanced Training in C by Sanfoundry.com"; } Which of the following format identifier can never be used for the variable var? a) %f b) %d c) %c d) %s

c

Which keyword is used to prevent any changes in the variable within a C program? a) immutable b) mutable c) const d) volatile

d

Which of the following declaration is illegal? a) char *str = "Best C programming classes by Sanfoundry"; b) char str[] = "Best C programming classes by Sanfoundry"; c) char str[20] = "Best C programming classes by Sanfoundry"; d) char[] str = "Best C programming classes by Sanfoundry";

b

Comment on the output of this C code? #include <stdio.h> int const print() { printf("Sanfoundry.com"); return 0; } void main() { print(); } a) Error because function name cannot be preceded by const b) Sanfoundry.com c) Sanfoundry.com is printed infinite times d) Blank screen, no output

b

Comment on the output of this C code? #include <stdio.h> int main() { const int i = 10; int *ptr = &i; *ptr = 20; printf("%d\n", i); return 0; } a) Compile time error b) Compile time warning and printf displays 20 c) Undefined behaviour d) 10

d

Comment on the output of this C code? #include <stdio.h> void main() { int const k = 5; k++; printf("k is %d", k); } a) k is 6 b) Error due to const succeeding int c) Error, because a constant variable can be changed only twice d) Error, because a constant variable cannot be changed

b

What is the output of this C code? #include <stdio.h> int main() { const int p; p = 4; printf("p is %d", p); return 0; } a) p is 4 b) Compile time error c) Run time error d) p is followed by a garbage value

c

What is the output of this C code? #include <stdio.h> int main() { j = 10; printf("%d\n", j++); return 0; } a) 10 b) 11 c) Compile time error d) 0

b

What is the output of this C code? #include <stdio.h> int main() { printf("sanfoundry\r\nclass\n"); return 0; } a) sanfoundryclass b) sanfoundry class c) classundry d) sanfoundry

a

What is the output of this C code? #include <stdio.h> void foo(const int *); int main() { const int i = 10; printf("%d ", i); foo(&i); printf("%d", i); } void foo(const int *i) { *i = 20; } a) Compile time error b) 10 20 c) Undefined value d) 10

a

Which is false? a) Constant variables need not be defined as they are declared and can be defined later b) Global constant variables are initialised to zero c) const keyword is used to define constant values d) You cannot reassign a value to a constant variable

a

Which of the following declaration is not supported by C? a) String str; b) char *str; c) float str = 3e2; d) Both (a) and (c)


Conjuntos de estudio relacionados

BIO 208 UK Microbiology: FINAL EXAM

View Set

The Real World: An Introduction to Sociology Chapter 15; Populations, cities, and the environment

View Set

ABA behavior management consequence based interventions

View Set

Introduction to Java Programming: Ch. 2 quiz

View Set

PrepU Questions: Week 16--Respiratory & Skin/Wounds

View Set

Psychology Exam 2 Multiple Choice

View Set

Research Method Exam 2 Study Guide

View Set

A2 EX.4 CH.38 PREP U Musculoskeletal

View Set