Documente Academic
Documente Profesional
Documente Cultură
PROGRAMMING
Section 1.
--------1. To display the contents of a executable file the
following command can be used
(a) cat (b) od (c) vi
(d) ed
ans : b
2. Assume the current directory contains 10 files and
does'nt
contain 'temp'. What will be the output of the follwing
commands?
$ls > temp
$wc -l temp
(a) 9 (b) 10 (c) 11 (d) undefined.
ans : b
3. If one wants the output of one command( command1) to be
printed inthe printer as well as to be added to another file
(outfile) which one of the following is a currect command he
can give?
(a) $command1 >>outfile|tee lpr
(b) $tee -a command1 | lpr
(c) $ command1 | tee outfile | lpr
(d) $ command | tee -a outfile |lpr
ans : d
(4) In the shell program set -x will cause
A. Execution of the commands in the background
B. Execution of the commands in verbose mode
C. Exit from the shell program.
D. Exit from the shell program after executing the next
command
(5)
A.
B.
C.
D.
(6)
The command echo*
A. will print * on the screen
B. will print contents of all the files in the current
directory
C. will list the files in the current directory
D.
will print the contents of all shell variables
(7)
ls || date will
A. print the name of the files in the current directory
B. print today's date and time
C. (A) followed by (B)
D. none of the above
(8) The built-in shell variable $$ refers to
A.
printing numbers in dollar format
B.
proces id_ of last command
C.
proces id_ of last background command issued
D.
proces-id of current shell
(9)
A.
B.
C.
D.
SCCS is a
SECTION 2:
1)study the following program
#define MAX(x,y) ((x)>(y)?(x):(y)
main()
{
intx=5,y=5;
printf("maximum is %d",MAX(++x,++y));
}
the outpput of the programis
a)maximum is 7 (b)maximum is 5 (c)maximum is 6
d)none of the above
2)given the following definitions
int *p,*q,r;
int values[30];
p=&values[0];
q=values+29;
r=++q-p;
what will be the value of r ?
a)address of q minus p
b)number of elements in the array
c)(value pointed by q)+1-(value pointed by p)
d)none of the above
3)what will the output of the program?
#include<stdio.h>
//print the sum of the series 1/5+1/4+....
static int =5;
main()
{
int sum=0;
do
{
sum+=(1/i);
}while(0<i--);
printf("sum of the series is %d",sum);
}
a)it will print the sum of the series 1/5+1/4+....+1/1
b)it will produce a compolation error
c)it will produce a runtime error
d)none of the above
#include<stdio.h>
main()
{
intoldvar=80;newvar=-80;
int swap(int,int);
swap(oldvar,newvar);
printf("numbers are %d\t%d",newvar ,oldvar);
}
int swap(intolval,int neval)
{
int temval=olval;
olval=neval;
neval=temval;
}
the output of the program is
a)numbers are 80-80
b)numbers are 80 80
c)numbers are -80 80
d)numbers are -80 -80
5) STUDY THE PROGRAM BELOW, WHICH OF THE FOLLOWING STATEMENT
WILL MAKE PROGRAM WORK :main ()
{
int *! = 10 , *j=20;
i=i*j;
}
A)
B)
C)
D)
6
Study the following program
#include<stdio.h>
enum mode = {green,red,orange,blue ,white};
main ()
{
green = green +!;
printf("%d,%d",green,red );
}
The output of the program will be :A)
d)
1,1
B) 0,1
C)
None of the above
C) Compilation
B) 2,104
D)
2,4
12) If
i = i * 16;
Which of the following is a better approach to do the
operation
A) Multiply i by 16 and keep it
B) Shift left by 4 bits
C) Add i 16 times
D) None of the above
C) Cannot be defined
15) Assuming that you are using IBM PC ,you have to a file
of 128 intergers into a character array of 256 characters .
Which statement you use ?
char buf[256];
int word[128]'
int i;
i varies from 0 to 255 in steps of 2
a)
b)
c)
d)
word[i]=buf[i+1]*0x100 + buf[i];
word[i]=buf[i]*0x100 +buf[i+1];
word[i/2] = buf[i] *0x100 + buf[i+1];
word[i/2]=buf[i+1]*0x100 +buf[i];
b) 6,6,7
c)
7,6,5
d)
6,5,6
17) For the following code how many times the printf
function is executed
int i,j ;
for(i=0;i<=10;i++);
for(j=0;j<=10;j++);
printf("i=%d,j=%d\n",i,j);
a)121
b) 11
c) 10
d)
b) 4 C) 29
p = 0, q =1;
q++;
++q;
q--;
--q;
D)
1,2
b) 2516941
C)
9162514
D)
1491625
Reasoning Section:
1. Helmet:Head::?
ans: Breakplate:chest
2. Writer:Pen::?
3. cargo:lorry::?
ans:Carpenter:Saw