TCS Company Programming Basics

What is the output of this C code?
#include
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%dn", k, *p, **p);
}
a) 5 5 5
b) 5 5 junk
c) 5 junk junk
d) Compile time error

Read Solution (Total 8)

TCS Other Question

What should the program below print?
#include
#include
#include
void myfunc(char** param){
++param;
}
int main(){
char* string = (char*)malloc(64);
strcpy(string, "hello_World");
myfunc(&string);
myfunc(&string);
printf("%sn", string);
// ignore memory leak for sake of quiz
return 0;
}
1. hello_World
2. ello_World
3. lo_World
4. llo_World
Given the below statements about C programming language:
1) main() function should always be the first function present in a C program file
2) all the elements of an union share their memory location
3) A void pointer can hold address of any type and can be typcasted to any type
4) A static variable hold random junk value if it is not initialised