Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger


Sunday, 20 July 2008

Technical - C & C++ Paper - 7

Some Technical Questions

void main()
{
enum bool{true,false};
if(true==(2==3)
printf(“..
else
printf(“..
}

void main()
{
printf(“%d”,(float)3/2);
}

void main()
{
int (*func)(const *char)=strlen;
printf(“%d”, func(“Hello”);
}

void main() {
char *s=”Hello World”;
printf(“%c”,s);
}

File fp,fs;
fp=fopen(“tc.dat”,”w”);
fs=fopen(“tc.dat”,”w”);
putch(‘A’,fp);
putch(‘B’,fs); What will happen?

What is the equivalent of a[i] Ans: *(a+i)

int (*func)(int,int) is a pointer to a function with 2 integers as parameters and returning an integer value.

int *(*func)(int *,int *) is a pointer to a function with 2 integer pointers as parameters and returning a pointer to

an integer Which of a and b is true?
Ans: Both are true.

switch(float value) this is compiler error.

int a[5]={1,2,3,4,5};
int *p=a+1;
int *q=a+5;

int dif=q-p;
value of dif is 4 ( q-p is evalueated as q-p/sizeof int)

Switch(NULL)
ans: case 0: will be executed.

#define exp 5
printf("%d",exp++);
ans: compilation error lvalue required

strcat(str,str);
ans: compilation error

Pointers can be subtracted from each other, can be added, constant cab be added or subtrated from pointer, but multipilcation with constant to pointer is not possible.

int(*ptr)[10] pointer to array of 10 integers.

No comments:

Post a Comment