Go Back   StudyChaCha 2024 2025 > StudyChaCha Discussion Forum > General Topics

  #2  
Old May 31st, 2014, 06:02 PM
Sashwat's Avatar
Super Moderator
 
Join Date: Jun 2011
Default Re: Previous year placement papers of Sasken Communication Technologies

As you want to get the previous year placement papers of Sasken Communication Technologies so here is the information of the same for you:


APTITUDE

1. Two people were walking in opposite directions.both of them walked 6 miles forward then

took right and walked 8 miles.how far is each from starting positions?
a) 14 miles and 14 miles
b) 10 miles 10 miles
c) 6 miles 6 miles
2. a person has certain number of cows and birds.they have 172 eyes and 344 legs.how many cows and birds does he have?
3.a person has 14 red socks and 14 white socks in a drawer.what is the minimum number of socks that he should take to get a correct pair?

4.when a number is multiplied by 13,it will become greater to 105 by an amt with which it is lesser to105 by now.what is the number

5.when asked what the time is, a person answered that the amount of time left is 1/5 of the time already completed.what is the time?

6.when I become as old as my father is now, I will be 5 times the age of my son.and my son will be 8 yrs older than what I am now.father+my age=100.how old is my son now?

7.two peoples on cycles are traveling at 10 miles / hour.when they reach a distance of 50 miles, a housefly lands on the first cyclist and then flies to the other and so on…at a speed of 16 miles/hour.what is the distance covered by fly before cyclist meet?

8.my successor's father is my father's son. and i don't have any brothers or sons..who is my successor?
a)nephew
b)niece
c)daughter
d)myself

COMPUTER SCIENCE

1. which of these checks for structural errors of a language
a)lexical analyser
b)parser
c)intermediate code
d)code optimisation

2. threads in the same process share the same
a)data section
b)stack
c)registers
d) thread id

3.the depth of a binary tree...
a)nlogn(base 2)
b) n*n
c)n

4.a program computing log(n) accepts 1000 inputs its execution time is 110 ms...when it doubles n to 2000 inputs..it becomes 120.....and what will be for 4000
a)130
b)140
c)150

5.algorithm to find the balancing of paranthesis was given and output had to be obtaines...using stacks...easy yaar....

6.which of the followin is non preemptive
fcfs
round robin
shortest job first

7.problem to find the avg waitin time of sjf..given the burst times of each process

8.which of the follwing may be implemented using a stack
parenthesis matchin
parsing
local variables stored in runtime
all the above

9.which of the foll data structures can be randomly accessed givin loc
1.linked kist implemented using array
2.singly linked list
3.double linked list

4.both single and double linked list





1. The hours remaining in a day is one-fifth of the hours passed in

the day. What is the time?

2. My successor is my uncles only brothers son who is his only kid.

(some what like this)

3. A and B starts from the same point and moves in opposite

direction for 8 miles and 6 miles respectively. After that A turns

right and moves for another 6 miles. B also turns right and moves 8

miles. What are their respective distance from the starting point?

10,10

4. In a pet shop there are 120 eyes and 172 legs. How many birds

and puppies are included in these?

5. Two cyclists are moving towards each other at 10 miles/hour.

They are now 50 miles apart. At this instance a fly starts from one

cyclist and move towards other and moves to and fro till the two

cyclist meet each other. If the fly is moving at 15 miles/hour, what is

the total distance covered by the fly? 50 80 100

6. Guru’s draw has 14 blue socks and 14 black socks. How many socks

must be taken to get a pair of socks of the same color? 14 15

13 16





C – SECTION

1. Find output ………….

Int *ptr=&const;

((((( ans:error)))))

2. Find output

Function(i=10);

(((((ans:error)))))

3. #define SWAP(x,y) t=x;x=y;y=t;

main()

{ int x=5,y=6;

if (x>y)

SWAP(x,y);

Printf(“x=%d y=%d\n”,x,y);

}

((( note that the function SWAPis not within braces))))

4. sum(int x)

{int t;

if(x<=1) return (1);

t=sum(x-3)+sum(x-1);

return (t);

}

if 6 is passed to the function, what is the value returned to the calling function.

(((((((ANS===== 9)))))))))

[ans:don’t remember the actual _expression.if the _expression is the

same the ans was nine]

5. what is int (*ptr)[]()?

6. Main()

{int a[]={0,2,4,6,8};

int *ptr;

ptr=a;

printf(“%d”, *((char *) ptr+4));

}

find output

8 2 4 6 (((((( ANS==== 4)))))))

7. which takes the same memory space regardless of the type of

operating system?

Char* char int float

8. main()

{ int I=3;

while(I--)

{int I=100;

I--;

Printf(“%d”, I);

}

}

find output.

100 99 98 99 98 97 99 99 99 error ((((( ANS== 99 99 99)))

9. main()
{char ch;

for(ch=’0’;ch<=255;ch++)

printf(“%c”, ch);
}

((((((([ans : infinite loop))))))

10. some program using variable b which was not initialized so

((((ans error))))

#include
int main()
{

enum Peoplevar1 {Alex=0, Tracy, Kristian} Girls;
enum Peoplevar2 {William=0, Martin } Boys;
switch (Boys)
{
case William:
puts("William");
break;

case Martin:
puts("Martin");
break;

default:
break;
}
return 0;
}



1. Martin

2. Compiler error


3. Runtime error


4. William



#include
union u
{
int var;
unsigned char str[4];
};
int main()
{
unsigned char tmp;
union u uObj;uObj.var = 3;
tmp = uObj.str[1];
uObj.str[1] = uObj.str[0];
uObj.str[0] = tmp;
printf("%d", uObj.var);
return 0;
}



1. 3


2. 768


3. Runtime crash


4. 876






An entire structure variable can be assigned to another structure variable if __________


1. the two variables have the same composition


2. the two variables are of same type


3. assignment of one structure variable to another is not possible


4. None of these







What will be the output of the following program ?

#include
#define size 3
enum{a,b,c,d,e};
int main()
{
const cValue[2];
long lValue[size];
signed sValue[e];
printf("%d",sizeof cValue+sizeof lValue+sizeof sValue);
return 0;
}



1. Compiler error


2. 45


3. 36


4. 20



What will be the output of the following program?

#include
enum myEnum { AB, BC };
int main()
{
enum myEnum a =10;
printf("%d", a);
return 0;
}



1. Compiler error


2. 1


3. 10


4. 0





#include
int main( )
{
struct a
{
category : 5 ;
scheme : 4 ;
} ;
printf ( "size = %d", sizeof ( struct a ) ) ;
return 0;
}



1. size = 0


2. size = 1


3. size = 4


4. Compiler error





Consider following code snippet:

#include
int main( )
{
int i = 5 , j = 2 ;
fun ( &i, &j ) ;
printf ( "\n%d %d", i, j ) ;
return 0;
}

Which of the following option is correct about function fun( ) so that value of i and j becomes 25 & 4?


1. void fun ( int i , int j )
{
i = i * i ;
j = j * j ;
}



2. void fun ( int &i , int &j )
{
i = i * i ;
j = j * j ;
}



3. void fun ( int *i , int *j )
{
*i = *i * *i ;
*j = *j * *j ;
}



4. void fun ( int *i , int *j )
{
i = i * i ;
j = j * j ;
}





What will be the output of the following program?

#include
int function(int i)
{
if(i<=1)
return 1;
if(i%2==0)
return function(i/2);
else
return function((i-1)/2);
}
int main()
{
extern int function(int);
int i;
i = function(5);
printf("%d",i);
return 0;
}



1. Compiler error


2. 2


3. 0


4. 1





What will the following program print?

#include

int main(void)
{
unsigned int c;
unsigned x=0x3;
scanf("%u",&c);
switch(c&x)
{
case 3: printf("Hello!\t");
case 2: printf("Welcome\t");
case 1: printf("To All\t");
defaultrintf("\n");
}
return 0;
}


1. It will Print Hello


2. Runtime error


3. Compiler error


4. No output



What will be the output of the following program?

void main( )
{
int i = 138, a = 138, k ;
k = fun ( !++i, !++a ) ;
printf ( "%d %d %d", i, a, k ) ;
}

fun( int j, int b )
{
int c ;
c = j + b ;
return ( c ) ;
}



1. 138 138 276


2. 138 138 0


3. 139 139 276


4. 139 139 0


What will be the output of the following program?

#include
int main()
{
int iaddr;
for(iaddr=0;iaddr<3;iaddr++)
{
int iaddr=100;
iaddr--;
printf("%d..",iaddr);
}
return 0;
}



1. 99..99..99..


2. 0..1..2.


3. 100..100..100..


4. 99..98..97.


What will be the output of the following program?

#include
int main()
{
char a[5][5],flag;
a[0][0]='A';
flag=((a==*a)&&(*a==a[0]));
printf("%d\n",flag);
return 0;
}


1. Runtime error


2. Compiler error


3. 1


4. 0



What will be the output of the following program?

#include
#define a 5
void foo();
int main()
{
printf("%d..",a);
foo();
printf("%d",a);
return 0;
}
void foo()
{
#undef a
#define a 50
}


1.
2. 50..50


3. 50..5


4. 5..5


5. Compiler error



What will be the output of the following program?

volatile int i;
main()
{
i = 8<10&1&&10>8;
i<<2;
printf("%d",i);
}



1. 1


2. 0


3. 4


4. None of these




What would be the output of the following program?

main()
{
int i = 10;
goto label2;
while(i)
{
switch(i-1)
{
case 1:
label2:
printf("%d", i);
}
}
printf("%s", "hello");
getch();
}



1. Infinite loop


2. 10 hello


3. Compiler error


4. hello




#include
int main()
{
const char *callCausal();
*callCausal()='A';
return 0;
}

const char *callCausal()
{
return "Causal Call";
}



1. No errors


2. Syntax error


3. callCausal() returns a constant string pointer which cannot be modified


4. None of these



What will be the output of the following program?

#include
char* func()
{
char str[10] = "Take Care";
return str;
}
int main()
{
char* str1 = func();
printf("%s", str1);
return 0;
}



1. Take Care


2. Compiler error


3. Undefined value


4. None of these


What will be the output of the following program?


#include
int main()
{
int var1,var2,var3,minmax;
var1=5;
var2=5;
var3=6;
minmax=(var1>var2)?(var1>var3)?var1:var3var2>var1);
printf("%d\n",minmax);
return 0;
}



1. 0


2. 5


3. 6


4. None of these



Consider following code snippet:

#include
int main( )
{
FILE *fp, *fs, *ft ;
fp = fopen ( "A.C", "r" ) ;
fs = fopen ( "B.C", "r" ) ;
ft = fopen ( "C.C", "r" ) ;
fclose ( fp, fs, ft ) ;
return 0;
}

Which one of the following files gets closed?


1. Only A.C


2. Only A.C and B.C


3. Error: “Undeclared identifier fclose( ) function”


4. All the three files



What will be the output of the following program?

#include

char *strrev(char *s,int n)
{
int i=0;
while (i {
*(s+n) = *(s+i); //uses the null character as the temporary storage.
*(s+i) = *(s + n - i -1);
*(s+n-i-1) = *(s+n);
i++;
}
*(s+n) = '\0';

return s;
}

int main()
{
char *str = malloc(10);

bzero(str, 10);
sprintf(str, "abcde");
printf("%s\n", strrev(str, 5));
return 0;
}



1. Compiler error


2. Runtime error


3. Compile and print some Garbage value


4. None of these



What will be the output of the following program?

Assume that the array begins at address 65486, and sizeof int is 2.

#include
int main()
{
int a[3][4] = {1,2,3,4,
4,3,2,1,
7,8,9,0
};
printf("%u %u", a+1, &a+1);
return 0;
}



1. 65480 65484


2. 65480 65482


3. 65480 65496


4. 65480 65488



#include
int main()
{
FILE* fp = NULL;
unsigned char c;
fp = fopen("MyFile.txt","r");
while((c = getc(fp)) != EOF)
putchar(c);
fclose(fp);
return 0;
}



1. Stack overflow


2. Runtime error


3. abcdefghij followed by infinite loop


4. Infinite loop



What will be the output of the following program ?


#include
void func(char*str)
{
int i=0;
*str=i++;
}

int main()
{
int i=0;
char str[5];
for(i=0;i<5;i++)
func(str+i);
for(i=0;i<5;i++)
printf("%c",str[i]);
return 0;
}



1. Runtime error


2. Empty array string


3. Compiler error


4. 0 1 2 3 4



What will be the output of the following program?

#include
int main()
{
int ch;
ch = 65;
printf("The character that has numeric value of 65 is:\n");
putc(ch, stdout);
return 0;
}



1. The character that has numeric value of 65 is: A



2. The character that has numeric value of 65 is: a



3. The character that has numeric value of 65 is: B



4. None of these





#include
int main()
{
int d;
double *s=0;
d=(int)(s+1);
printf("%d",d);
return 0;
}



1. 8


2. 4


3. Runtime error


4. Compiler error




int feof(FILE *stream)
int ferror(FILE *stream);
void clearerr(FILE *stream);
int fileno(FILE *stream);

The above functions are used for __________.



1. low level I/O


2. creating temporary file


3. stream status enquiries


4. reading and writing files



Point out the error if any, in the following program?

01 void main(void)
02 {
03 int j,i;
04 int *a[2];
05 int arr[2] = {1,2};
06 int srr[2] = {3,4};
07 a[0] = arr;
08 a[1] = srr;
09 clrscr();
10 for(i=0;i<2;i++){
11 for(j = 0;j<2;j++){
12 printf("%d",a[i]+j);
13 }
14 }
15 getch();
16 }




1. Prints 4 different addresses


2. Compiles without any error and the output is 1 2 3 4


3. Error in line 07 & 08


4. Error in line 13




01. int main()
02. {
03. FILE* fp = NULL;
04. long size = 0;
05. fp = fopen("MYFile.txt","b");
06. fseek( fp, 4 , SEEK_SET);
07. size = fwrite("TakeCare",1,3,fp);
08. return 0;
09. }



1. AbcdTakeCare


2. Empty file


3. 4 Take


4. Runtime error at line #4





Consider the following code snippet:

void main( )
{
int i, j ;
int ( *p )[3] ;
p = ( int ( * )[3] ) malloc ( 3 * sizeof ( *p ) ) ;
}

How would you access the elements of the array using p?




for ( i = 0 ; i < 3 ; i++ )
{
for ( j = 0 ; j < 3 ; j++ )
printf ( "%d", p[ i + j ] ) ;
}



for ( j = 0 ; j < 3 ; j++ )
printf ( "%d", p[ i ][ j ] ) ;



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



for ( i = 0 ; i < 3 ; i++ )
{
for ( j = 0 ; j < 3 ; j++ )
printf ( "%d", p[ i ][ j ] ) ;
}





Question Number 12

What will be the output of the following program?

#include

#define BUFSIZE 1024

void usage(char *cmd)
{
printf("Usage: %s \n", cmd);
printf("If your file is at /home/Cprogramming/documents/names.txt,
then the command will be: \n");
printf("%s /home/ Cprogramming /documents/names.txt\n", cmd);
}

int main(int argc, char *argv[])
{
FILE *fp;

if (argc < 2)
{
usage(argv[0]);
exit(0);
}

fp = fopen(argv[1], "r");
if (fp == NULL)
{
usage(argv[0]);
exit(0);
}

printf("Contents of %s are: \n", argv[1]);

while (!feof(fp))
{
char buf[BUFSIZE] = {0};

fread(buf, sizeof(char), BUFSIZE, fp);
printf("%s", buf);
}

printf("End of the file\n");

fclose(fp);
return 0;
}



Compiler error


Runtime error


No output


None of these




#include
int main( )
{
static char s[25] = "The cocaine man";
int i = 0 ;
char ch ;
ch = s[++i] ;
printf ( "%c", ch ) ;
ch = s[i++] ;
printf ( "%c", ch ) ;
ch = i++[s] ;
printf ( "%c", ch ) ;
ch = ++i[s] ;
printf ( "%c", ch ) ;
return 0;
}

hhec


he c


The c


hhe!




Select the most appropriate functionality of the following declaration in handling errors in C.

int feof(FILE *stream);


Returns a non-zero value if the error indicator is set for the stream


Returns a non-zero value if the end of file indicator is set for the stream


Returns all the error messages if the file pointer reaches the end of file


Returns a zero value if the error indicator is set for the stream




Which one of the following statements is correct about the following program?

#include
int main( )
{
int *c ;
c = check ( 10, 20 ) ;
printf ( "c = %u", c ) ;
return 0;
}
check ( int i , int j )
{
int *p, *q ;
p = &i ;
q = &j ;
if ( i >= 45 )
return ( p ) ;
else
return ( q ) ;
}




Error: ‘Expression syntax in function check( )’


Error: ‘Non portable pointer conversion’


Error: ‘Lvalue required’


No error




Which one of the following is the correct option that substitutes // deallocate memory in the following program?


#include
int main( )
{
struct ex
{
int i ;
float j ;
char *s ;
} ;

struct ex *p ;
p = ( struct ex * )
malloc ( sizeof ( struct ex ) ) ;
p -> s = ( char * ) malloc ( 20 ) ;
// deallocate memory
return 0;
}




free ( p -> s ) ;


free ( s, p ) ;


free ( p ) ;


free ( p -> s ) ; free ( p ) ;



#include
int main()
{
unsigned int i = -1;
printf("%s","Welcome");
if(i>-5)
main();
return 0;
}

Infinite loop


Stack overflow


Calling main inside main is illegal


Welcome





#include
int main()
{
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);
printf("%d %d",*(a+1),*(ptr-1));
return 0;
}


2 1


2 2


2 5


None of these





What will be the output of the following program?

#include
int main()
{
FILE * fp = NULL;
char str[100]="abcdefghij";
fp = fopen("MyFile.txt","w");
while(!feof(fp))
{
fscanf(fp,"%s",str);
fprintf (fp, "[%-10.10s]\n",str);
}
fclose(fp);
return 0;
}



MyFile.txt will contain abcdefghij



Infinite loop


Compiler error


Runtime error




#include
int bags[5]={20,5,20,3,20};
int main()
{
int pos=5,*next();
*next()=pos;
printf("%d %d %d", pos, *next(), bags[0]);
}
int *next()
{
int i;
for(i=0;i<5;i++)
if (bags[i]==20)
return(bags+i);
printf("Error!");
exit(0);
return 0;
}



10 20 10


5 20 5


10 Garbage value


20 Garbage value



#include
int callPoint(void);
void print(int,int(*)());
int i = 10;
int main()
{
int i=20;
print(i, callPoint);
}
void print(int i,int (*callPointOne)())
{
printf("%d\n",(* callPointOne)());
}
int callPoint(void)
{
return(i-=5);
}



10


Runtime error


5


Compiler error



What will be the output of the following program?

#include
int main()
{
FILE * fp = NULL;
char str[100]="abcdefghij";
fp = fopen("MyFile.txt","w");
while(!feof(fp))
{
fscanf(fp,"%s",str);
fprintf (fp, "[%-10.10s]\n",str);
}
fclose(fp);
return 0;
}



Compiler error


MyFile.txt will contain abcdefghij


Runtime error


Infinite loop



Question Number 2

What is TRUE about the code written below?

char *s1 = "Clueless";
char s2[] ="Clueless";
char *s3 = "Clueless";

1. s1 and s3 may share the same memory area
2. s1,s2 and s3 may share the same memory area
3. s1,s2 and s3 do not share the same memory area


1


2


3


4




What will be the output of the following program ?

#include
int main()
{
int arr[ ]={4.8,3.9,2,1.7,0};
int i,*q=arr;
for(i=0;i<5;i++)
{
printf("%d ",*arr);
++q;
}
return 0;
}




4.8 3.9 2 1.70


0 0 0 0 0


4 4 4 4 4


4 3 2 1 0



What will be the output of the program below, if MyFile.txt contains abcdefghij?


#include
int main()
{
FILE* fp = NULL;
unsigned char c;
fp = fopen("MyFile.txt","r");
while((c = getc(fp)) != EOF)
putchar(c);
fclose(fp);
return 0;
}





Infinite loop


abcdefghij followed by infinite loop


Runtime error


Stack overflow



What will be the output of the following program?


#include
int main()
{
int d;
double *s=0;
d=(int)(s+1);
printf("%d",d);
return 0;
}



Runtime error


Compiler error


4


8



From the following options, select the operation that you can perform on the file when you open a file using the command.

fp = fopen("filename", "r+");


Read contents from the file and add new contents to the file


Only read contents from the file


Read and modify only the existing contents of the file


Write contents to the file




The function that finds the first occurrence of a given string in another string is__________.



strrchr( )


strchr( )


strnset( )


strstr( )







Which one of the following options is TRUE about the following programs A and B?

A.
char str[100];
strcpy(str,"Hello");
File *fp = fopen("Binary.txt", "wb");
fwrite(str,sizeof(char),strlen(str),fp);
fclose(fp);

B.
char str[100];
strcpy(str,"Hello");
File *fp = fopen("Ascii.txt", "w");
fwrite(str,sizeof(char),strlen(str),fp);
fclose(fp);



Both the programs throws compiler error


Compiles successfully and both the programs give different output


Compiles successfully and both the programs give the same output


None of these






What will be the output of the following program?

#include
int main()
{
int *cptr, c;
int *vptr, v;
c=10; v=0;
cptr=&c; vptr=&v;
printf("%d %d ", c, v);
return 0;
}



Runtime error


10 10


10 0


Compiler error





What will be the output of the following program ?

#include
int main()
{
int arr[ ]={4.8,3.9,2,1.7,0};
int i,*q=arr;
for(i=0;i<5;i++)
{
printf("%d ",*arr);
++q;
}
return 0;
}



4.8 3.9 2 1.70


0 0 0 0 0


4 4 4 4 4


4 3 2 1 0




Which will be the output of the following program?


#include
struct virus
{
char signature[25] ;
char status[20] ;
int size ;
}
v[2] =
{
"Yankee Doodle", "Deadly", 1813,
"Dark Avenger", "Killer", 1795
} ;
int main ( )
{
int i ;
for ( i = 0 ; i <= 1 ; i ++ )
printf ( "\n%s %s", v[i].signature, v[i].status ) ;
return 0;
}


Yankee Doodle Deadly
Dark Avenger Killer


Dark Avenger Killer


Yankee Doodle Deadly


Compiler error


What will be the output of the following program?

#include
int main( )
{
union a
{
int i ;
char ch [ 2 ] ;
} ;
union a z1 = { 512 } ;
union a z2 = { 0, 2 } ;
return 0;
}



No Error


Error in initializing z1


Error in initializing z2


None of these


What will be the output of the following program ?

#include
int main()
{
typedef struct{char ch;}st;
st s1 = {'c'}; st s2 = s1;
if(s1 == s2)
printf("Successful");
return 0;
}


What will be the output of the following program?

#include
int main()
{
union a
{
int i;
char ch[2];
};
union a u;
u.ch[0] = 3;
u.ch[1] = 2;
printf("%d\n",u.i);
return 0;
}



Cannot predict output


2


Compiler error


3


What will be the output of the following program?

#include
int main( )
{
struct a
{
category : 5 ;
scheme : 4 ;
} ;
printf ( "size = %d", sizeof ( struct a ) ) ;
return 0;
}



size = 4


size = 0


Compiler error


size = 1



int main( )
{
abc ( main ) ;
printf ( "hi" ) ;
return 0;
}
abc( )
{
printf ( "hello" ) ;
}



hello


hellohi


Error: ‘Expression syntax’


hi


What will be the output of the following program?

#include
void print(int i);
int main()
{
static int i=1;
print(++i);
return 0;
}

void print(int i)
{
if(i==6)
return;
print(i);
print(++i);
printf("%d", i);
}



5 4 3 2 1 0


Stack overflow


5 5 4 4 3 3 2 2 1 1


Compiler error



What would be the output of the following program?

main()
{
int i = 10;
goto label2;
while(i)
{
switch(i-1)
{
case 1:
label2:
printf("%d", i);
}
}
printf("%s", "hello");
getch();
}





Infinite loop


hello


10 hello


Compiler error




What will be the output of the following program?

#include
int main()
{
int num;
num = 321;
num = fu(num);
printf("%d",num);
return 0;
}
int fu(int num)
{
static int n =0;
int r;
if(num)
{
r=num%10;
n=n*10+r;
fu(num/10);
return n;
}
else
return n;
}




321


123


3


None of these


What will be the output of the following program?

#include
int main()
{
int i;
for(i=0; i<10; i++);
printf("%d", --i);
return 0;
}




8


10


9


7


What will be the output of the following program?

#include
int main()
{
char c=' ',x,convert(z);
getc(c);
if((c>='a') && (c<='z'))
x=convert(c);
printf("%c",x);
}
convert(z)
{
return z-32;
}




Runtime error


Compiler error


32


22



Question Number 7

What will be the output of the following program?

01 void fun()
02 {
03 printf("%s","biog");
04 return 1;
05 }
06 int main()
07 {
08 int i = 10;
09 i = fun();
10 printf("%d",i);
11 }



Error in line 09


It will print biog 1


Error in line 04 & 09


Error in line 04




What will be the output of the following program?

int main()
{
int a=5,b=4,c=1;
while(a-- != 0 && b-- != 0 && c-- != 0)
{
c=a^b;
if(((c^b)== a))
{
printf("%d%d%d", a,b,c);
continue;
}
else
{
printf("%d%d%d", a,b,c);
a++;
b++;
c++;
continue;
}
}
return 0;
}




437


437321213101


437437437 and so on in infinite loop


Compilation error


What will the following program print?

#include

int main(void)
{
unsigned int c;
unsigned x=0x3;
scanf("%u",&c);
switch(c&x)
{
case 3: printf("Hello!\t");
case 2: printf("Welcome\t");
case 1: printf("To All\t");
defaultrintf("\n");
}
return 0;
}



It will Print Hello


No output


Compiler error


Runtime error





Which one of the following statements allow the variable being pointed to be changed?



A. const int *ptr
;
B. int *const ptr
;
C. const * int ptr;

D. const int * const ptr;



B & C


B


A & D


A




What will be the output of the following program?

#include
int main( )
{
int a, b;
a = sum ( 123 ) ;
printf ( "%d", a ) ;
return 0;
}
sum ( int n )
{
static int s = 0 ;
int d, d1;
if ( n != 0 )
{
d = n % 10 ;
d1 = ( n – d ) / 10 ;
s = s + d ;
sum ( n ) ;
}
else
return s ;
}




6


7


Error: ‘Lvalue required’


The code generates an infinite loop





#include
int main()
{
int var1,var2,var3,minmax;
var1=5;
var2=5;
var3=6;
minmax=(var1>var2)?(var1>var3)?var1:var3var2>var1);
printf("%d\n",minmax);
return 0;
}



0


5


6


None of these




Consider following code snippet:


#include
void main ( )
{
FILE *fp ;
fp = fopen ( "try.c", r ) ;
}

In the above code fp points to __________



the name of the file


the first character in the file


a structure which contains a char pointer that points to the first character in the file


the first word in the file




What will be the output of the following program?

#include

char *strrev(char *s,int n)
{
int i=0;
while (i {
*(s+n) = *(s+i); //uses the null character as the temporary storage.
*(s+i) = *(s + n - i -1);
*(s+n-i-1) = *(s+n);
i++;
}
*(s+n) = '\0';

return s;
}

int main()
{
char *str = malloc(10);

bzero(str, 10);
sprintf(str, "abcde");
printf("%s\n", strrev(str, 5));
return 0;
}




Compiler error


Runtime error


Compile and print some Garbage value


None of these




Consider the following two-dimensional array.

int twoarray[4][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

Select the correct option that gives out the values of the following array elements.

twoarray[1][1], twoarray[2][0], twoarray[3][2], twoarray[0][2]




6, 9, 10, 2


5, 7, 12, 3


5, 12, 7 , 3


5, 7, 12, 1



Question Number 4

What will be the output of the program below, if MyFile.txt contains abcdefghij?


#include
int main()
{
FILE* fp = NULL;
unsigned char c;
fp = fopen("MyFile.txt","r");
while((c = getc(fp)) != EOF)
putchar(c);
fclose(fp);
return 0;
}



abcdefghij followed by infinite loop


Runtime error


Infinite loop


Stack overflow





Which one of the following statements represent a correct and safe declaration of a NULL pointer?



typedef((void *)0) NULL;


typedef NULL(char *)0;


#define NULL((void *)0)


None of these



Select the function which does not generate file names that can be safely used for a temporary file.


char *tmpname(char *s)


char *tmpname_r(char *s)


char *tempname(const char *dir, const char *pfx)


char *tempname r(const char *dir, const char *pfx)





What will be the output for the following program?

#include
int callPoint(void);
void print(int,int(*)());
int i = 10;
int main()
{
int i=20;
print(i, callPoint);
}
void print(int i,int (*callPointOne)())
{
printf("%d\n",(* callPointOne)());
}
int callPoint(void)
{
return(i-=5);
}



5


10


Compiler error


Runtime error



What will be the output of the following program?

#include
int main()
{
static char*s[] = {"white", "yellow", "violet", "black"};
char **ptr[] = {s+3, s+2, s+1, s}, ***p;
p = ptr;
**++p;
printf("%s", *--*++p+3);
return 0;
}



Compiler error


kc


te


ck


What will be the output of the following program?

#include
int main()
{
char str[ ]="Hello";
strcat(str, '!');
return 0;
}


Select the most appropriate functionality of the following declaration in handling errors in C.

int feof(FILE *stream);


Returns a non-zero value if the error indicator is set for the stream


Returns a non-zero value if the end of file indicator is set for the stream


Returns all the error messages if the file pointer reaches the end of file


Returns a zero value if the error indicator is set for the stream




What will be the output of the following program?

#include
int main()
{
unsigned int i = -1;
printf("%s","Welcome");
if(i>-5)
main();
return 0;
}



Stack overflow


Calling main inside main is illegal


Welcome


Infinite loop




Consider the following program:

#include
int main( )
{
int *p ;
p = ( int * ) malloc ( 20 ) ;
printf ( "%u", p ) ;
free ( p ) ;
printf ( "%u", p ) ;
return 0;
}

Assume that the first printf( ) function gives the output as 3141.

What would be the output of the second printf( ) function?


Garbage


0


3141


None of these


What will be the output of the following program ?

#include
int main()
{
enum Days{Sunday,Monday,Tuesday,Wednesday,Thursday,Frid ay,Saturday};
Days TheDay;
int j = 0;
printf("Please enter the day of the week (0 to 6)\n");
scanf("%d",&j);
TheDay = Days(j);
if(TheDay == Sunday || TheDay == Saturday)
printf("Hurray it is the weekend\n");
else
printf("Curses still at work\n");
return 0;
}



Hurray it is the weekend


Runtime error


Curses still at work


Compiler error




What will be the output of the following program?

#include
#define sdef struct s *
struct s{int x;char y[2];};
int main()
{
sdef sobj1,sobj2;
sobj1->x=10;sobj1->y[0]='a';
sobj1->y[0]='b';sobj2=sobj1;
printf("%d%c%c",sobj2->x, sobj2->y[0],sobj2->y[1]);
return 0;
}




Compiler warning


10ab


Runtime error


Compiler error




#include
int main( )
{
int x , y , z ;
x = y = z = 1;
z = ++x || ++y && ++z ;
printf ( "x = %d y = %d z = %d \n", x , y , z ) ;
return 0;
}




x = 2 y = 1 z = 1


x = 1 y = 2 z = 1


x = 2 y = 2 z = 2


x = 2 y = 2 z = 1



What will be the output of the following program?

#include
int main();
int printf(const char*,Ave);
int main()
{
int i=100,j=10,k=20;
int sum;
float ave;
char myformat[]="ave=%.2f";
sum=i+j+k;
ave=sum/3.0;
printf(myformat,ave);
return 0;
}




Prints nothing


Runtime error


ave=43.33


Compiler error




#include
int main()
{
char *svar[]={ "Fruits","Vegetables","Meat","Fish"};
char **pvar;
pvar=svar;
printf("%s",++*pvar);
printf("%s",*pvar++);
printf("%s",++*pvar);
return 0;
}




Fruits Vegetables Meat Fish


ruitsruitsegetables


Fruits, Vegetables


Compiler error



#include
int main()
{
union Test_union
{
int a; float b; long c;
}
u;
struct Test_struct
{
int a; float b; long c;
}
s;
u.a = 1;
u.b = 2;
u.c = 3;
s.a = u.a;
s.b = u.b;
s.c = u.c;
printf("%d\t%f\t%d",s.a,s.b, s.c);
return 0;
}



Which one of the following statements is TRUE about a function?


Each function except main function shares the same stack


Other functions share the same stack as the main function


In case of a buffer overflow the saved registers are affected


None of these




If we don’t specify any return type for a function, then the function returns __________.



float


double


integer


void




#include
int main()
{
int itype = 2;
float type=(int)itype;
switch(itype)
{
defaultrintf("zero");
case 2rintf("2.3f");break;
case 3rintf("3.4f");break;
case 4rintf("4.4f");break;
}
return 0;
}



zero2.3f


4.4f


2.3f


zero




#include
void print(int i);
int main()
{
static int i;
print(i++);
getch();
}
void print(int i)
{
if(i==5)
{
return;
}
print(i++);
printf("%d", i);
}


Stack overflow


5 4 3 2 1


Compiler error


4 3 2 1 0



#include
#define macIntFunc(n) func(n)
int func(int n)
{
return (! ( n & ( n-1 )));
}
int main()
{
printf("%d", macIntFunc(8));
return 0;
}



Compiler error


1


Compiler warning


None of these



Consider test1, test2, test3 as three functions. In which order will the functions be called in the following expression?

a = test1() * test2() / test3() + test3;



Compiler dependent


test3, test2, test1


test2, test3, test1


test1, test2, test3





#include
int main()
{
int i=1;
while (i<=5)
{
printf("%d",i);
if (i>2)
goto here;
i++;
}
return 0;
}
fun()
{
here:
printf("PP");
}




Compiles successfully


Runtime error


Compiler error


None of these




From the following statements, select the correct way of declaring a function pointer which accepts two integer arguments and returns an integer value?



int (*fp)(int, int);


int *fp(int, int)


(int*) fp(int, int)


(int *fp) (int, int)




What will be the output of the following program?

#include
int main( )
{
int i ;
i = fun( ) ;
printf ( " %d ", i ) ;
return 0;
}
int fun( )
{
int _AX = 1990 ;
return _AX;
}





19


Runtime error


Compiler error


1990



Consider the following variable declarations:

float var1;
double var2;

Which one of the following is the correct way to scan the above two variables?





scanf("%f %f ", &var1,&var2);


scanf("%Lf %Lf ", &var1,&var2);


scanf("%f %Lf ", &var1,&var2);


scanf("%Lf %f ", &var1,&var2);




Which one of the following is the correct option that substitutes // deallocate memory in the following program?


#include
int main( )
{
struct ex
{
int i ;
float j ;
char *s ;
} ;

struct ex *p ;
p = ( struct ex * )
malloc ( sizeof ( struct ex ) ) ;
p -> s = ( char * ) malloc ( 20 ) ;
// deallocate memory
return 0;
}



free ( p ) ;


free ( s, p ) ;


free ( p -> s ) ;


free ( p -> s ) ; free ( p ) ;



What is TRUE about the code written below?

char *s1 = "Clueless";
char s2[] ="Clueless";
char *s3 = "Clueless";

1. s1 and s3 may share the same memory area
2. s1,s2 and s3 may share the same memory area
3. s1,s2 and s3 do not share the same memory area





1


2


3


4





What will be the output of the following program ?

#include
int main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d", sizeof(str1), sizeof(str2));
return 0;
}




1 4


1 1


1 5


4 5





#include
int main()
{
int aaddr[]={5,4,3,2,1};
int xaddr,yaddr;
int *paddr=&aaddr[2];
*paddr++;
xaddr=++*paddr;
yaddr=*(paddr++);
printf("%d %d",xaddr,yaddr);
return 0;
}



Compiler error


2 2


1 1


3 3




Question Number 8

What will be the output of the program below, if MyFile.txt contains abcdefghij?


#include
int main()
{
FILE* fp = NULL;
unsigned char c;
fp = fopen("MyFile.txt","r");
while((c = getc(fp)) != EOF)
putchar(c);
fclose(fp);
return 0;
}



abcdefghij followed by infinite loop


Stack overflow


Infinite loop


Runtime error





What will be the output of the following program?

#include
int main()
{
int *cptr, c;
int *vptr, v;
c=10; v=0;
cptr=&c; vptr=&v;
printf("%d %d ", c, v);
return 0;
}



10 10


Compiler error


10 0


Runtime error





The function unlink(filename) is used to __________.



remove link between file and buffer


remove the existing file from the directory


remove the contents of file only


None of these



What will be the output of the following program?

#include
int main( )
{
int a [ ] = {2, 4, 6, 8, 10 } ;
int i ;
for ( i = 0 ; i <= 4 ; i++ )
{
* ( a + i ) = a [ i ] + i [ a ] ;
printf ( "%d", *( i + a ) ) ;
}
return 0;
}



2 4 8 16 32


2 4 6 8 10


4 8 12 16 20


4 8 16 32 64





What will be the output of the following program?

#include
int main()
{
FILE* fp = NULL;
fp = fopen("c:\newfolder\MyFile.txt", "wb");
return 0;
}



Creates the MyFile.txt file if it doesn’t exist and then opens it


Runtime error


Doesn't compile


Doesn't create any file even if it doesn’t not exist





Consider the following two-dimensional array.

int twoarray[4][3] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

Select the correct option that gives out the values of the following array elements.

twoarray[1][1], twoarray[2][0], twoarray[3][2], twoarray[0][2]



5, 12, 7 , 3


5, 7, 12, 1


6, 9, 10, 2


5, 7, 12, 3



Select the most appropriate functionality of the following declaration in handling errors in C.

int feof(FILE *stream);


Returns a non-zero value if the error indicator is set for the stream


Returns a non-zero value if the end of file indicator is set for the stream


Returns all the error messages if the file pointer reaches the end of file


Returns a zero value if the error indicator is set for the stream





What will be the output of the following program?

Assume that short is two bytes.


#include
int main()
{
short testarray[4][3] = { {1}, {2, 3}, {4, 5, 6} };
printf( "%d\n", sizeof( testarray ) );
return 0;
}



24


Compiler error


7


6


Pattern : C(10 Qs) + Aptitude(10 Qs) + Discpline based[CS/EC](10 Qs)

Duration : 1 Hr

C questions
------------

1.Consider the following declaration:-

char const *p = 'd';

Which of the following is not a permissible operation
(a) *p++
(b) ++p
(c) (*p)++
(d) All

2.What is the output of the following code:-

void print_arr(float **p)
{
printf(" 0 %f 1 %f 2 %f\n",p[0][0],p[0][1],p[0][2]);
}

void main()
{
float arr[2][3] = {{0,1,2},{3,4,5}};
float **fl_arr;
fl_arr = (float *)arr;
print_arr(fl_arr);
fl_arr++;
print_arr(fl_arr);
}

(a)
(d)segmentation fault

3.What is the output of the following code:-
#define putchar (c) printf("%c",c)
void main()
{
char s='c';
putchar (s);
}

(a) c
(b) 99
(c) Compilation error
(d) Execution error
4.What is the output of the following code:-

void main()
{
printf("%d",printf("ABC\\"));
}
(a) ABC\\
(b) 1
(c) ABC\4
(d) ABC\3

5.What is the output of the following code:-

int compute(int n)
{
if(n>0)
{
n=compute(n-3)+compute(n-1);
return(n);
}
return(1);
}

void main()
{
printf("%d",compute(5));
}

(a) 6
(b) 9
(c) 12
(d) 13

6.What is the output of the following code:-

void main()
{
int i;
for(i=0;i<3;i++)
{
int i=100;
i--;
printf("%d..",i);
}
}

(a0..1..2..
(b)99..98..97..
(c)100..100..100..
(d)99..99..99..

7.What is the output of the following code:-

void main()
{
int a[]={9,4,1,7,5};
int *p;
p=&a[3];
printf("%d",p[-1]);
}

(a)6
(b)1
(c)7
(d)Error

8.What is the output of the following code:-

void main()
{
int a[]={10,20,30,40,50};
int *p;
p= (int*)((char *)a + sizeof(int));
printf("%d",*p);
}

(a)10
(b)20
(c)30
(d)40

9.Which code will run faster

for(i=0;i<100;i++)
for(j=0;j<10;j++)
a[i][j]=0;

OR

for(j=0;j<10;j++)
for(i=0;i<100;i++)
a[i][j]=0;

(a)First code
(b)Second code
(c)Same
(d)Compiler and hardware dependent

Aptitude
--------

1.How many 2 digit numbers are there which have 8 as the unit number in it's square.
(a)3
(b)None
(c)2
(d)1

2. B is 8km East of A. C is 6km North of B. D is 12km East of C. E is 16km North of D. What is the distance b/w A and E.
(a)20km
(b)22km
(c)18km
(d)30km

3. x+y = z
Then
(a)...
(b)y(c)...

4. 2Then which is the greatest
(a) (x^2)y
(b) 5xy
(c) x(y^2)
(d) 5(x^2)y/12

5. A is taller than B, D is taller than D, D is shorter than E.Then which of the following is correct.
(a) C is taller than E
(b) A is taller than C
(c) D is shorter than A
(d) B is shorter than C

6.A small passage was given and 4 options which summarizes it was given.The best was to be chosen.

7.Another passage was given and 4 inference was given and correct was to be chosen.This one is very easy.

8.Which of the following is a parellogram:-
(a)130,50,130,50(angle in deg)
(b)120,30,130,20
(c)90,90,90,90
(d)a & c

9. In the following series (an - 1)^2, 1 is the first term.Which are the next three
(a)1,3,4
(b)0,3,6
(c)0,1,2
(d)0,1,0




Computer science
----------------

1.Deadlock occur when
(a)Some resources are held up by some process.
(b)...
(c)...
(d)None of these

2. A prefix expression can be equal to a postfix expression reversed only if
(a)It is left associative
(b)It is commutative
(c)It is right associative

3.How many lines will be printed in the following
Pascal pgm [I don't remember the Pascal version,so I am giving C version]

void print(int n)
{
if(n>0)
{
print(n-1);
printf("%d",n);//println(n) in Pascal version.
print(n-1);
}
}
(a)3
(b)7
(c)15
(d)31

4.Maximum number of nodes in a tree with n levels.
(a)2^(n-1)
(b)(2^n)-1
(c)2^(n-1) - 1

5.Complete graphwith n nodes have
(a)n-1 edges
(b)n(n-1)/2

6.If d is the degree of a node in a graph and n is number of vertices then number of edges in that graph is
(a)Edi^n
(b)0.25Edi
(c)0.5Edi

7.A grammar was given and 4 strings was given and the one which was not possible was to be chosen.

8.A problem related to ethernet in which a station sending a frame is of p probablity.There are m stations to send pckts.4 option was given.It was a mathematical kind of question related to probablity.

9.Which of the following layer in the OSI model does error handling
(a)Data link
(b)Network
(c)Transport
(d) a & c

10.A network problem in which Data rate,Propagation delay,and distance was given and it was to find how many packets will be in the line. Choices where
(a)5000
(b)Not possible to find with given data
(c)1000

Contact Details:
Sasken Communication Technologies Limited
1st Floor, Bagmane Parin,
Bagmane Tech Park, GM Palya,
Cauveri Colony,
C V Raman Nagar,
Bangalore,
Karnataka 560093 ‎
080 3989 1122
India

Map Location:
__________________
Answered By StudyChaCha Member
Reply With Quote
Reply


Tags
Job Placement



All times are GMT +6. The time now is 05:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Friendly URLs by vBSEO 3.6.0 PL2

1 2 3 4 5 6 7 8