Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1. int b=10;
int *p=&b;
*p++;
printf("%d",*p);
what is the output?
4. main()
{
char *a="hello";
char *b="bye";
char *c="hai";
int x=10,y=100;
c=(x<y>)?a:b;
printf("%s",c);
}
whats the output?
5. void main()
{
int a,b;
a=sumdig(123);
b=sumdig(123);
printf("%d %d",a,b);
}
int sumdig(int n)
{
static int sum;
int d;
if(n!=0)
{
d=n%10;
n=(n-d)/10;
sum=sum+d;
sumdig(n);
}
else
return s;
}
what is the output?
C++
8. class A
{
public:
A()
{
}
~A();
};
class derived:public A
{
derived();
};
what is wrong with this type of declaration?
18.char *str;
char *str1="Hello World";
sscanf(str1,"%s",str);
what is the output?
1. void main()
{
int d=5;
printf("%f",d);
}Ans: Undefined
2. void main()
{
int i;
for(i=1;i<4,i++)
switch(i)
case 1: printf("%d",i);break;
{
case 2:printf("%d",i);break;
case 3:printf("%d",i);break;
}
switch(i) case 4:printf("%d",i);
}Ans: 1,2,3,4
3. void main()
{
char *s="\12345s\n";
printf("%d",sizeof(s));
}Ans: 6
4. void main()
{
unsigned i=1; /* unsigned char k= -1 => k=255; */
signed j=-1; /* char k= -1 => k=65535 */
/* unsigned or signed int k= -1 =>k=65535
*/
if(i<j)
printf("less");
else
if(i>j)
printf("greater");
else
if(i==j)
printf("equal");
}Ans: less
5. void main()
{
float j;
j=1000*1000;
printf("%f",j);
}
1. 1000000
2. Overflow
3. Error
4. None
Ans: 4
6. How do you declare an array of N pointers to functions
returning pointers to functions returning pointers to
characters? Ans: The first part of this question can be
answered in at least three ways:
8. Use the cdecl program, which turns English into C and vice
versa:
cdecl> declare a as array of pointer to function returning
pointer to function returning pointer to char char
*(*(*a[])())()
cdecl can also explain complicated declarations, help with
casts, and indicate which set of parentheses the arguments
go in (for complicated function definitions, like the one
above). Any good book on C should explain how to read
these complicated C declarations "inside out" to understand
them ("declaration mimics use"). The pointer-to-function
declarations in the examples above have not included
parameter type information. When the parameters have
complicated types, declarations can *really* get messy.
(Modern versions of cdecl can help here, too.)
9. A structure pointer is defined of the type time . With 3 fields
min,sec hours having pointers to intergers.
Write the way to initialize the 2nd element to 10.
17. main()
{
static i=3;
printf("%d",i--);
return i>0 ? main():0;
}
Ans: 321
i2 Technologies
Q3. In 32 bit memory machine 24 bits for mantissa and 8 bits for
exponent. To increase the range of floating point.
a) more than 32 bit is to be there.
b) increase 1 bit for mantissa and decrease 1 bit for exponent
c) increase 1 bit for exponent and decrease one bit for mantissa
Q6. The following function gives some error. What changes have to be
made
void ( int a,int b)
{
int t; t=a; a=b; b=t;
}
a) define void as int and write return t
b) change everywhere a to *a and b to *b
Q8. include<stdio.h>
void swap(int*,int*);
main()
{
int arr[8]={36,8,97,0,161,164,3,9}
for (int i=0; i<7; i++)
{
for (int j=i+1; j<8;j++)
if(arr[i]<arr[j]) swap(&arr[i],&arr[j]);
}
}
void swap(int*x,int*y)
{
int temp; static int cnt=0;
temp= *x;
*x=*y;
*y=temp;
cnt++;
}
What is cnt equal to
a) 7
b) 15
c) 1
d) none of these
a) 0 bytes
b) 5 bytes
c) 11 bytes
d) data is insufficient
Q10. f1(int*x,intflag)
int *y;
*y=*x+3;
switch(flag)
{
case 0:
*x=*y+1;
break;
case 1:
*x=*y;
break;
case 2:
*x=*y-1;
break;
}
return(*y)
main()
{
*x=5;
i=f1(x,0); j=f1(x,1);
printf("%d %d %d ",i,j,*x);
}
a) 8 8 8
b) 5 8 8
c) 8 5 8
d) none of these
printf("%d\n",i);
}
Ans: -1
7. ain()
{
char a[]=="Hello";
printf("%c\n",*a++);
}
Ans: Error
8. a=3,b=2,c=1;
What's the value of k?
k== a< b < c-1;
Ans: 0
9. main()
{
int a=3;
do
{
printf("%d", a);
a=-1;
} while(a0);
}
Ans: 3
10. It is not "exact" Question; But the given Answers is:
a) PASS1 PASS2
b) PASS1 FAIL1
c)FAIL1 FAIL2
d)FAIL1 PASS2
main()
{
char c==-32;
int i==-64;
unsigned u==-26;
if(ci)
printf("PASS1");
if( i < c)
printf("PASS2");
else
printf("FAIL1");
if(i<U)
printf("PASS2");
else
printf("FAIL2");
}
Ans: PASS1 PASS2 PASS1
11. main()
{
int i==0;
for( i==0; i<= ;i++)
{
switch(i)
{
case 0: i+==5;
case 1: i+==2;
case 2: i+==5;
default: i+==4;
break;
}
printf("%d",i);
}
Ans: 16 21
12. main()
{
int i==4;
switch(i)
{
case 1:
printf("HEllo"):
case default: // "case" should not come with "default"
printf("****");
}
}
Ans: Error
13. main()
{
int sum==0,count;
for(count==1;sum+==count)
printf("%d\t",sum);
}
Ans: Error
14. define cond(a) a=e && a<=0
main()
{
char s=='R';
if( cond(s) )
printf("UPPER CASE");
else
printf("LOWER CASE");
}
Ans:UPPER CASE
15. main()
{
static int i==5;
printf("%d\t",i--);
if( i)
main();
}
Ans: 5 4 3 2 1
16. main()
{
char *a1=="new",*a2=="dictionary",*t;
swap(a1,a2);
printf("(%s%s)",a1,a2);
t=¡;
a1=¢;
a2==t;
printf("-(%s%s)",a1,a2);
}
swap( char *s1,char *s2)
{
char *temp;
s1=s2;
s2=s1;
temp=s1;
}
Ans: (newdictionary)-(dictionarynew)
17. *p++?
Ans: increments Address
18. main()
{
int a[]=={ 10,20,30,40,50};
char*p==(char*)a;
printf("%d", * ( (int *) p+4);
}
Ans: 50
19. one question nothig but calling a function before it has been defined.
Mistral Solutions
C Section
part 1 of paper
part 2
second c debugging (test ur c skills - yashwant kanitkar)(questions
20 time 30 min.)
paper 1
section one
section two
section three
one hotel has two zones (east and west) not all east zone flats have
ocean view but all weat zone flats have harbour view all ocean view
flats has extra charge in harbour view flats above and on 3rd floor
have extra charge west zone flats lower than 3rd floor some has
kitchen so extra charge all other flats of east zone not having ocean
view has kitchen so extra charges
section four
sections five
* total 12 members half are in club a one third in b and one fourth in
c how many are not in any club
ans 5(check)
in question it was written that all five sections carry their cutoffs so
attempt all but in electrical one guy was selected who didnot attempt
reading comprehension but attempted all 45 questions this paper also
has negative marking of 50%
paper 2
1.what does p in
const char *p
stands for
p can be changed like this
2.main()
sturct date {
char name[20];
int age ;
float sal;
};
sturct data d ={"rajesh"};
printf("%d%f",d.age,d.sal);
}
tell the output
3.main()
int i=7;
printf("%d"i++*i++);
output
4.void main()
{
int d ;
int i=10;
d =sizeof(++i);
printf("%d");
output
5.difference between
extern int f();
int f();
6.choose correct
(i)stack is automatically cleared
(ii)heap is automatically cleared
(iii)user has to clear stack and heap
(iv)system takes care of ----------
10.which is valid :
(i)char arr[10];
arr="hello";
(ii) char arr[]="hello";
11.
main()
{
char *str;
str=char*malloc(20*sizeof(char));
strcpy(str,"test");
strcat(str,'!');
printf("%s",str);
}
14. Output ?
main()
{
int i,j;
for(i=0,j=0;i<5,j<25;i++,j++);
printf("%d %d",i,j);
}
15.main()
{
int i;
if(i=0) //it's assisnment not logical operator
printf(" Hell ");
else
printf("Heaven");
like this
no negative marking and more than one answers but paper I is cutoff
paper i think c paper will not be checked
Interview
they will give u puzzles in first round which will be from site
techinterview.org this site has 70 puzzles and their answers so go
through them
Some of the questions will not have answers .Please forgive us.
main(){
int p=3,q=4;
q = shw(&p);
printf("%d %d",p,q);
}
4. which is true
a. all automatic variables are declared with in the function
b. all variables are automatic
c. all not declared variables are automatic
d. none
5. What is recursion. Recursive prog to generate Fibonacci series . Is
it a best method?
6. write 7*a interms of +,-,<<
7. count number of 1's in a 32 bit integer.(i had not remembered
whether array or integer).
8. main(){
char *s1 = "hello",*s2 ="abce";
strcpy(s1,"");
s2[0] = s1[0];
printf("%d%d",strlen(s1),strlen(s2));
}
9. regarding memset
10.Algorithm to delete a node in Double linked list.
11. Difference b/n fgets,fscanf which u will prefer.
Unix
11.What is creon and whats diff b/n 'at' command.
12. what is system call and lib function. whats diff b/n them. abt
execve - expalin.
13.some thing abt makeall
14. write abt TCP,IP,ICMP