PRF192

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Given the below code: char ch; scanf("%c", &ch); printf("%c".ch), A user enters "abcd" from the console What is printed? A abcd B a C. Blank(nothing output) D. Compile error

B a

int main(){ char i=127; i++ printf("%d", i); return 0; } What is the output? A. 128 B. -128 C. Undefined D. None of the other choices

B. -128

What will be the output of this program? #include<stdio.h> void main(){ printf("%c", "12345"[1]); } A. 1 B. 2 C. 3 D. 4 E. 5 F. Compile error

B. 2

What is output of the following code? int factorial (int n) { int rs = 1; for (int i=1; i<=n;i++) rs *= i; return rs: } int main() { printf("%d", factorial(4)); return 0; } A. 1 B. 24 C. 16 D. 4

B. 24

How many times will the following loops be executed? int c=1; while ((c > 0 && (c<60)) c++ } A 61 B. 60 C. 59 D. 1 E. 58

B. 60

What will be the output of the following program? #include <stdio.h> int main(void) { char ch1, ch2; int diff, ch1 = 'B'; ch2 = 'A'; diff = ch1-ch2; printf("%c%c%d\n", ch1, ch2, diff); return 0; } A. AB1 B. BA1 C. A1B D. B1A

B. BA1

What is the fundamental addressable unit of primary memory? A. Bibble B. Byte C. Bit D. KByte

B. Byte

What is the fastest memory type? A. Registers B. Cache C. RAM D. Magnetic disk

B. Cache

Given the program: #include <stdio.h> #include <string.h> void main(){ char str[50]; strcpy(str, "Hello world"); *(str+7)="\0'; printf("%s",str); } What is printed? A. Error B. Hello w C. Hello world D. Hello \Orld E. Other F. Hello 10

B. Hello w

Is the following code legal? int a, b = 0; a-b=6 A. YES B. NO

B. NO

Can I use code like this? ((condition)? a: b) = some_expression; A. Yes B. No

B. No

An array declared as: int code[100]; The first element of the array is: A code B. code[0] C. code[1] D. None of the others

B. code[0]

Which of the followings are NOT a valid C identifiers? A. _ ident B. double C. bigNumber D. g42277

B. double

What is ending character of all strings in C? A. !! B. " C. '\0' D. 'n'

C. '\0'

What is the output when the sample code below is executed? int j = 11; do { j= j+1; printf("%d ", j); } while(j<=10); A. 10. B 1 2 3 4 5 6 7 8 9 10 C. 12 D. 11 E. No output

C. 12

What will be the output of this program? #include<stdio.h> void main(){ printf("%c", "12345"[1]); } A 3 B. 4 C. 2 D. Compile error E 1 F. 5

C. 2

What is the output when the sample code below is executed? int a = 3, b = 2; if (a== 2) b = a; else if (a != 1) b= -1; else { a = 2; b = 3;} printf("%d %d\n",a,b); A 3 2 B. 2 2 C. 3 -1 D. 2 3

C. 3 -1

What is the output when the sample code below is executed? void show(int *b) { printf("%d":"b); } int main() { int i; int a =(23, 34, 45, 56}; for(i=0; i<3; i++) show(&a[i]+1); return(0); } A. 23 34 45 B. 23 34 45 56 C. 34 45 56 D. 45 56 23 E. 23 45 56

C. 34 45 56

What is the output when the sample code below is executed? void fun 1 (int aint b) { a++ b++ main() { int x=5,y=10; fun1(x,y); printf("%d %d",x,y): return 0; } A. 10 5 B. 6 11 C. 510 D. 116

C. 510

After the sample code below has been executed, what value will the variable x contain? int x = 5; int y = 2. char op ='*'; switch (op) { default: x += 1, case '+' x += y; case '-': x-+y; } A 4 B. 7 C. 6 D. 8 E 5

C. 6

#include <stdio.h> int calc(int a, int b, char op) int value = 0; switch(op){ case value = a + b; break; case '-' value = a - b; break; case": value = a* b; break; case '/': value = a/b; break; } return value; } int main(){ printf("%c", calc(31, 34, '+')); return 0; What is the output? A. 66 B. 65 C. A D. a E b F. B

C. A

What is the correct definition of an array? A. An array is a collection of different data types spread throughout the memory B. An array is a collection of the same data type spread throughout the memory C. An array is the collection of the same data type located next to each other in the memory D. An array is the collection of different data types located next to each other in the memory

C. An array is the collection of the same data type located next to each other in the memory

Study the following statements: Statement A: In the if else statement, a condition is checked, and if it results to true then the following the if is executed Statement B: In a nested if statement, each else matches the nearest if preceding it, which been matched by an else. Select the true clause among the followings: A. Statement A is TRUE, statement B is FALSE B. Statement A is FALSE, statement B is TRUE C. Both statements are TRUE D. Both statements are FALSE

C. Both statements are TRUE

What is the output when the sample code below is executed? char ch='p': switch(ch){ case 'p': case 'P' printf("Hello"): case 'q': printf("ABC"): } A. Nothing (no output) B. Hello C. Hello ABC D. ABC E. compiler error

C. Hello ABC

Which code line is incorrect? A putchar('a'): B. putchar(65): C. None of the others

C. None of the others

How can you print a '%' character in a printf format string? A. Simply precede the percent sign with a backslash 1% B. Simply precede the percent sign with a double backslash \\% C. Simply double the percent sign: %%

C. Simply double the percent sign: %%

What kind of loop that executes its body at least once? A. while B. for C. do while

C. do while

Which of the following shows the correct syntax for an if statement? A. if expression B. if{ expression C. if( expression) D. expression if

C. if( expression)

How is the integer pointer var declared in C? A. pointer *var, B. int pointer var; C. int *var, D. int pointer *var,

C. int *var,

All languages reserve certain words for their internal use, these words hold a specific meani context of a particular language, and are referred to as A vanables B. identifiers C. keywords D. operators

C. keywords

Which is NOT a valid data type in C language? A double B. float C. string D. int

C. string

Which one of the following will read a character from the keyboard and store it in the variable A. c = getc(). B. getc(&c), CC=getchar(stdin), D. getchar(&c); E. c = getchar():

c = getchar():

Which library that the following functions belong to? double round (double); double ceil (double); double sqrt (double); double pow (double base, double exponent); A. stdio.h B. stdlib h C. time.h D. math.h

math.h

What is the output when the sample code below is executed? int index, sum; index = sum = 0; while(index++ < 3) sum += 10* index; printf("%d", sum); A 10 B. 20 C. 30 D. 60

60

What is the output when the sample code below is executed: main(){ int i=5; printf("%d\n", i = ++i == 6); } A 1 B. 5 C. O D. 7 E 6

A 1

What will be the output of this code fragment? int sub[50], i; for (i=0;i<=48; i++); sub] = i; printf("\n%d", sub[i]); A 48 B. 49 C. 50 D. None of the others

A 48

Consider the statement int a [8] = {0, 1, 2, 3, 5); What is the value of a[4]? A 5 B. Arbitrary value C. NULL D. 0

A 5

Which of the followings can be passed to the functions? A Data type B. Loop C. Value D. Operator

A Data type

The main() function is the function to which the operating system transfers control at the star A True B. False

A True

Which library you need to include into your program in order to use printf function? A stdio.h B. studio.h C. stdio.c D. studio.c

A stdio.h

What is the output when the sample code below is executed? int a = 0, b = 0, c = 0; if (a > 0) if (b> 0) c = 1; else c = 2; a++ b-=1; printf("%d %d %d\n",a,b,c); A. 1-1 0 B. 0 -1 0 C. 0-1 2 D. 1 0 2

A. 1-1 0

What will be the output of the following program? #include<stdio.h> int fun (int arr[], int n) { int rs = 1; for (int i=0;i<n;i++) rs*= arr[0]; return rs; } int main() { int a[3] = {2,3,4}; printf("%d", fun(a,3)); return 0; A. 24 B. 25 C. 26 D. 27

A. 24

What is the maximum value of an unsigned char? A. 255 B. 256 C. 127 D. 128

A. 255

What is the value of variable a returned by the C statement? int a = strlen("OhMyGod!"); A. 8 B. 9 C. 10 D. 11

A. 8

Evaluate the following as true or false: !(1 &&0 || !1) A. TRUE B. FALSE C. Invalid expression

A. TRUE

getchar and scanf functions are buffered input types. A. TRUE B. FALSE

A. TRUE

Which of the following statements is correct? A. The array int arr[26] has 26 elements B. The expression arr[1] refers to the first element in the array C. It is necessary to initialize the array at the time of declaration D. The expression arr[20] refers to the 20th element of the array

A. The array int arr[26] has 26 elements

#include <stdlib.h> #include <stdio.h> int main() { char a[3]= ('a', 'b','c"}; printf("%s",a); return 0; } Which statement is correct about the output? A. The output is abc B. The output is abc followed by some chraracters C. The output is ab

A. The output is abc

What will print when the sample code below is executed? int main() { int a = 3, b,c; b=a = 10: c=a<10; printf("a = %d, b = %d, c = %d", a,b,c); return 0; } A. a=10, b=10, c=0 B. a=10, b=10, c=10 C. a=3, b-10, c=10 D. a=10, b=0, c=0

A. a=10, b=10, c=0

Which of the following denotes file modes that can be used in C program? A. r B. d+ C. d D. Wr

A. r

What is the output of the following code? void test(float x) {x+=25; printf(" Value inside the function: %.2f\n",x); x += 25; int main() { float y: y = 100; printf(" y = %.2f\n",y); test(y); printf(" y = %.2f\n",y): return(0): } A. y=100 Value inside the function: 125 y=125 B. y = 100.00 Value inside the function: 125.00 y= 100.00 C. y=100.00 Value inside the function: 125.00 y=150.00

A. y=100

The address operator is shown using the.......symbol. A @ B. C. # D. &

D. &

What does the function feof(FILE *fp) return if our program has not attempted to read the end of file mark? A Does not return anything B. -1 CT D. 0

D. 0

What will be the output of the following program? #include <stdio.h> int main(void) int ref] = {1, 2, 4}; int *ptr, int index; for (index = 0, ptr = ref, index < 3; index++, ptr++) printf("%d %d", ref[index]. *ptr); return 0; } A. 124124 B. 142241 C. 144221 D. 112244

D. 112244

What will be the output of this program? #include<stdio.h> void main() { int num[26], temp: num[0] = 100; num[25] = 200; temp = num[25]; num[25] = num[0]; num[0] = temp; printf("%d %d", num[0], num[25]); } A. 025 B. 25 100 C. 026 D. 200 100

D. 200 100

What is the output when the sample code below is executed? int i; for(i=0; i<5; i++); printf("%d ", 1); A. 01234 B. 0 12345 C. 4 D. 5 E compiler error

D. 5

What is the output when the sample code below is executed? int power (int base, int exponent) { int result, i result = 1; for (i = 1; i <= exponent; i++) result = result base; return result, } int main() { printf("%d", power (4,3)); return 0; } A. 7 B. 12 C. 4 D. 64

D. 64

Which of the following statements is INCORRECT? A. If a file is opened for reading, it is required that the file must exist B . If a file is opened for writing, it is required that the file must exist C. If a file opened for writing already exits, its content will be overwritten D. None of the others

D. None of the others

Which options are correct about the function getchar() ? A. No return value B. Return a char type C. Accepts 1 parameter D. Not accept any parameter

D. Not accept any parameter

What is the output when the sample code below is executed? int s1=0; for(;s1;) printf("A"); A. A B. compiler error C. runtime error D. Nothing (no output)

D. Nothing (no output)

What is the output when the sample code below is executed? void foo(int *z) { return(m+2); int main() { int a 45, *b, m = 10; b=foo(&a); printf("%d %b", a, b); return 0; A. 45 12 B. 45 10 C. 10 45 D. compile error E. 12 12

D. compile error

What is the correct prototype of function fclose? A. int fclose(FILE *); B. Void fclose(FILE *); C. int fclose(FILE *, char *); D. int fclose(File");

D. int fclose(File");

All languages reserve certain words for their internal use, these words hold a specific meaning within the context of a particular language, and are referred to as A operators B variables C identifiers D. keywords

D. keywords

What is size of an int? A. 32 bits B. 16 bits C. 8 bits D. Dependent on machine's "word" size

Dependent on machine's "word" size

/* What will be the output of the following program? */ #include <stdio.h> #include <conio.h> int func (int t) { return 2*t; } int rec ( int x). int f if ( x == 1) return (1); return(2* func (x-1)); } int main() f printf("%d", rec (3)); getch(); return 0; Choose the right answer bellow: A. 9 B. 11 C. 10 D. 12 E. 8

E. 8

Which one is the INCORRECT statement to declare an array? A. int digit[5] B. int digit1[5] = {1,2,3); C. int digit2[5]= {1,2,3,4,5); D. int digit1[5]= 0; E. None of the other choices

E. None of the other choices


Ensembles d'études connexes

Glacial Landscapes 5:Glaciers, Deserts, and Wind

View Set