vinod


{ City } chennai
< Country > india
* Profession * software engineer
User No # 110088
Total Questions Posted # 0
Total Answers Posted # 7

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 7
Users Marked my Answers as Wrong # 1
Questions / { vinod }
Questions Answers Category Views Company eMail




Answers / { vinod }

Question { Wipro, 15464 }

int zap(int n)
{
if(n<=1)then zap=1;
else zap=zap(n-3)+zap(n-1);
}
then the call zap(6) gives the values of zap
[a] 8 [b] 9 [c] 6 [d] 12 [e] 15


Answer

Ans: 9

Is This Answer Correct ?    0 Yes 0 No

Question { TCS, 14947 }

identify the in correct expression
a.a=b=3=4;
b.a=b=c=d=0;
float a=int b=3.5;
d.int a;
float b;
a=b=3.5;


Answer

Answer b and d are Correct.
b.a=b=c=d=0;
d.int a;
float b;
a=b=3.5;

Is This Answer Correct ?    0 Yes 0 No


Question { TCS, 10910 }

what is y value of the code if input x=10
y=5;
if (x==10)
else if(x==9)
elae y=8;
a.9
b.8
c.6
d.7


Answer

int main()
{
int x = 10, y = 5;
if(x==10)
else if(x==9)
else y=8;
printf("%d",y);
return 0;
}
error: expected expression before 'else'

------------
int main()
{
int x = 10, y = 5;
if(x==10) {}
else if(x==9) {}
else {y=8;}
printf("%d",y);
return 0;
}

OP: 5

Is This Answer Correct ?    1 Yes 0 No

Question { Microsoft, 19150 }

# define prod(a,b)=a*b
main()
{
int x=2;
int y=3;
printf("%d",prod(x+2,y-10)); }

the output of the program is
a.8
b.6
c.7
d.none


Answer

Assuming '=' is added by mistake in the macro.
#define prod(a,b) a*b
int main()
{
int x=2, y=3;
printf("%d",prod(x+2,y-10));
return 0;
}
Ans: None
The output is -2
a*b
x+2*y-10
2+2*3-10
2+6-10
8-10
-2

Is This Answer Correct ?    4 Yes 1 No

Question { HCL, 24924 }

main()
{
char *p1="Name";
char *p2;
p2=(char *)malloc(20);
while(*p2++=*p1++);
printf("%s\n",p2);
}
what is the output?




Answer

int main()
{
char *p1="Name";
char *p2,*s1,*s2;;
p2=(char *)malloc(20);
s1 = p1;
s2 = p2;
while(*p2++ = *p1++);
printf("%s %s",s1,s2);
return 0;
}

Store the Start address of p1 and p2 before incrementing the pointer so that it could be later used to print the String.

Is This Answer Correct ?    1 Yes 0 No

Question { Hughes, 8525 }

If "AaBbCc" is passed to the char

char x(*a)
{
a[0]?x(a+1):1;
printf("%c",a[0]);
return 1;
}
what will be the output?


Answer

char x(char *a) // Argument Pointer declaration was missing
{
a[0]?x(a+1):1;
printf("%c",a[0]);
return 1;
}

Output: cCbBaA

Is This Answer Correct ?    0 Yes 0 No

Question { IBM, 25634 }

what is difference between ++(*p) and (*p)++


Answer

++(*p) (or) ++*p -> Pre-increment the Value
(*p)++ -> Post-increment the value

*++p -> Increment the Position and then obtain the Value
*p++ (or) *(p++) -> Obtain the Value and then increment the Position

Example:
#include
void main()
{
char str[10] = "Helyo";
char *p = str;
printf("%c
",++(*p)); // Pre-Increment the Value -> I
printf("%c
",++*p); // Pre-Increment the value -> J
printf("%c
",(*p)++); // Post-Increment the value -> J and increment to K

printf("%c
",*p++); // Post-Increment the position -> K and move to next position i.e. e
printf("%c
",*(p++)); // Post-Increment the position -> e and move to next position i.e. l
printf("%c
",*++p); // Pre-Increment the position and obtain value -> y

}

Is This Answer Correct ?    1 Yes 0 No