1. What the following code snippet do:
#define func(a,b) \
({ typeof (a) _a = (a); \
typeof (b) _b = (b); \
_a > _b ? _a : _b; })
2. What the following program going to output:
#include
main()
{
int i=0;
if(i)
{
#define VARIABLE_SET
}
#if defined(VARIABLE_SET)
printf("Hello\n");
#else
printf("World\n");
#endif
}
Ans:
Hello.
And now the question is why Hello, and why not World.
3. How the following code snippet is going to expand after pre-processing:
#define MYCASE(item,id) \
case id: \
item##_##id = id;\
break
switch(x) {
MYCASE(widget,23);
}
Ans:
case 23:
widget_23 = 23;
break;
4. What is the o/p?
1 #include
2 //fixed
3 void printer(char **);
4
5 void printer(char ** tmp)
6 {
7 //c> tmp = (char ** ) malloc(sizeof("world"));
7 tmp = (char ** ) malloc(sizeof("world"));
8 strcpy(tmp, "world");
9 }
10 main()
11 {
12 //a>
13 char * tmp = (char * ) malloc("Hello");
14 strcpy(tmp, "Hello");
15 //b>
16 //char tmp[sizeof("Hello")] = "Hello";
17 printer(&tmp);
18 printf("%s\n", tmp);
19 }
20
Ans:
The answer to this question is simple, problem lies in line 7. In line 7, you are creating a new memory location and storing the new data "World" in to that new location, and not the old location pointed by tmp in main.
5. How do you disable compiler optimization of C programs?
Ans:
In case of Microsoft Visual Studio, on the "Code Optimization" section of the project properties, you have an option to disable optimization by passing /Od. Similarly you can use -Od in GNU GCC compiler to disable code optimization.
6. main(){printf("%d");}
Ans:
The output is a garbage value.
8. What are the difference of the following:
malloc();
delete ;
9.
free();
10. What will be the effect of closing a file multiple times?
fopen();
fclose();
fclose();
11.
How do you initialize a member variable of a structure or union?
12.
13. Here is the lucky fellow to qualify him as the No 13th question. This is not a question as such, here are two tips while workin in Microsoft Windows:
Tips 1:
I lost the Windows Start Button
The other day, again in the night, instead of sleeping, I had to work. While working I lost the Windows start button. I did this trick and got the Start bar. Open the Task manager, and File>New Task (RUN) > explorer.exeThis will bring back the Start button.
Ctrl+Shift+Esc will pop up the Task Manager.
~Kongkon
Tips 2:
CTRL+ALT+DEL
I was working late night in a Windows machine using the Remote Desktop facility to a London machine. While I was working, I fall asleep for some time. And, when I got up I saw that my Windows start bar is missing. And I need to check the Task Manager for killing some processes. I tried CTRL+ALT+DEL, but results in Windows Security window in my local machine. Later, I figured out that, CTRL+ALT+END does the effect of CTRL+ALT+DEL inside a Remote Desktop.In Local Windows: CTRL+ALT+DEL
In RDP: CTRL+ALT+END
In RealVNC: F8 or Shift+Ctrl+Alt+Del or Ctrl+Alt Gr + Del
In VMWare: Ctrl+Alt+Ins
~Kongkon
Good Night Guys...
(-|-)
No comments:
Post a Comment