Tuesday, October 17, 2006

Adobe Interview Ques....

adobe intrvw
hey ppl..

1) at adobe i was asked to write memcpy function. since it was 1st time i have heard abt the function i rather blotched up.. can u plss give me d code for it.

2) secondly i was asked something in OS.. it was u have 4gb ram, n at any time u have only 2 processes of 10mb each. so do u need any virtual memory for it??

He also asked me if there is a malicious code which writes all ram with 0, how can virtual memory stop it.. i think it was something like this:

int *i;
for(i=0;i*i=0;

dnt go into the details of the prog, he was just trying to give an example n asking how do virtual memory come useful in such situations..

posted by
(http://www.orkut.com/Profile.aspx?uid=18150653767473274915)

Monday, October 16, 2006

Programming problem....

Find out the program such that if you given a foating point number then output should be fraction
eg: it u given 0.75 then output should 3/4

Interview Question

You have an array. For eg [23,12,45,23,9,23,45]
Now you have to print the elements in the order of decreasing frequency, and the same no of times as it is coming in the imput aray.
so the output for this eg would me [23,23,23,45,45,12,9].
if frequency of two elements is equal, they should come in the same order as they are coming in the input array.

Can u solve it ? Ask me if you dont understand the question.

intresting problem...

Write a program for the problem: the array of
inetegers indicating the marks of the students is
given, U have to calculate the percentile of the
students aaccording to this rule: the percentile of a
student is the %of no of student having marks less
then him. For eg:
suppose

Student Marks
A 12
B 60
C 80
D 71
E 30
F 45

percentile of C = 5/5 *100 = 100 (out of 5 students 5
are having marks less then him)

percentile of B = 3/5*100 = 60% (out of 5, 3 have
markses less then him)

percentile of A = 0/5*100 = 0%.

Try it

Typically a main function is declared as:

int main(int cArg, char *szArg[]);

tell me if there is any way that cArg can recieve the value 0!!

print 1 to N*N in cyclic order

input N
print in cyclic order. eg N=2
4 3
1 2

N=3
5 4 3
6 1 2
7 8 9

so on...

Constraints: U r not supposed to store in in array..
U r not supposed to use vedio memory
==> it has to print 5,4,3,6,1,2,7,8,9 if N=3..

josephous problem

plz write the program in C for the problem below:
suppose there are N persons are in circle. a person kills the person beside him. and pass the knife next person(example :- 1 kills 2 , pass the knife to 3 ,3 kills 4 and pass to 5 and so on) . at last only two persons will be left . find those two persons? . at last who will kill whom?. who is the surviver?.

i already wrote the program for this..
as thread progress i'll post it.

Simple one,

what is the output & WHY?

int a=3;

int f()
{
return a=1,2;
}

main()
{
printf("%d %d\n",f(),a);
}

wht is the output and why???/

WAt is the output of

void main()
{
float i=1.8;
if(i==1.8)
printf("i is 1.8");
else
printf("i is not 1.8");
getch();
}


Strange,Its output is "i is not 1.8".
Now,u have to tell whyyyyyyyyyyy???

what is the output and why

#include
main()
{
char *p="HI FRIENDS",*p1;
p1=p;
while(*p!='\o')
++*p++;
printf("%s%s",p,p1);
}

function pointer..

hi all,
i jus want to make clear my function pointer doubts here.
for eg.
{
int (*fun)();
int add(int a,int b);
int sub(int a,int b);
int div(int a,int b);
fun=&add;
}
my doubt is when iam assigning add to the function pointer..
function pointer variable is having different address..but its not having the add function address...
but when i checked n the disassembly mode,the function pointer is having some address which is jumping to that add subroutine.
can u ppl make it clear abt ths?

Posted by
sakthi (orkut)

Sunday, October 15, 2006

Volatile variable

what is this "volatile" variable? where it get stored and what are its advantages,uses?

ms interview questions

1. A majority element in an array A, of size N is an element that appears more than N/2 times (and hence there is atmost
one such element)

Write a function which takes an array and emits the majority element (if it exists), otherwise prints NONE as follows:

I/P : 3 3 4 2 4 4 2 4 4
O/P : 4

I/P : 3 3 4 2 4 4 2 4
O/P : NONE

2. How do u find the largest repeating string and the number of times it
repeats in a given string efficiently offcourse !?

ex :
String : "abc fghi bc kl abcd lkm abcdefg"
Ans : "abcd" count = 2

3. Here is an interesting sequence..
1 20 33 400 505 660 777 8000 9009 10100 11121
What are the next few numbers in the above sequence?

can u do it?????????

1)A chess board contains 64(8*8)squares.Fr a knight at(m,n),allowable to (m+2,n_+1),m+-1,n+2)or (m+-1,n-2)provided the new coordinate is a valid one Verify whether a path exists or not for a knight to traverser all the squqre without touching the same square again for scond time.If yes print the path.If no print error message(Use Recursion)Your input is initial coordinate and output is complete path satisfying the constraintsgiven above.

what is the output and why

#include
main()
{
char *p="HI FRIENDS",*p1;
p1=p;
while(*p!='\o')
++*p++;
printf("%s%s",p,p1);
}

diff betn static & global variable?

Kirti(Next Paulo
10/15/2006 9:23 AM
they are completely different if you go in details.....but visible differences are::

static is has a life = program life but acope is limited to the function in which it is defined.........where as global variable have scope over all of the program and life = program life......

Udit
10/15/2006 9:26 AM
@Kirti

They are not completely different. Infact globals are just special cases of static variables (pretty much like a square is a special case of a rectangle). Statics and globals both exist till the process exits, the only differenc being the scope they are declared in like you said.

Jassi-gyaani-
10/15/2006 10:10 AM
static variables if declared outside of all functions would still be local variables inside the file that is you cannot use them outside of that file.

global variables are by default external...

sharad
10/15/2006 10:37 AM
SEE GLOBAL VARIABLE BY DEFAULT COMES UNDER EXTERN TYPE.THEIR SCOPE IS GLOBAL AND THEIR LIFETIME IS PERMANENT,WHETHER THE PROGRAM IS EXECUTING OR NOT.
WHERE AS STATIC VARIABLE'S SCOPE IS LOCAL BUT LIFETIME IS SAME AS EXTERN VARIABLE

Try it out...

How can we multiply any two large number(may be 10-15 digits long) and print it....!!!
Before hand the programmer will have no idea how big the the couple of numbers would be!

sOlvE it

Write a C function that will print 1 to N one per each line on the stdout
where N is a int parameter to the function. The function should not use
while, for, do-while loops, goto statement, recursion, and switch
statement.

self reproducing program using C

Write the smallest self-reproducing C program such that the program's output is the exact source of the program itself.

solve it...

Input -> output

1 ->
1

2 ->
222
212
222

3->
33333
32223
32123
32223
33333

and so on.

Input WILL BE <=9.

It has to be done without using arrays, gotoxy, setw or anything.. Only basic for loops...

???

puzzle....

Hi all,
One good problem I come across was to give the algo for finding out the sub array whose sum is the heighest across the original array? I mean find out consecutive number in the array whose sum is heighest across the array which is having both +ve and -ve numbers.

(posted on puzzles@c)

undefined behaviour

y is this behaviour undefined

char *p = "Hello";
*p = 'h'; // this is where gcc gave segmentation fault.

its given in K & R that the above action gives undefined behaviour, but couldnt figure the reason.

iNTERVIEW qUESTION

Recently I sat for an interview and have been asked a tricky question on C...

How can we multiply any two large number(may be 10-15 digits long) and print it....!!!
Before hand the programmer will have no idea how big the the couple of numbers would be!

Can anybody solve this???

(posted by http://www.orkut.com/Profile.aspx?uid=17124471744203924609)

Intresting Puzzle!!

Sove this ->

A program in C to find out 10 digit nos. whic has all digits (0,1,2,3.....9) and is a perfect square.
Make the Program as short as possible !

Programming puzzle

Simple one, what is the output & WHY?

int a=3;

int f()
{
return a=1,2;
}

main()
{
printf("%d %d\n",f(),a);
}

(

Please explain!!!!!!

I am compiling the following code in Turbo C & i am getting
the following o/p....

void main()
{
int i;
i=10/0; // or any other number in place of 10
printf("%d",i);
}

and i'm getting the o/p as 10 (same is the case if i use
any other no. in place of 10).


Also, if i do....

main()
{
int i=10;
i/=0;
printf("%d",i)
}

then i'm getting the o/p as Divide Error at runtime..


Please explain why it's happening.......

(posted by http://www.orkut.com/Profile.aspx?uid=2703908295022053136)

How to Acces the flags of TCP Header

CAn any one help on this:

I have a client and server running (AF_INET,socket:Port), server sends some data to client, which is encapsulated in TCP, i could see the header in the Ethreal, now in the program i need to alter the flags in TCP Header say to set PSH to zero or one,

Is there any API for this, or any other way to go around

(posted by http://www.orkut.com/Profile.aspx?uid=2999564862497008552)

Tricky question

Hello Friends,
Little Tricky question, without using printf, print HELLO WORLD in normal C program.....How?

Thanks in Advance

(posted by http://www.orkut.com/Profile.aspx?uid=1539117400373858425)

c program without semicolon

i want a c prog. to print Hello

but it should jot contain any semicolons

Team Members

please keep on adding ur email id to this post if u want to become a team member of this website....I will send u the invitation for this website...

ternary

void main()
{
int a=1;
a=a?a++:a++;
printf("%d",a);
}
the ans here is 1

void main()
{
int a=1,b;
b=a?a++:a++;
printf("%d",b);
}
here it is 2

can anyone explain wen exactly does a get incremented in the first prob..

(http://www.orkut.com/CommMsgs.aspx?cmm=1366247&tid=2491312994285729847)

what is the diffrence btw
if(x==0)
and
if(0==x)

in wat cases one of above may fail???

posted on (http://www.orkut.com/Community.aspx?cmm=1366247)


Free Web Counter