PRF192 2

Ace your homework & exams now with Quizwiz!

c

#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 ab B. The output is abc followed by some characters C. The output is abc

c

(see picture) /* 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() { printf(%d", rec(3)); getch(); return 0; } A. 10 B. 11 C. 8 D. 12 E. 9

a

Could the following code find the maximum value among a, b, c and assign to maxVar variable? if (a>b) if (a>c) maxVar = a; else if(b>c) maxVar = b; else maxVar = c; A. No, the code has the WRONG logic B. Yes the code has the CORRECT logic

e

Given the program: #include <stdio.h> #include < conio.h> #include <string.h> int main(){ char str[50]; strcpy(str,"KLM"); for(int i=0; i<strlen(str);i++) str[i] = str[i]-1; printf("%s",str); getch(); return 0; } What is printed|? A. compile error B. LMN C. KLM D. Runtime error E. JKL

b

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

e

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

a

When applied to a variable, what does the unary "&" operator yield? A. The variable's address B. The variable's value C. The variable's binary form D. The variable's right value E. The variable's format

a

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

a

puts() function can display only one string at a time where as gets() is capable of receiving only one string at a time and can receive a multi-word string. A. TRUE B. FALSE

a

A string is a ....................... array of characters terminated by a null('\0') A. one-dimensional B. non-dimensional C. two-dimensional D. None of the others

d

The ______ function after accepting a character and wait for the Enter key to be pressed. A. putchar() B. getch() C. putch() D. getchar()

b

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

c

What IS NOT the unary operators? A. ++ B. ? C. ! D. --

d

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

d

What is required to avoid falling through from one case to the next in the switch construct? A. end; B. stop; C. ; D. break;

c

What is the characteristic of RAM? A. Fixed B. Deterministic Access C. Volatile D. Slower than Hard Disk (in term of accessing speed)

b

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

c

What is the correct statement? A. The vast majority of modern computers process and store information in hexadecimal digits. B. Octal representation is selected as the fundamental to process and store information in modern computers. C. The vast majority of modern computers process and store information in binary digits D. None of the others

b

What is the difference between two number 4 in the following expressions? int num[4]; num[4] = 1; A. The first 4 is particular element, the second 4 is type B. The first 4 is array size, the second 4 is index of a particular element C. The first 4 is particular element, the second 4 is array size D. None of the above

a

What is the most correct statement about function prototype? A. Function prototypes describe the form of a function and the implementation details B. To validate the number of arguments, the compiler needs to know the number of parameters. C. To determine the data type of the call expression, the compiler needs to know the parameters type of the function. D. The parameter identifiers are compulsory.

a

What is the output of the following code? int age = 18; double cashFare = 2.25; printf("His age is %d. The cash fare is $%d", age, (int)cashFare); A. His age is 18. The cash fare is $2 B. Wrong at compiling time C. His age is 18. The cash fare is $0 D. His age is 18. The cash fare is $2.25

c

What is the output when the sample code below is executed? int a=13, b=20; if( a==15 || b > 30) printf("Hello"); else printf("Sorry"); A. compiler error B. Nothing C. Sorry D. Hello

b

What is the output when the sample code below is executed? int i, a[10] = { 1, 1, 2, 3 }, sum =0; for (i = 2; i < 10; i++) sum += a[i] * a[i-2] * a[i-1]; printf("%d", sum); A. An arbitrary value B. 8 C. 17 D. 14

d

What is the output when the sample code below is executed? int i, x=0; for(i=1; i<10; i++) { if(i%2 == 1) x=x+i; else x--; } printf("%d",x); A. 1 B. 19 C. 23 D. 21 E. 20

e

What is the output when the sample code below is executed? int p, q, h; for(p=1; p<=3; p++) for(q=1; q<=2; q++) h=p+q; printf("%d\n",h); A. 4 B. 1 C. 2 D. 3 E. 5

e

What is the output when the sample code below is executed? int x=20, y=35; x=y++ + x++; y=++y + ++x; printf("%d %d\n",x,y); A. 57 35 B. 22 94 C. 57 94 D. 57 92 E. 56 93

a

What is the output when the sample code below is executed? char mess[] = "more"; char *ptr; ptr = mess + strlen(mess); while(ptr>mess) printf("%s",--ptr); A. ereoremore B. oremore C. reoremore D. eoremore E. more

z

What is the output when the sample code below is executed? (de sai, khong co dap an) 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 45 56 C. 23 34 45 56 D. 45 56 23 E. 34 45 56

c

What is the output when the sample code below is executed? int a = 5, b = 2; switch(a+b){ case 1: break; case 2: b = a; break; default: b = -1; a = 4; } printf("%d %d\n",a,b); A. 5 5 B. 5 2 C. 4 -1 D. 5 -1

c

What is the role of the assembler? A. it converts assembly language instructions and data into equivalent machine language instructions and data B. It converts high level language instructions and data into equivalent machine language instructions and data C. It converts high level language instructions and data into equivalent assembly language instructions and data C. None of the above

c

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

c

What will be the output of the following program? #include <stdio.h> #include <ctype.h> int main() { char ch = 'B'; if(islower(ch+1)) putchar(toupper(ch+1)); esle putchar(tolower(ch-1)); return 0; } A. B B. c C. a D. A

d

What will be the output of the following program? #include<stdio.h> int main() { long x[4] = {4,2,8,6}; int i, j; long temp; đm câu này dài quá, gặp cái long long long 4286 này thì chọn D.

d

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. A1B C. B1A D. BA1

c

When you pass an array as an argument to a function, what will actually be passed? A. The values of the elements of the array B. The number of elements of the array. C. The address of the first element of the array D. None of the above

b

Which connection mode would you choose, if you want to open a text file for writing to the end of the file, and possibly reading? A. r+ B. a+ C. w D. a

c

Which is file access mode that always writes data to the end of file? A. w+ B. r C. a D. w

a

Which is not valid in C? A. class aClass(public:int x;}; B. /* A comment */ C. char x=12; D. int d =10;

c

Which is the correct statement for openning a file named "test.txt" for reading? A. File *f = fopen("test.txt", "w"); B. File *f = fopen('test.txt', "r"); C. File *f = fopen("test.txt", "r"); D. File *f = fopen("test.txt", 'r');

b

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

d

Which of the following adds one string to the end of another? A. stradd(); B. stringadd(); C. append(); D. strcat();

c

Which of the following statement would create a random real number in the range of [1.0, 10.0] (inclusive)? A. 1.0 + (double) rand()/RAND_MAX * 10.0 B. (double rand()/RAND_MAX * 10.0 C. 1.0 + (double)rand()/RAND_MAX * 9.0 D. (double)rand()?RAND_MAX * 9.0

a

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 intialize the array at the time of declaration D. The expression arr[20] refers to the 20th element of the array

b

Which of the following variable names are NOT valid? A. go4it B. 4season C. run4 D. go_cart

b

Why hexadeciaml and octal representations are used for sets of bits? A. Because these representations are considerably shorter and more convenient. B. Because modern computers process and store information in hexadecimal and octal digits. C. Because they are larger than bit unit.

c

Why the following code is wrong? int choice = 0, a =0; b=1, c=2; switch(choice){ case a: printf("case A happens!"); break; case b: printf("Wow, that is B!"); break; case c: printf("C please!"); break; } A. Lack of default at the end of switch block B. Can not assign value of choice, a, b, and c at the declaration time C. The value after the "case" keyword must be the constant D. The above code is correct

b

Will int i; scanf("%d",i); work as you want it would be? A. Yes B. No. The arguments you pass to scanf must always be pointers

b

______ is the comparison operation and ____ is the logical operation. A. Modulo, Less than B. Less than, NOT C. NOT, Less than D. Divide, OR


Related study sets

financial algebra foolproof review

View Set

Pharmacology II Prep U Chapter 46: Antianginal Agents

View Set