main()

{

extern int i;

i=20;

printf("%d",sizeof(i));

}

Answers were Sorted based on User's Feedback



main() { extern int i; i=20; printf("%d",sizeof(i))..

Answer / susie

Answer :

Linker error: undefined symbol '_i'.

Explanation:

extern declaration specifies that the variable i is defined
somewhere else. The compiler passes the external variable to
be resolved by the linker. So compiler doesn't find an
error. During linking the linker searches for the definition
of i. Since it is not found the linker flags an error.

Is This Answer Correct ?    22 Yes 4 No

main() { extern int i; i=20; printf("%d",sizeof(i))..

Answer / sahoo845

This program throws error in compilation. Because variable i is declared but not defined anywhere. Essentially, the variable isn’t allocated any memory. And the program is trying to change the value to 20 of a variable that doesn’t exist at all.

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More C Code Interview Questions

Write a procedure to implement highlight as a blinking operation

2 Answers  


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


struct Foo { char *pName; char *pAddress; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); obj->pName = malloc(100); obj->pAddress = malloc(100); strcpy(obj->pName,"Your Name"); strcpy(obj->pAddress, "Your Address"); free(obj); printf("%s", obj->pName); printf("%s", obj->pAddress); } a. Your Name, Your Address b. Your Address, Your Address c. Your Name Your Name d. None of the above

2 Answers   HCL,


Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

13 Answers   Intel, Microsoft, TCS,


write a c program to Create employee record by taking details like name, employee id, address and phone number. While taking the phone number, take either landline or mobile number. Ensure that the phone numbers of the employee are unique. Also display all the details

2 Answers   TCS,






main() { int a[10]; printf("%d",*a+1-*a+3); }

1 Answers  


&#8206;#define good bad main() { int good=1; int bad=0; printf ("good is:%d",good); }

2 Answers  


#define a 10 int main() { printf("%d..",a); foo(); printf("%d..",a); return 0; } void foo() { #undef a #define a 50 }

3 Answers  


What is the output of the program given below main() { signed char i=0; for(;i>=0;i++) ; printf("%d\n",i); }

1 Answers  


main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }

1 Answers  


main() { printf("%x",-1<<4); }

3 Answers   HCL, Sokrati, Zoho,


main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(ā€œ%dā€ ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(ā€œ%d ā€ ,*p); p++; } }

1 Answers  


Categories