You are on page 1of 80

Once the function ends, the control is returned back to the ...

function and execution continues from the


statement immediately after the function call | executing

what number is equivalent to -4e3? | -4000

what is the output when the sample code below executed? | 8

#include<stdio.h> | 8

int fn(int v){ | 8

if(v==1||v==0) | 8

return 1; | 8

if(v%2==0) | 8

return (fn(v/2)+2); | 8

else return(fn(v-1)+3); } | 8

int main() { | 8

printf("%d\n",fn(5)); | 8

return (0); } | 8

which 2 options are correct about the function scanf? | scanf returns the number of addresses
successfully filled of EOF ; EOF indicates that scanf did not fill any address AND encountered an end of
data character.

what is the output when the sample code below is executed? | 1 55 0

int s=35; | 1 55 0

printf("%d%d%d",s==35,s+20,s>40) | 1 55 0

according to the standard C specification, what are the respective minimum sizes (in bytes) of the
following two data type: int and long? | 2,4
what does the following declaration mean (if there are more than one correct answers, choose the best
one) | pointed to the array of 10 elements.

int *ptr[10]; | pointed to the array of 10 elements

what would happen if the user types in the number 3 and presses Enter when running this program? |
the program exits without printing the square

main(){ | the program exits without printing the square

int x=5; | the program exits without printing the square

char c; | the program exits without printing the square

printf("Enter x="); | the program exits without printing the square

scanf("%d",&x); | the program exits without printing the square

printf("Calculate square(Y/N):"); | the program exits without printing the square

c=getchar(); | the program exits without printing the square

if(c==Y||c==y) | the program exits without printing the square

printf("sqr=%d",x*x);} | the program exits without printing the square

what is the output when the sample code below is executed? | 8

int i,j,k,x=0; | 8

for(i=1;i<5;i++) | 8

for(j=0;j<i;++j){ | 8

switch(i+j){ | 8

case 0:x=x+1; | 8

break; | 8

case 1: | 8

case 2: | 8
case 3: x=x+2; | 8

break; }} | 8

printf("%d",x); | 8

the while loop can be written as a for loop | true

what is the output when the sample code below is executed? | How ae you

char fun[]="How are you?"; | How ae you

char **p; | How ae you

p=fun; | How ae you

while(***p!='\0'){ | How ae you

if(strlen(p)!=7) printf("%c",**p); | How ae you

p++;} | How ae you

given the below code? | pfc i

char st[50]; | pfc i

scanf("%5[^\]",st); | pfc i

printf("%s",st); | pfc i

a user enters "pfc is simple" | pfc i

what is printed? | pfc i

how is a variable accessed from another file? | the global variable is referenced via the extern specifier

which one of the following is a variable, which can contain the address of the memory location of
another variable?(choose the best answer) | struct
declare a two dimensional integer array of two rows and four columns having some initial values | int
arr1[4][2]={{8,12},{22,45},{23,40},{44,79}}

what value will x contain in the sample code below? | 25

int x=011|0x10; | 25

what is the output when the sample code below is executed? | 3 3 1

int g=1; | 3 3 1

printf("%d %d %d",g,++g,g++); | 3 3 1

what is the output when the sample code below is executed? | nothing

int i=0; | nothing

for(;i;) | nothing

printf("This is a loop"); | nothing

if(i>0) | nothing

printf("in C program"); | nothing

what is the output when the sample code below is executed?

#include<stdio.h> | 65 65

void main(){ | 65 65

int i,j=25; | 65 65

int *pi, **pj=&j; | 65 65

***pj=j+5; | 65 65

i=*pj+5; | 65 65

pi=pj; | 65 65

**pi=i+j; | 65 65
printf("%d%d",**pi,pj);} | 65 65

which one of the following is a valid function definition? | double funct(int a,int b, double c)

what is the output when the sample code below is executed? | our are

char mess[]="Your are welcome here"; | our are

char *p; | our are

p=mess; | our are

mess[8]='\0'; | our are

puts(++p); | our are

which of the following can be used to append one string at the end of another | strcat

what is the output when the sample code below is executed? | compiler error

int a=8, b=9; | compiler error

if(a%2=b%3) | compiler error

printf("\n%d %d", ++a, b--) | compiler error

what will be printed when the sample code below is executed? | 56789 0123456789

char **buffer="0123456789"; | 56789 0123456789

char **ptr=buffer; | 56789 0123456789

ptr+=5; | 56789 0123456789

printf("%s\n",ptr); | 56789 0123456789

printf("%s\n",buffer); | 56789 0123456789


in myfile.c does not exist, what will be output of this program?

#include<stdio.h>

main(){

FILE *fi;

fi=fopen("myfile.c","r");

if(fi=NULL)

{puts("file is not opened");

exit(1);}

else

puts("FILE opened");} no output

given the below code: | 8

int a=1; | 8

int i=7; | 8

if(a||i++) | 8

i++; | 8

printf("%d",i); | 8

what is the output | 8

a string is a ... array of characters terminated by a null('\0') | one-dimensional

referring to the sample code below, what value will the variable counter have when completed

int x=3, counter = 0; | 2

while(x-1){ | 2

++counter; | 2
x--;} | 2

the operation between float and int would give the result as | none of the above

what is the output when the sample code below is executed? | 85

int k=0x55; | 85

printf("\n%d",k); | 85

printf("\n"); | 85

what is the output when the sample code below is executed? | 19

int calc(int a, int b){ | 19 19

int x,y; | 19 19

x=a+b; | 19 19

y=a*b; | 19 19

return(x+y);} | 19 19

int main(){ | 19 19

int p=3, q=4, r, s; | 19 19

r=calc(p,q); | 19 19

s=calc(q,p); | 19 19

printf("\n%d%d",r,s); | 19 19

return 0;} | 19 19

which of the following statement are true with regards to the ll operator? | this operator is used to
combine two conditional expressions which evaluate to true as a whole only if either of the two
expressions evaluate to true

which of the following statement are true with regards to the ll operator? | only if both the expressions
evaluate to false, the outcome is false
what is the output when the sample code below is executed, assuming int data type is 32 bits in size? |
1,4,8,4

printf("%d, %d, %d, %d", sizeof(char), sizeof(int), sizeof(10.0), sizeof(10.0f)); | 1,4,8,4

what is the output when the sample code below is executed?

int a[5]={0}, x=2111223;

while(x>10){

a[x%10-1]++;

x/=10;}

printf("%d",a[1]); | 2

what will the code below print when executed?

double x=-3.5, y=3.5;

printf("%.0f:%.0f\n",ceil(x), ceil(y));

printf("%.0f:%.0f\n",floor(x), floor(y)); | -3:4 -4:3

consider the following code:

if(a==b)

printf("\n the number are equal");

else(a<b)

printf("\n the smaller number is: %d",a);

else

printf("\n the smaller number is: %d",b);

in the above code, if a=14 and b=9, then the .... clause is executed | else
when does the code block following while(x<100) execute? | when x is less than one hundred

which are the following statements printf % character? | printf("\%%") ; printf("%%")

A comment can be split over more than one line, as follows | true

/** A program to calculate average of 5 numbers. **/ | true

what is the output when the sample code below is executed? | 5

int p,q,h; | 5

for(p=1;p<=3;p++) | 5

for(q=1;q<=2;q++) | 5

h=p+q; | 5

printf("%d\n",h); | 5

what is the output when the sample code below is executed? | 4

int x=3; | 4

if(x==2) | 4

x=0; | 4

if(x==3) | 4

x++; | 4

else x+=2; | 4

what is the incorrect statement about floating-point data types(float and double)? | float-point means
that the decimal point can float(that is, it can ba placed anywhere relative to the significant digits)

what is the output when the sample code below is executed? | i:16, k:4
int n=10, i; | i:16, k:4

int k=0; | i:16, k:4

for(i=1;i<n;i=i*2)k++; | i:16, k:4

printf("i:%d, k:%d", i, k); | i:16, k:4

printf("\n"); | i:16, k:4

what is the output when the sample code below is executed? main() | 1

{int i=5; | 1

printf("%d\n",i=++i==6) | 1

what is the output when the sample code below is executed?

char *ptr="Hello world"; | ello worldlo world

ptr++; | ello worldlo world

printf("%s",ptr); | ello worldlo world

ptr+=2; | ello worldlo world

printf("%s",ptr); | ello worldlo world

what is the output when the sample code below is executed? | 9

int i=3; | 9

switch(i){ | 9

case 3: i+=5; | 9

if(i==8){ | 9

i++; | 9

if(i==9) break; | 9

i*=2;} | 9
i-=4; | 9

break; | 9

case 8: | 9

i+=5; | 9

break; | 9

default: | 9

i+=6; | 9

break;} | 9

printf("%d\n",i); | 9

using break statement we can exit from | for a loop

give the code below | 3

int a=2; | 3

printf("%d",++a,a+5) | 3

what is printed? | 3

What is 7/9*9 equal to? | 0

What is the output when the sample code below is executed? | 2 5 4 6

int i=0, j=0; | 2 5 4 6

for( i=1; i<10,j<5;i*=2,j++){ | 2 5 4 6

j+=2; | 2 5 4 6

printf("%d ",j);} | 2 5 4 6

Printf("%d %d",i,j); | 2 5 4 6
What is the output when the sample code below is executed?

int i; | 1 2 3

for(i=1;i<4;i++) | 1 2 3

switch(i){ | 1 2 3

case 1: printf("%d ",i); | 1 2 3

break; | 1 2 3

case 2: printf("%d ",i); | 1 2 3

break; | 1 2 3

case 3: printf("%d ",i); | 1 2 3

break; | 1 2 3

case 4: printf("%d ",i); | 1 2 3

}|123

If the program completes executing successfully, what value should the function main returned? | 0

Which value can not be assigned to an unsigned-short type? | -3

If a program contains just one function, then it must be___. | main()

What number is equivalent to -4e3 ? | -4000

What does the following declaration mean ( If there are more than one correct answer, choose the best
one)

Int*ptr[10]; | Pointers to the array of 10 elements

___ is the comparison operation and ___ is the logical operation. | less than, NOT
- What is the output when the sample code below is executed? | 12.500000 12.450000

The ___ function after accepting a character and wait for the Enter key to be pressed. | getchar()

Evaluate the following as true or false: !(1&&0||!1) | true

The precedence of operators is ___ | Arithmetic, Comparison, Logical

What is the output?

int main(){ | -128

char i=127; | -128

i++; | -128

printf("%d",i); | -128

return 0; | -128

} | -128

What is the output of the following code?

int sum(int n); | s=15

int main() | s=15

printf("s=%d\n",sum(5)); | s=15

return 0; | s=15

int sum(int n) | s=15


{

int s,i; | s=15

s=0; | s=15

for(i=1;i<=n;i++) s+=i; | s=15

return(s); | s=15

} | s=15

A user enter "pfabcd" from the console. What is printed? | pf

What is the output when the sample code below is executed?

float j; | 1000000

j=1000*1000; | 1000000

printf("%3.0f",j); | 1000000

By default any real number is treated as | a float

A string is a ___ array of characters terminated by a null('\0'). | one-dimensional

If you push 1,3, and 5 -in that odder -onto a stack , which number is popped out first? | 5

Which of the following adds ones string to the end of another? | strcat();

We want to round off x, a float, to an int value. The correct way to do so would be: | y= (int)(x+0.5)

Which of the following is the Boolean operator for logical-and ? | &&


Which is not a loop structure in C ? | repeat until

Which of the following statement is (are) wrong ? (choose 2) | 3=d ; 3**c=d;

Which of the following can be used to append one string at the end of another ? | strcat

What is the output when the sample code below is executed ?

int i; | 4

i= 1; | 4

i = i+ 2*i ++; | 4

printf("%d",i); | 4

What is the correct fomat to define a value in C ? | #define PI 3.14159

What is required to avoid falling through from one case to the next ? | break;

Which is the correct statement about coupling ? | Global variables introduce a low degree of coupling.

Which of the following functions compares two strings ? | strcmp();

What is the correct prototype in C ? | void doFunc(int x, int y);

Which of the following statements prints %character ? | printf("\%%"); printf("%%");


What is the output when the sample code below is executed ?

#include<stdio.h>

int fn(int v){

if( v==1||v==0) return 1;

if(v%2==0) return(fn(v/2)+2);

else return(fn(v-1)+3);

int main(){

printf("%d\n",fn(5));

return (0);

}|8

Which of the following data type occupied 1 byte ? (choose two) | unsigned char; char.

What are the correct statements ? ( choose two) | The operator ** reads as 'the data at address'; The
*** operator is a unary operator and it returns the memory address of the operand.

What is the output when the sample code below is executed ?

int s=0;

for (int i=1;i<=10;++i){

s=s+i;

if (s>=6) break;

s=s+1;

printf("%d\n",s); | 8
#include<stdlib.h>

#include<stdio.h>

int main(){

int i,n,a=10,b=20; | 10 pseudo-random integers between 10 and 20 inclusive.

for(i=0;i<10;i++){ | 10 pseudo-random integers between 10 and 20 inclusive.

n=a+rand()%(b+1-a); | 10 pseudo-random integers between 10 and 20 inclusive.

printf("%d\n",n);

return 0;

Run the above program, which is correct statement about the output? | 10 pseudo-random integers
between 10 and 20 inclusive.

Which are proper declarations of a string str which stores the value "Melodies" (choose two) | char
str[]="Melodies";char str[9] =" Melodies";

What would happen if the user types in number 3 and presses Enter when running this program ?

main(){ | program exits without printing the square

int x=5; | program exits without printing the square

char c; | program exits without printing the square

printf("Enter x="); | program exits without printing the square

scanf("%d",&x); | program exits without printing the square

printf("Calculate square?(Y/N):"); | program exits without printing the square

c=getchar(); | program exits without printing the square

if (c== 'Y'|| c== 'y') | program exits without printing the square

printf("sqr=%d",x*x); | program exits without printing the square


} | program exits without printing the square

What is size of an int ? | 16 bits

How is the integer pointer var declared in C? | int** x;

What is the output when the sample code below is executed ?

void foo(int x){ | 00123

if (x>0) foo(--x); | 00123

printf("%d",x); } | 00123

int main(){ | 00123

foo(4); | 00123

printf("\n"); | 00123

return 0; | 00123

} | 00123

How do you include a system header file called sysheader.h in a C source file ? | #include<sysheader.h>

What is the output when the sample code below is executed?

int i=0, j=0; | 01283

for(i=1;i<10,j<3;i*=2) { | 01283

printf("%d",j++); } | 01283

printf("%d%d",i,j); | 01283

What is the output when the sample code below is executed?


void show(int**b){ | 34 45 56

printf ("%d ",**b); } | 34 45 56

int main(){

int i; | 34 45 56

int a[] = { 23,34,45,56}; | 34 45 56

for(i=0;i<3;i++) show(&a[i]+1); | 34 45 56

return (0); | 34 45 56

} | 34 45 56

Which of the following is used to call a function named as doFun() | None of other choices

What is the output of the following program ? | 1

Which one is not the standard library in C? | system.h

Data is stored in computer memory in ......... Choose one answer. | binary format

Which of these statements about primary memory are not true? Choose at least one answer. | Only one
operation on primary memory and it is reading;ROM is a volatile memory.

(1) One byte consists of 4 nibbles. (2) One nibble consists of 2 consecutive bits. Choose at least one
answer. | (1): false ; (2): false

Which of these statements about fundamental unit in CPU is true? Choose one answer. | The natural
unit of the CPU is a word

Which of these definitions are true? Choose at least one answer.


Which of these statements about fundamental unit in CPU is true? Choose one answer. | The CPU
performs the operation on the values stored as operands or on the values stored in the operand
addresses;

Which of these statements about fundamental unit in CPU is true? Choose one answer. | The addresses
are either register names or primary memory addresses;

Which of these statements about fundamental unit in CPU is true? Choose one answer. | Each program
instruction consists of an operation and operands.

Comments of a program... | used for documenting a program;omitted by the compiler;enhance the


readability of a program.

Choose at least one answer. | are used for documenting a program ; are omitted by the compiler ;
enhance the readability of a program.

Select correct properties of C language. Choose at least one answer. | C source code must be translated
into executable code by a compiler;

Select correct properties of C language. Choose at least one answer. | C language is a functional
language;

Select correct properties of C language. Choose at least one answer. | C i s case sensitive language.

Select correct statements. Choose at least one answer. | An interpreter will iterate to translate each
statement of source code into machine code then CPU execute these binary code of this statement;

Select correct statements. Choose at least one answer. | Compiler of the language A can translate A-
source code into language B-source code then the B-language compiler will translate B-source code into
machine code.

....... helps identifying the device which will communiate with CPU. Choose at least one answer. | all

Which type qualifiers are defined in C? Choose at least one answer. | short ; long

-------------------------------------------------------------------------------------------------------------------------------------------
-----

In C, select correct statements. Choose at least one answer. | The expression x=y;will copy y to x;A
constant string must be enclosed by a pair of double quotes.
1. Intel use this little-endian ordering. 2. Motorola use middle-endian ordering. 3. Motorola use big-
endian ordering. 4. Intel use this big-endian ordering. Choose one answer. | e. 1, 3 true

Which of the following is an invalid identifier? Choose at least one answer. | employee salary ; +ab ; 45n

Which of these statements about constants are not true? Choose at least one answer. | The compiler
allocates memory for constants;The compiler compiles constants.

In C language, (1) The == operator is used for setting a value to a variable. (2) The = operator is used for
checking whether two numbers are equal or not. Choose at least one answer. | (2): false ; (1): false

Select correct statements. With respect to ASCII, .......... Choose at least one answer | Binary ASCII of A
01000001;Upcase less than Lowcase;Digit less than alphabet.

Select correct conversion specifiers for an int variable in C language. Choose at least one answer. | %o ;
%d ; %u

In C language, the selection constructs use ....... Choose at least one answer. | switch ; ?: ; if else

Suppose that the following codes are executed. What is the output?

long S=10; | 40

long i=1; | 40

while (i<=10) | 40

{ if (i%2==0) S+=i; | 40

i++;} | 40

printf("%ld", S); Choose one answer. | 40


Flags is a technique that supports using goto, continue statements. Choose one answer. | false

To improve readability, programmers are recommended .......Choose at least one answer. | using
whitespace to identify the logical structure of the code ; removing continue statements ; using break
statements as needed.

1. The rule in C is that an else statement always belongs to the innermost if available. 2. The rule in C is
that an else statement always belongs to the outermost if available. Choose one answer. | Only 1st
statement is true

Program should be written ... Choose at least one answer. | as a well program ; with a consistent style
and clear throughout.

Select correct statement(s). Choose at least one answer. | A table that contains all program variables is
used in walkthrough process ; Walkthrough is a manual process for recording all changes of program
variables when the program executes instruction-by-instruction ; A listing of the output, if any,
produced by the program is carried out when we do a walkthrough..

Suppose that the following codes execute and input data are 9 and 12.

int m,n; | -3

printf("Enter two integers:"); | -3

scanf("%d%d",&m, &n); | -3

if (m>10 && n<20) printf("%d", m+n); | -3

else printf("%d", m-n); What is the output. Choose one answer. | -3

Suppose that the following codes execute. What is the output?

long S=10; | None of the others

long i; | None of the others


for (i=1; i<10; i++) if (i%3==0) S+=i; | None of the others

printf("%ld", S); Choose one answer. | None of the others

In C, which of these statements are not true? Choose at least one answer. | #include "filename"using
with filename locate in system directory ; #include<>using with filename locate in user directory;# is a
symbol of postprocessor indicators

What is the output if the following code executes.

int n=3, m=7; | None of the others

int p1= &n, p2=&m; | None of the others

p1 -= m+n- 3(*p2); | None of the others

p2 += p1%2 ? 2 : 5; | None of the others

printf ("%d", m-n); Choose one answer. | None of the others

In C, incorrect order(s) of a function implementation: Choose at least one answer. | Return


type,body,function name,parameters;Return type,body,parameters,function name;Return
type,parameters,body,function name

Which of these statements about the function is true? Choose one answer. | A function may receive
data and may return a value

Select correct statement(s). Choose at least one answer. | Actual parameter is a parameter that is
transfered to a function when it is called ; Formal parameter is a parameter in function implementation.

Select the statements that belong to low cohesion. Choose at least one answer. | "logical" - related tasks
of which only one is performed - the module identifier suggests a choice ; "coincidental" - unrelated
tasks
In C, with reference to property of reusing a function, the function that will check whether an integer is
a prime or not, should be declared as ........ Choose one answer. | a function that will return an integer.

Study the following function:

int t (int x, int y, int z) | 10

{ return x+y+z>20 ? 10 : 20;} | 10

If this function is called as following with input data are 5 10 15. What is the output?

int a,b,c; | 10

printf("Enter 3 integers:"); | 10

scanf("%d%d%d", &a, &b, &c); | 10

printf("%d", t(b,c,a)); Choose one answer. | 10

Study the function implementation and a case of using this function.

int t (int x, int y) | 3

{ return x-y;} | 3

...

char c1= 'A', c2= 'D'; | 3

printf("%d", t(c2, c1)); | 3

Suppose that the above codes execute. What is the output? Choose one answer. | 3

Suppose that the following codes execute. What is the output.

int n=3, m=7; | 14

int p1= &n, p2=&m; | 14

p1 -= m+n- 3(*p2); | 14

*p2 += m-n; | 14

printf ("%d", m+n); Choose one answer. | 14


Which of these statements about the scanf function are true? Choose at least one answer. | interpreted
and processed the entire format string;scanf treats the whitespace between the input values as a
separator;If the buffer is empty,the function scanf will wait until the user adds more data values

Select incorrect statements. Choose at least one answer. | The specifier %hex is used for printing out an
integer in hexadecimal format;The specifier %u is used for printing out a unsigned integer;The specifier
%b is used to print out an integer in binary format.

The getchar function can do. Choose one answer. | None of the others

What library includes function to generate random numbers? Choose one answer. | stdlib.h

Validation do not include. Choose one answer. | None of the others

Which of these statements about format string are not true? Choose one answer. | None of the others

What is the output of the following program?

/ Suppose that all needed libraries are included /

int main() | 11

{ double x= 3.5, y= 6.8 , z= 1.5; | 11

int n= floor( x )+ ceil( y )+ z; | 11

printf("%d", n); | 11

getch(); | 11

return 1; | 11

} Choose one answer. | 11


/ Suppose that all needed libraries are included /

int main() | 12, 10

{ int n; | 12, 10

char c; | 12, 10

scanf("%d",&n); | 12, 10

c=getchar(); | 12, 10

printf("%d, %d", n,c); | 12, 10

getch(); | 12, 10

return 1; | 12, 10

What is the output of the above program if user enters the keys 12 and ENTER? Choose one answer. |
12, 10

/ Suppose that all needed libraries are included /

int main()

{ int n, m; | 1

int result = scanf("%d%d",&n, &m); | 1

printf("%d", result); | 1

getch(); | 1

return 1; | 1

What is the ouput of the above program if input is 12asd45 ? Choose one answer. | 1

/ Suppose that all needed libraries are included /

int main()

{ int n, m; | 9 and a non-predictable value.


scanf("%d,%d",&n, &m); | 9 and a non-predictable value.

printf("%d, %d", n, m); | 9 and a non-predictable value.

getch(); | 9 and a non-predictable value.

return 1; | 9 and a non-predictable value.

When the program executes, user enters 9 100 . What is output? Choose one answer. | 9 and a non-
predictable value.

Program .... Choose at least one answer. | is a simulation of solution ; is the result of a programming
process ; is a set of instructions that computer hardware will execute.

What are the right matching?

Character Sequence

a. Newline \t

b. vertical tab \v

c. backslash \

d. alarm \r

e. backspace \b

f. question mark \? Choose at least one answer. | f ; e ; b

Which of these statements about the array are true? Choose at least one answer. | An array is stored in
contiguously block of memory and each element is identified by its index;The index of an element can
be an integer variable, an integer expression or an integer constant;An array is a group of related
elements and they belong the same data type.

The linear search algorithm can be applied on an array in which its elements .......Choose at least one
answer. | are in descending order;are in ascending order.
Study the binary search algorithm:

int binarySearch (int x, int a[], int low, int high) | 4

{ while (low<=hight) | 4

{ int mid= (low+high)/2; | 4

if ( x==a[mid]) return mid ; | 4

else if (x>a[mid]) low=mid+1; | 4

else high=mid-1; | 4

return -1; | 4

Suppose that this function is used as following:

int a[6] = { 1, 2, 2, 3, 3,5}; | 4

int pos = binarySearch(3,a,0,5); | 4

What is the value of the variable pos? Choose one answer. | 4

Select correct statements. Choose at least one answer. | Flagging technique uses an integer for marking
elements of an array when we summarize data of the array;Flagging technique is used when we
summarize data in an array.

What are the names of search algorithm applied to an array? Choose at least one answer. | Linear
search;Binary search.

Study the following function:

Suppose that all needed libraries are included.

int search ( int x, int a[], int n) | 6

{ int i; | 6
for ( i=n-1; i>=0 ; i--) if (x==a[i]) return i; | 6

return -1; | 6

This function is used as following:

int a[10] = { 1, 2, 2, 2, 3, 3, 3, 4, 4, 4}; | 6

int pos = search(3, a, 10); | 6

When the above code executes, what is the value of the variable pos? Choose one answer. | 6

/ Suppose that all needed libraries are included /

int main()

{ int a[5]= { 1,2,3,4,5 };

int*p= a;

int i;

for (i=0;i<5; i++)

if (i%2==0)

{ (*p)++;

p++;

for (i=0;i<5;i++) printf("%d, ", a[i]);

getch();

return 1;

When the above program executes. What is the output? Choose one answer. | 2, 3, 4, 4, 5

/ Suppose that all needed libraries are included /


int main()

{ int a[5]= { 1,2,3,4,5 }; | None of the others.

int*p= a; | None of the others.

int i; | None of the others.

int S=10; | None of the others.

for (i=0;i<5; i++) | None of the others.

if (a[i]%2==0) S+=a[i]; | None of the others.

printf("%d", S); | None of the others.

getch(); | None of the others.

return 1; | None of the others.

The output of the program is ......Choose one answer. | None of the others.

/ Suppose that all needed libraries are included /

void f1 ( int*a, int n)

{ int i,j,t;

for (i=0;i<n-1;i++)

for (j=n-1; j>i; j--)

if (a[j]>a[j-1])

{ t=a[j];

a[j]=a[j-1];

a[j-1]=t;

void f2 (int a[], int n)


{ int i;

for (i=0;i<n;i++) printf ("%d%s ", a[i], (i<4 ? "," : "" ));

int main()

{ int a[5]= { 5, 1, 2,4, 3 }; | 5, 4 ,3 ,2 ,1

f1(a,5); | 5, 4 ,3 ,2 ,1

f2(a,5); | 5, 4 ,3 ,2 ,1

getch(); | 5, 4 ,3 ,2 ,1

return 1;} | 5, 4 ,3 ,2 ,1

The output of the program is ......Choose one answer. | 5, 4 ,3 ,2 ,1

With respect to the binary search algorithm on an array, ....... Choose one answer. | The values
contained in the array must be in an order (ascending or descending).

Which of these statements about the %s conversion specifier used in scanf function are true? | It will
read all characters until the first white space character;It is usually used when user will enter a word
such as the code of a product.

/ Suppose that all needed libraries are included /

void f(char S[ ], char c1, char c2) | ABCD

{ int L= strlen(S); | ABCD

int i; | ABCD

for (i=0; i<L; i++) | ABCD

if ((S+i) == c1) (S+i)=c2; | ABCD

int main()

{ char S[10]="ABCDEFGEH"; | ABCD


f( S, 'E', 0); | ABCD

printf("%s", S); | ABCD

getch(); | ABCD

return 1;} | ABCD

The output of the program is ...... Choose one answer. | ABCD

Which of these statements about null byte terminator are not true? Choose one answer. | We can
describe the null byte as the constant EOF.

Which of these statements about the %[^ ] specifier is true when it is used in the scanf function ?
Choose one answer. | The scanf function will store the characters read in memory locations starting
with the address passed to scanf

Which of the the following is the result of the %[abcd] conversion specifier when it is used in the scanf
function and the input is dfgh ? Choose one answer. | None of the others

Which is the result of strcmp(S1, S2) with S1 ="abcdefgh" and S2 = "abcdefdh"? Choose one answer. | A
positive integer.

/ Suppose that all needed libraries are included /

int main()

{ char S[50]= "ABCDEF";

printf("Length:%d, %s", strlen(S), &S[2]);

getch();

return 1;

The output of the program s ....... Choose one answer. | Length:6, CDEF
/ Suppose that all needed libraries are included /

int main()

{ char S1[50]= "ABCDEF";

char S2[50]= "GHI";

strcat(S1,S2);

printf("%s", S1);

getch();

return 1;

What is the output of the program? Choose one answer. | ABCDEFGHI

Study three following code segments:

(1)

char S[50]= "ABCD";

puts(S);

(2)

char S[50]= "ABCD";

printf("%s",S);

(3)

char S[50]= "ABCD";

printf("%s \n",S); Choose one answer. | (1) and (3) have the same output.

Suppose the string library was included. Study the following C-code:

char S1[10]="AB";
char S2[10]="AB1";

printf("%d, %d", strcmp(S1,S2), strcmp(S2,S1));

The output of the above code is: Choose one answer. | a negative and a positive integers.

The function fopen(...) is used for openning a text file. Which of the following mode parameters can not
be used? Choose at least one answer. | art ; RW

What in the following file operations should be used when the file closed only? Choose at least one
answer. | renaming a file ; remove a file.

Which of these statements about file format types are true? Choose at least one answer. | With text
format, the data on the file can be modified using a text editor ; With text format, data in a the file are
stored as ASCII code of characters.

In C, which of following functions can be used to write data to a file? Choose at least one answer. | fputc
; fgets ; fputs

Text format is used. Which of these statements about table, record, and fields are not true? Choose at
least one answer. | Typically, one table refers to one entity of information ; A new line delimiter must be
used to separate two adjacent fields of a record.

Select correct statements. Choose at least one answer. | We can rename a file if the file is
closed;Rewinding a file will move current position to the beginning of the file.

Suppose that a value of the int type will be stored in 4 bytes.

int n=7; | 1

In C, if this variable is written to a textfile (using ASCII code), it will take ... byte(s) in the file. Choose one
answer. | 1
Suppose that a value of the int type will be stored in 4 bytes.

int n=7; | 4

In C, if this variable is written to a binary file, it will take ... byte(s) in the file. Choose one answer. | 4

Select correct statement(s).

Suppose that a value of the int type will be stored in 4 bytes. | Writing int values into text file is less
efficient because type conversions are needed.

What guideline should be examined before working with a text file? | data format in the file must be
known or designed.

Which of these statements about the black-box testing are not true? Choose at least one answer. |
External factors,such as logic-driven,and path-oriented,are determinant;Each possible path through the
code is executed at least once. The number of possibilities to be tested may be too great;Synonyms for
black-box include:structural,glass-box and clear-box

d. External factors, such as testing to specifications, input-output driven, and data driven, are
determinant

Methods are used in testing a software are ......... Choose at least one answer. | White box testing ; Black
box testing

Which of these statements about comparing the difference of Waterfall and Open Source Model are
true? Choose one answer. | None of the others

Statement 1: If a program works then it is good designed.

Statement 2: If the program models a real world situation, it can be hardly upgraded. Choose one
answer. | Both of them are false.
Study the following steps in software development process.The correct order of them : |
Analysis;Design;Implementing;Deploying;Maintenance

The output of a program is incorrect. It may be caused by ...... Choose at least one answer. | the
algorithm is wrong ; a semantic error.

Analysis and maintenance are ............. phases in the sofware development process. Choose one answer.
| first and last

........software development model(s) has (have) some phases that are concurrently carried out. Choose
one answer. | Practical

Restricting our use of the language to the standard subset of a language will create the ......... of a
program. Choose one answer. | portability

What will be output when you will execute following c code?

#include<stdio.h>

#include<conio.h>

printf("%d\t", sizeof(6.5)); | 8 4 1

printf("%d\t", sizeof(90000)); | 8 4 1

printf("%d", sizeof('A')); | 8 4 1

getch();

Biết kích thước kiểu char : 1 byte, float : 4 byte, int : 4 byte, double : 8 byte, long : 4 byte. | 8 4 1

What will be output when you will execute following c code? | 1 4 5


double num = 5.2; | 1 4 5

int var = 5; | 1 4 5

printf("%d\t", sizeof(!num)); | 1 4 5

printf("%d\t", sizeof(var=15/2)); | 1 4 5

printf("%d", var); | 1 4 5

What value gets printed by the program below? | 0

int w = 3; | 0

int x = 31; | 0

int y = 10; | 0

double z = x / y % w; | 0

printf("%f\n", z); | 0

What will be output when you will execute following c code?

#include "stdio.h" | -6

int main()

char a = 250; | -6

int expr; | -6

expr= a + !a + ~a + ++a; | -6

printf("%d", expr); | -6

What will be output when you will execute following c code?

#include "stdio.h"

int a = -5; | Avatar

unsigned int b = -5u; // (*) | Avatar

if(a == b) | Avatar

printf("Avatar"); | Avatar
else

printf("Alien"); | Avatar

return 0; | Avatar

-----------------------

What will be output when you will execute following c code?

#include "stdio.h"

#include "conio.h"

void main()

int x = 3; | 8

printf("%d", x++ + ++x); | 8

getch(); | 8

7. What is output ?

#include "stdio.h"

#include "conio.h"

void main()

int i = 5, j = 6, k; | 4

k = i & j; | 4

printf("%d", k); | 4

getch(); | 4

}
8. What is output ?

#include "stdio.h"

#include "conio.h"

void main()

int i = 5,j = 6; | 7

printf("%d", i | j); | 7

getch(); | 7

9. What is output ?

#include "stdio.h"

#include "conio.h"

extern int x = 0; | 1

void main()

x++; | 1

printf("%d", x); | 1

getch(); | 1

}
10. What is output ?

#include "stdio.h"

#include "conio.h"

extern int x = 0; | 0

void main()

int x = 1; | 0

printf("%d", x); | 0

getch(); | 0

11. What is output ?

#include "stdio.h"

#include "conio.h"

int y = 0;

void main()

int x = 0; | ‘x’ undeclared identifier

x++; | ‘x’ undeclared identifier


++y; | ‘x’ undeclared identifier

printf("%d\t%d", x, y); | ‘x’ undeclared identifier

getch(); | ‘x’ undeclared identifier

12. Output of following code?

void main()

int x; | Error (code ko khai báo thư viện và biến x chưa đc tạo)

x++; | Error

printf("%d", x); | Error

getch(); | Error

13. Output of following code?

void main()

int x=0; | 0

int x = 0, y = 0; | 0

y++; | 0

x++; | 0
}

printf("%d", x); | 0

getch(); | 0

14. Output of following code?

void count() | 0123456789

static int page = 0; | 0123456789

printf("%d", page); | 0123456789

page++; | 0123456789

void main()

int i; | 0123456789

for(i = 0; i < 10; i++) | 0123456789

count(); | 0123456789

15. Output of following code?

const int x = 5; | 5

void main()

int x[x]; | 5

int y = sizeof(x) / sizeof(int); | 5

printf("%d", y); | 5

getch(); | 5
16. What is output?

#include "stdio.h"

int main()

int x = 5, y = 10, z = 15; | Garbage Garbage Garbage

printf("%d %d %d"); | Garbage Garbage Garbage

17. What is output?

#include "stdio.h"

int main()

asm | Complie error18.

mov bx, 8; | Complie error18.

mov cx,10 | Complie error18.

add bx, cx; | Complie error18.

printf("%d", _BX); | Complie error18.

18. What is output?

#include<stdio.h>

int main()

char *url="c:\tc\bin\rw.c"; | w.c in

printf("%s", url); | w.c in

return 0; | w.c in

19. What is output ?


#include<stdio.h>

int main()

const int i = 5; | Complier error

i++; | Complier error

printf("%d", i); | Complier error

return 0; | Complier error

20. What is output?

#include "stdio.h"

#include "conio.h"

void main()

char c = 125; | -121

c = c + 10; | -121

printf("%d", c); | -121

getch(); | -121

21. What is output?

#include "stdio.h"

#include "conio.h"

int main()

char c = 48; | 12480

int i, mask = 01; | 12480

for(i = 1; i <= 5; i++) | 12480

printf("%c", c|mask); | 12480

mask = mask << 1; | 12480


getch();

22. What is output?

#include <stdio.h>

#include <conio.h>

int main()

float a = 0.7; | Hi

if(0.7 > a){ printf("Hi\n");} | Hi

else printf("Hello\n"); | Hi

-----------------------------------

1. What value is returned by function func()?

float func() | Exception

int r = 0, d = 0, i=0; | Exception

for (i; i < 2; i++){r += 5 / d;} | Exception

return r; | Exception

2. What will be output when you will execute following c code?

void main() | mmmm aaaa nnnn

char s[] = "man"; | mmmm aaaa nnnn

int i; | mmmm aaaa nnnn

for(i = 0; s[i]; i++) | mmmm aaaa nnnn

printf("%c%c%c%c\t", s[i], *(s+i), *(i+s), i[s]); | mmmm aaaa nnnn

getch(); | mmmm aaaa nnnn

3. What will be output when you will execute following c code?


void main()

int i = 0; | AAAAAABCDEF

char ch = 'A'; | AAAAAABCDEF

do{putchar(ch);} | AAAAAABCDEF

while(i++ < 5 || ++ch <= 'F'); | AAAAAABCDEF

getch(); | AAAAAABCDEF

4. What gets printed?

void main() | 6

int array[2][2] = {0, 1, 2, 3}; | 6

int i; | 6

int sum = 0; | 6

for (i = 0; i < 4; ++i) | 6

int x, y; | 6

x = i % 2; | 6

if (x){y = 0;} | 6

else{y = 1;} | 6

sum += array[x][y]; | 6

printf("%d\n", sum); | 6

getch(); | 6

}
5. What is output?

#include <stdio.h>

#include <conio.h>

void main()

int k; | Nothing

for (k = -3; k < -5; k++) | Nothing

printf("Hello"); | Nothing

getch(); | Nothing

6. What is output?

void main()

double k = 0; | 3

for (k = 0.0; k < 3.0; k++); | 3

printf("%lf", k); | 3

getch(); | 3

7. What is output?

#include <stdio.h>

int main()
{

int i = 0; | Complie time error

for (; ; <img draggable="false" class="emoji" alt=" "


src="http://s.w.org/images/core/emoji/72x72/1f609.png"> | Complie time error

printf("In for loop\n"); | Complie time error

printf("After loop\n"); | Complie time error

8. What is output?

#include <conio.h>

#include <stdio.h>

int foo();

void main()

int i = 0; | After loop

for (foo(); i == 1; i = 2) | After loop

printf("In for loop\n"); | After loop

printf("After loop\n"); | After loop

getch(); | After loop

int foo() | After loop

return 1; | After loop

9. What is output?
#include <conio.h>

#include <stdio.h>

int main()

int i = 0; | False

while (i = 0) | False

printf("True\n"); | False

printf("False\n"); | False

getch(); | False

10. What is output ?

#include <conio.h>

#include <stdio.h>

int main()

int i = 0, j = 0; | 10, 10

while (i < 5, j < 10) | 10, 10

i++; | 10, 10

j++; | 10, 10

printf("%d, %d\n", i, j); | 10, 10

getch(); | 10, 10
}

11. What is output?

#include <conio.h>

#include <stdio.h>

int main()

int a = 0, i = 0, b = 0 ; | a = 5,b = 0

for (i = 0; i < 5; i++) | a = 5,b = 0

a++; | a = 5,b = 0

continue; | a = 5,b = 0

b++; | a = 5,b = 0

printf("\n a = %d,b =%d", a, b); | a = 5,b = 0

getch(); | a = 5,b = 0

12. What is output ?

void main()

int i = 0; | Hello

for (i = 0; i < 5; i++) | Hello

if (i < 4) | Hello
{

printf("Hello"); | Hello

break; | Hello

getch(); | Hello

13. What is output?

#include <stdio.h>

#include <conio.h>

void main()

int i = 0; | 1 2 3

for(; i <= 2; ) | 1 2 3

printf(" %d", ++i); | 1 2 3

getch();

14. What is output ?

#include <stdio.h>

#include <conio.h>

void main()

int x; | 6

for(x = 1; x <= 5; x++); | 6


printf("%d", x); | 6

getch(); | 6

15. What is output?

#include <stdio.h>

#include <conio.h>

int main()

int i = 3; | 99 99 99

while (i--) | 99 99 99

int i = 100; | 99 99 99

i--; | 99 99 99

printf("%d ", i); | 99 99 99

getch(); | 99 99 99

16. How many times will “vncoding” is printed on screen?

#include <stdio.h>

#include <conio.h>

int main()
{

int i = 1024; | 10

for (; i; i >>= 1) | 10

printf("\nvncoding"); | 10

getch(); | 10

17. What is output?

#include<stdio.h>

#include <conio.h>

void main()

int i = 2, j = 2; | 1

while(i+1? --i : j++) | 1

printf("%d", i); | 1

getch(); | 1

18. What is output?

#include<stdio.h>

#include <conio.h>

void main()
{

int i, j; | 1 3

i = j = 2; | 1 3

while(--i&&j++) | 1 3

printf("%d %d", i, j); | 1 3

getch(); | 1 3

19. What is output?

#include <stdio.h>

#include <conio.h>

int main()

int x = 011, i; | Start Start Start

for(i = 0; i < x; i += 3) | Start Start Start

printf("Start "); | Start Start Start

continue; | Start Start Start

printf("End"); | Start Start Start

getch(); | Start Start Start

}
20. What is output of the following code?

#include <stdio.h>

#include "conio.h"

void main()

int s = 0; | 4 5 6 7 8 9 10

while (s++ < 10) | 4 5 6 7 8 9 10

if (s < 4 && s < 9) | 4 5 6 7 8 9 10

continue; | 4 5 6 7 8 9 10

printf(" %d ", s); | 4 5 6 7 8 9 10

getch(); | 4 5 6 7 8 9 10

----------------------------------------

1. What gets printed?

void main()

int i = 3; | 6

if (!i) | 6
i++; | 6

i++; | 6

if (i == 3) | 6

i += 2; | 6

i += 2; | 6

printf("%d\n", i); | 6

getch(); | 6

2. What gets printed?

void main()

int x; | Value of x is not 0

if(x = 0) printf ("Value of x is 0"); | Value of x is not 0

else printf ("Value of x is not 0"); | Value of x is not 0

getch(); | Value of x is not 0

3. What gets printed?

void main()

int i; | 16,21,

for(i = 0; i < 20; i++) | 16,21,

{
switch(i) | 16,21,

case 0:i+=5; | 16,21,

case 1:i+=2; | 16,21,

case 5:i+=5; | 16,21,

default: i+=4; | 16,21,

break; | 16,21,

printf("%d,", i); | 16,21,

4. What gets printed ?

void main()

static int i; | -1

while(i <= 10&&i >= 0) | -1

(i > 2 ? i++ : i--); | -1

printf("%d", i); | -1

getch(); | -1

5. What is output ?

void main() | Hello

int i = 10, j = 20; | Hello


if(i = 20) printf(" Hello"); | Hello

else printf(" Hi"); | Hello

getch(); | Hello

6. What is output?

void main() | x=0 y=0

int x = 0, y = 0; | x=0 y=0

if(x == 0 || ++y) printf("x=%d", x); | x=0 y=0

printf(" y=%d", y); | x=0 y=0

getch(); | x=0 y=0

7. What is output?

void main() | 5Hey

int i = 5, k; | 5Hey

if (i == 0) goto label; | 5Hey

label: printf("%d", i); | 5Hey

printf("Hey"); | 5Hey

getch(); | 5Hey

}
8. What is output?

void main() | 1 4

printf("%d ", 1); | 1 4

goto l1; | 1 4

printf("%d ", 2); | 1 4

l1:goto l2; | 1 4

printf("%d ", 3); | 1 4

l2:printf("%d ", 4); | 1 4

getch(); | 1 4

9. What is output?

#include <conio.h>

#include <stdio.h>

void foo(); | Complie error

int main() | Complie error

printf("%d ", 1); | Complie error

goto l1; | Complie error

printf("%d ", 2); | Complie error

void foo() | Complie error


{

l1: printf("3 "); | Complie error

10. What is output?

#include <conio.h>

#include <stdio.h>

int main()

int i = 0, j = 0; | Infinite loop

while (i < 2) | Infinite loop

l1: i++; | Infinite loop

while (j < 3) | Infinite loop

printf("loop\n"); | Infinite loop

goto l1; | Infinite loop

11. What is output?

void main()

int i = 0, j = 0; | Complie error

while (l1: i < 2) | Complie error


{

i++;

while (j < 3) | Complie error

printf("loop\n"); | Complie error

goto l1; | Complie error

getch();

12. What is output?

void main()

int a = 15, b = 10, c = 5; | False

if(a > b > c) printf("True"); | False

else printf("False"); | False

getch();

13. What is output?

#include <stdio.h>

#include <conio.h>

void main()
{

int i = 0;ABC

switch (i)ABC

case '0': printf("A");ABC

break;

case '1': printf("B");ABC

break;

default: printf("ABC");ABC

getch();

14. What is output?

#include <stdio.h>

#include "conio.h"

void main()

int i = 3; | B

switch (i) | B

case 0+1: printf("A"); | B

break; | B

case 1+2: printf("B"); | B


break;

default: printf("ABC"); | B

getch();

15. What is output?

#include <stdio.h>

#include <conio.h>

#define A 0

#define B 1

int main()

int i = 3; | TRUE

switch (i & 1) | TRUE

case A: printf("FALSE"); | TRUE

break;

case B: printf("TRUE"); | TRUE

break;

default: printf("Default"); | TRUE

getch();

}
16. What is output?

#include <stdio.h>

#include <conio.h>

int main()

int i; | TRUE

if (printf("0")) i = 3; | TRUE

else i = 5; | TRUE

printf("%d", i); | TRUE

getch();

17. What is output?

#include<stdio.h>

#include <conio.h>

int main()

int a = 5; | 5

switch(a) | 5

default: | 5

a = 4; | 5

case 6: | 5
a--; | 5

case 5:

a = a + 1; | 5

case 1:

a = a - 1; | 5

printf("%d \n", a); | 5

getch();

18. What is output?

#include <stdio.h>

#include <conio.h>

int main()

int x = 3; | x = 2

if (x == 2); x = 0; | x = 2

if (x == 3) x++; | x = 2

else x += 2; | x = 2

printf("x = %d", x); | x = 2

getch();

19. What is output?


#include <stdio.h>

#include <conio.h>

int main()

int check = 20, arr[] = {10, 20, 30}; | Complier Error

switch (check) | Complier Error

case arr[0]: printf("A "); | Complier Error

case arr[1]: printf("B"); | Complier Error

case arr[2]: printf("C"); | Complier Error

getch();

20. What is output of code?

void main()

if ((1 || 0) && (0 || 1)) | ABC

printf("ABC"); | ABC

else

printf("DEF"); | ABC

}
getch();

---------------------------------------

1. What is the correct value to return to the operating system upon the successful completion of a
program? 0

2. What is the only function all C programs must contain? | main()

3. What punctuation is used to signal the beginning and end of code blocks? | { }

4. What punctuation ends most lines of C code? | ;

5. Which of the following is a correct comment? | /* Comment */

6. Which of the following is not a correct variable type? | real

7. Which of the following is the correct operator to compare two variables? | ==

8. Which of the following is true? | All of the above

9. Which of the following is the boolean operator for logical-and? | &&

10. Evaluate !(1 && !(0 || 1)) | True

11. Which of the following shows the correct syntax for an if statement? | if ( expression )
12. What is the final value of x when the code is run? | 10

int x; | 10

for(x = 0; x < 10; x++) { } | 10

13. When does the code block following while(x<100) execute? | When x is less than one hundred

14. Which is not a loop structure? | repeat until

15. How many times is a do while loop guaranteed to loop? | 1

16. Which is not a proper prototype? | double funct(char x)

17. What is the return type of the function with prototype: “int func(char x, float v, double t);” | int

18. Which of the following is a valid function call (assuming the function exists)? | funct();

19. Which of the following is a complete function? | int funct(int x) {return x=x+1;}

20. Which follows the case statement? | :

21. What is required to avoid falling through from one case to the next? | break;

22. What keyword covers unhandled possibilities? | default

23. What is the result of the following code?


#include "stdio.h"

void main()

int x = 0; | ZeroHello World

switch(x) | ZeroHello World

case 1: printf( "One" ); | ZeroHello World

case 0: printf( "Zero" ); | ZeroHello World

case 2: printf( "Hello World" ); | ZeroHello World

24. Which of the following is the proper declaration of a pointer? | int *x;

25. Which of the following gives the memory address of integer variable a? | &a

26. Which of the following gives the memory address of a variable pointed to by pointer a? | a;

27. Which of the following gives the value stored at the address pointed to by pointer a? | *a;

28. Which of the following is the proper keyword or function to allocate memory in C? | malloc

29. Which of the following is the proper keyword or function to deallocate memory in C language? |
delete
30. Which of the following accesses a variable in structure b? | b.var;

31. Which of the following accesses a variable in a pointer to a structure, *b? | b→var;

32. Which of the following is a properly defined struct? | struct a_struct {int a;};

33. Which properly declares a variable of struct foo? | struct foo var;

34. Which of the following correctly declares an array? | int arr[10];

35. What is the index number of the last element of an array with 29 elements? | 28

36. Which of the following is a two-dimensional array? | int arr[20][20];

37. Which of the following correctly accesses the seventh element stored in foo, an array with 100
elements? | foo[6];

38. Which of the following gives the memory address of the first element in array arr, an array with 100
elements? | arr;

39. Which of the following is a string literal? | “Static String”

40. What character ends all strings? | ‘\0’

41. Which of the following reads in a string named x with one hundred characters? | fgets(x, 100, stdin);
42. Which of the following functions compares two strings? | strcmp();

43. Which of the following adds one string to the end of another? | strcat();

1. What is output ?

#include "stdio.h"

#include "conio.h"

#include "string.h" | hello_World

#include "stdlib.h" | hello_World

void myfunc(char** param) | hello_World

++param; | hello_World

void main()

char* string = (char*)malloc(64); | hello_World

strcpy(string, "hello_World"); | hello_World

myfunc(&string); | hello_World

myfunc(&string);

printf("%s\n", string); | hello_World

getch();

2. What is output?

void myfunc(char** param) | llo_World


{

++*param; | llo_World

void main()

char* string = (char*)malloc(64); | llo_World

strcpy(string, "hello_World"); | llo_World

myfunc(&string); | llo_World

myfunc(&string);

printf("%s\n", string); | llo_World

getch();

3. What is output?

void main()

int ints[] = { 0, 1, 2, 3 }; | 4

int* i1 = ints + 1; | 4

int a = ++*i1; | 4

int b = a + *i1; | 4

printf("%d\n", b); | 4

getch();

}
4. What is output?

void main() | 10#15

int ints[] = { 0, 5, 10, 15 }; | 10#15

int* i2 = ints + 2; | 10#15

int a = *i2++; // a = *(i2++); | 10#15

printf("%d#%d\n", a, *i2); | 10#15

getch();

5. What is output of following code?

void main() | 4#5

int ints[] = { 0, 1, 2, 3 }; | 4#5

int* i1 = ints + 1; | 4#5

int* i2 = ints + 2; | 4#5

int a = ++*i1 + *i2++; | 4#5

int b = *++i1 + *i2--; | 4#5

printf("%d#%d", a, b); | 4#5

getch();

6. What is output of following code?

void main()
{

int i = 400; | 400 2

int *ptr = &i; | 400 2

*++ptr = 2; | 400 2

printf("%d %d", i, *ptr); | 400 2

getch();

7. What is output?

void main()

char str[] = {"pvpit"}; | v

char *s1 = str; | v

s1++; | v

printf("%c", *s1); | v

getch();

8. What is output?

void main()

char *s = "\12345s\n"; | 5

printf("%d", strlen(s)); | 5

printf("\n%s", s); | 5
getch(); | 5

9. For the code below which lines should be reported as errors by a compiler?

int main(int argc, char** argv) | 3

const char* foo = "wow"; // line 1 | 3

foo = "top"; // line 2 | 3

foo[0] = 1; // line 3 | 3

return 0; | 3

10. What is output?

void main()

int x = 5,y = 6; | Complier error

int* const p = &x; | Complier error

p = &y; | Complier error

printf("%d", (*p)); | Complier error

getch();

11. What is output?

void main()
{

int x = 5, y = 8; | 8

const int* p; | 8

p = &x; | 8

p = &y; | 8

x++; | 8

printf("%d", *p); | 8

getch();

12. What is output of code?

void main()

int x = 5; | Complier Error

const int* p; | Complier Error

p = &x; | Complier Error

x++;

*p = 4; | Complier Error

printf("%d", *p); | Complier Error

getch();

13. What is output of code?


#include <stdio.h>

int main()

int a = 320; | 64

char *ptr; | 64

ptr = (char*)&a; | 64

printf("%d ", *ptr); | 64

return 0; | 64

14. What will be output of following program?

#include <stdio.h>

int main()

int i = 3; | Address of j , Address of i , 3

int *j; | Address of j , Address of i , 3

int **k; | Address of j , Address of i , 3

j = &i; | Address of j , Address of i , 3

k = &j; | Address of j , Address of i , 3

printf("%u , %u , %d ", k, *k, **k); | Address of j , Address of i , 3

return 0;

}
15. What will be output of following program?

#include <stdio.h>

#include <conio.h>

#include <string.h>

int main()

char *ptr1 = NULL; | Error

char *ptr2 = 0; | Error

printf("\n%d", ptr2); | Error

strcpy(ptr1, "c"); | Error

strcpy(ptr2, "questions"); | Error

printf("\n%s %s", ptr1, ptr2); | Error

getch();

16. What will be output of following program?

#include<stdio.h>

#include<conio.h>

int main()

int a = 10; | Lỗi tại dòng int *ptr = p;

void *p = &a; | Lỗi tại dòng int *ptr = p;

int *ptr = p; | Lỗi tại dòng int *ptr = p;


printf("%u\n", *ptr); | Lỗi tại dòng int *ptr = p;

getch();

18. What will be output of following program?

#include <stdio.h>

#include <conio.h>

int main()

int i = 5, j; | 5 5

int *p , *q; | 5 5

p = &i; | 5 5

q = &j; | 5 5

j = 5; | 5 5

printf("%d %d", *p, *q); | 5 5

getch();

19. What will be output of following program?

#include<stdio.h>

#include<conio.h>

void main()
{

int i = 5; | Address of i Address of i

int *p; | Address of i Address of i

p = &i; | Address of i Address of i

printf(" %u %u", *&p , &*p); | Address of i Address of i

getch();

You might also like