Professional Documents
Culture Documents
C Source
C Source
#include<stdio.h> | 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.
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.
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
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
what is the output when the sample code below is executed? | How ae you
scanf("%5[^\]",st); | pfc i
printf("%s",st); | 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}}
int x=011|0x10; | 25
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
for(;i;) | nothing
if(i>0) | nothing
#include<stdio.h> | 65 65
void main(){ | 65 65
int i,j=25; | 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
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
what will be printed when the sample code below is executed? | 56789 0123456789
#include<stdio.h>
main(){
FILE *fi;
fi=fopen("myfile.c","r");
if(fi=NULL)
exit(1);}
else
int a=1; | 8
int i=7; | 8
if(a||i++) | 8
i++; | 8
printf("%d",i); | 8
referring to the sample code below, what value will the variable counter have when completed
while(x-1){ | 2
++counter; | 2
x--;} | 2
the operation between float and int would give the result as | none of the above
int k=0x55; | 85
printf("\n%d",k); | 85
printf("\n"); | 85
int x,y; | 19 19
x=a+b; | 19 19
y=a*b; | 19 19
return(x+y);} | 19 19
int main(){ | 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
while(x>10){
a[x%10-1]++;
x/=10;}
printf("%d",a[1]); | 2
printf("%.0f:%.0f\n",ceil(x), ceil(y));
if(a==b)
else(a<b)
else
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
A comment can be split over more than one line, as follows | true
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
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
what is the output when the sample code below is executed? main() | 1
{int i=5; | 1
printf("%d\n",i=++i==6) | 1
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
int a=2; | 3
printf("%d",++a,a+5) | 3
what is printed? | 3
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
break; | 1 2 3
break; | 1 2 3
break; | 1 2 3
}|123
If the program completes executing successfully, what value should the function main returned? | 0
What does the following declaration mean ( If there are more than one correct answer, choose the best
one)
___ 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()
i++; | -128
printf("%d",i); | -128
return 0; | -128
} | -128
printf("s=%d\n",sum(5)); | s=15
return 0; | s=15
s=0; | s=15
return(s); | s=15
} | s=15
float j; | 1000000
j=1000*1000; | 1000000
printf("%3.0f",j); | 1000000
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 can be used to append one string at the end of another ? | strcat
int i; | 4
i= 1; | 4
i = i+ 2*i ++; | 4
printf("%d",i); | 4
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.
#include<stdio.h>
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.
int s=0;
s=s+i;
if (s>=6) break;
s=s+1;
printf("%d\n",s); | 8
#include<stdlib.h>
#include<stdio.h>
int main(){
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 ?
if (c== 'Y'|| c== 'y') | program exits without printing the square
printf("%d",x); } | 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>
for(i=1;i<10,j<3;i*=2) { | 01283
printf("%d",j++); } | 01283
printf("%d%d",i,j); | 01283
int main(){
int i; | 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
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 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.
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
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
scanf("%d%d",&m, &n); | -3
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
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.
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
{ return x-y;} | 3
...
Suppose that the above codes execute. What is the output? Choose one answer. | 3
p1 -= m+n- 3(*p2); | 14
*p2 += m-n; | 14
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
Which of these statements about format string are not true? Choose one answer. | None of the others
int main() | 11
printf("%d", n); | 11
getch(); | 11
return 1; | 11
{ int n; | 12, 10
char c; | 12, 10
scanf("%d",&n); | 12, 10
c=getchar(); | 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
int main()
{ int 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
int main()
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.
Character Sequence
a. Newline \t
b. vertical tab \v
c. backslash \
d. alarm \r
e. backspace \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:
{ while (low<=hight) | 4
else high=mid-1; | 4
return -1; | 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.
{ int i; | 6
for ( i=n-1; i>=0 ; i--) if (x==a[i]) return i; | 6
return -1; | 6
When the above code executes, what is the value of the variable pos? Choose one answer. | 6
int main()
int*p= a;
int i;
if (i%2==0)
{ (*p)++;
p++;
getch();
return 1;
When the above program executes. What is the output? Choose one answer. | 2, 3, 4, 4, 5
The output of the program is ......Choose one answer. | None of the others.
{ int i,j,t;
for (i=0;i<n-1;i++)
if (a[j]>a[j-1])
{ t=a[j];
a[j]=a[j-1];
a[j-1]=t;
for (i=0;i<n;i++) printf ("%d%s ", a[i], (i<4 ? "," : "" ));
int main()
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
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.
int i; | ABCD
int main()
getch(); | 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.
int main()
getch();
return 1;
The output of the program s ....... Choose one answer. | Length:6, CDEF
/ Suppose that all needed libraries are included /
int main()
strcat(S1,S2);
printf("%s", S1);
getch();
return 1;
(1)
puts(S);
(2)
printf("%s",S);
(3)
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";
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.
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
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 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
#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
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
int w = 3; | 0
int x = 31; | 0
int y = 10; | 0
double z = x / y % w; | 0
printf("%f\n", z); | 0
#include "stdio.h" | -6
int main()
char a = 250; | -6
int expr; | -6
expr= a + !a + ~a + ++a; | -6
printf("%d", expr); | -6
#include "stdio.h"
if(a == b) | Avatar
printf("Avatar"); | Avatar
else
printf("Alien"); | Avatar
return 0; | Avatar
-----------------------
#include "stdio.h"
#include "conio.h"
void main()
int x = 3; | 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
#include "stdio.h"
#include "conio.h"
int y = 0;
void main()
void main()
int x; | Error (code ko khai báo thư viện và biến x chưa đc tạo)
x++; | Error
getch(); | Error
void main()
int x=0; | 0
int x = 0, y = 0; | 0
y++; | 0
x++; | 0
}
printf("%d", x); | 0
getch(); | 0
page++; | 0123456789
void main()
int i; | 0123456789
count(); | 0123456789
const int x = 5; | 5
void main()
int x[x]; | 5
printf("%d", y); | 5
getch(); | 5
16. What is output?
#include "stdio.h"
int main()
#include "stdio.h"
int main()
#include<stdio.h>
int main()
return 0; | w.c in
int main()
#include "stdio.h"
#include "conio.h"
void main()
c = c + 10; | -121
getch(); | -121
#include "stdio.h"
#include "conio.h"
int main()
#include <stdio.h>
#include <conio.h>
int main()
float a = 0.7; | Hi
else printf("Hello\n"); | Hi
-----------------------------------
return r; | Exception
int i = 0; | AAAAAABCDEF
do{putchar(ch);} | AAAAAABCDEF
getch(); | AAAAAABCDEF
void main() | 6
int i; | 6
int sum = 0; | 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
printf("Hello"); | Nothing
getch(); | Nothing
6. What is output?
void main()
double k = 0; | 3
printf("%lf", k); | 3
getch(); | 3
7. What is output?
#include <stdio.h>
int main()
{
8. What is output?
#include <conio.h>
#include <stdio.h>
int foo();
void main()
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
#include <conio.h>
#include <stdio.h>
int main()
int i = 0, j = 0; | 10, 10
i++; | 10, 10
j++; | 10, 10
getch(); | 10, 10
}
#include <conio.h>
#include <stdio.h>
int main()
int a = 0, i = 0, b = 0 ; | a = 5,b = 0
a++; | a = 5,b = 0
continue; | a = 5,b = 0
b++; | a = 5,b = 0
getch(); | a = 5,b = 0
void main()
int i = 0; | Hello
if (i < 4) | Hello
{
printf("Hello"); | Hello
break; | Hello
getch(); | Hello
#include <stdio.h>
#include <conio.h>
void main()
int i = 0; | 1 2 3
for(; i <= 2; ) | 1 2 3
getch();
#include <stdio.h>
#include <conio.h>
void main()
int x; | 6
getch(); | 6
#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
getch(); | 99 99 99
#include <stdio.h>
#include <conio.h>
int main()
{
int i = 1024; | 10
for (; i; i >>= 1) | 10
printf("\nvncoding"); | 10
getch(); | 10
#include<stdio.h>
#include <conio.h>
void main()
int i = 2, j = 2; | 1
printf("%d", i); | 1
getch(); | 1
#include<stdio.h>
#include <conio.h>
void main()
{
int i, j; | 1 3
i = j = 2; | 1 3
while(--i&&j++) | 1 3
getch(); | 1 3
#include <stdio.h>
#include <conio.h>
int main()
}
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
continue; | 4 5 6 7 8 9 10
getch(); | 4 5 6 7 8 9 10
----------------------------------------
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
void main()
void main()
int i; | 16,21,
{
switch(i) | 16,21,
break; | 16,21,
void main()
static int i; | -1
printf("%d", i); | -1
getch(); | -1
5. What is output ?
getch(); | Hello
6. What is output?
7. What is output?
int i = 5, k; | 5Hey
printf("Hey"); | 5Hey
getch(); | 5Hey
}
8. What is output?
void main() | 1 4
goto l1; | 1 4
l1:goto l2; | 1 4
getch(); | 1 4
9. What is output?
#include <conio.h>
#include <stdio.h>
#include <conio.h>
#include <stdio.h>
int main()
void main()
i++;
getch();
void main()
getch();
#include <stdio.h>
#include <conio.h>
void main()
{
int i = 0;ABC
switch (i)ABC
break;
break;
default: printf("ABC");ABC
getch();
#include <stdio.h>
#include "conio.h"
void main()
int i = 3; | B
switch (i) | B
break; | B
default: printf("ABC"); | B
getch();
#include <stdio.h>
#include <conio.h>
#define A 0
#define B 1
int main()
int i = 3; | TRUE
break;
break;
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
getch();
#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
getch();
#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
getch();
#include <conio.h>
int main()
getch();
void main()
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
3. What punctuation is used to signal the beginning and end of code blocks? | { }
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
13. When does the code block following while(x<100) execute? | When x is less than one hundred
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;}
21. What is required to avoid falling through from one case to the next? | break;
void main()
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;
35. What is the index number of the last element of an array with 29 elements? | 28
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;
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"
++param; | hello_World
void main()
myfunc(&string); | hello_World
myfunc(&string);
getch();
2. What is output?
++*param; | llo_World
void main()
myfunc(&string); | llo_World
myfunc(&string);
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?
getch();
getch();
void main()
{
*++ptr = 2; | 400 2
getch();
7. What is output?
void main()
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?
foo[0] = 1; // line 3 | 3
return 0; | 3
void main()
getch();
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();
void main()
x++;
*p = 4; | Complier Error
getch();
int main()
int a = 320; | 64
char *ptr; | 64
ptr = (char*)&a; | 64
return 0; | 64
#include <stdio.h>
int main()
return 0;
}
15. What will be output of following program?
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main()
getch();
#include<stdio.h>
#include<conio.h>
int main()
getch();
#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
getch();
#include<stdio.h>
#include<conio.h>
void main()
{
getch();