|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
C
DETAILS
Question: main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }
Answer: Ans :1,2 because the *p is the pointer varible but the type is character.p is apointer variable.
|
|
|
Category |
C Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9645 users |
Added on |
7/19/2011 |
Views |
72633 |
Rate it! |
|
|
Question:
main() { char *p; printf("%d %d ",sizeof(*p),sizeof(p)); }
Answer:
Ans :1,2 because the *p is the pointer varible but the type is character.p is apointer variable. Source: CoolInterview.com
1,4 its 1 because it holds d data of type character so only... its 4 because its d address not any type... Source: CoolInterview.com
Answered by: Vivek Gopinathlal | Date:
| Contact Vivek Gopinathlal
correct answer is 1 and 2 because *p is a character pointer which holds the value of a character variable i.e. is 1 byte whereas sizeof(p) ...here p is used to hold the address of the character pointer hence 2(adress in integer) Source: CoolInterview.com
Answered by: Debapriya Maity | Date:
| Contact Debapriya Maity
1,2bcoz, *p=means the value at address p(which hold the character i.e one byte in size) sizeof(p)= indicates that the "p" is a pointer to char type data type which holds its address, i.e any how the pointer size is always 2byte , as the address is whole no . and 2 byte is sufficient for it Source: CoolInterview.com
Answered by: PRASANNA KUMAR DAS | Date: 3/12/2010
| Contact PRASANNA KUMAR DAS
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } }
|
case 1: printf("one"); br - C Interview Questions & Answers">
View Answer
|
|
How can you get the number of elements in an array allocated dynamically at runtime? For example - int *p = (int *) malloc(sizeof(int) * n);
int numElems = ??????? /* n is not available here */
|
View Answer
|
|
What is the draw back in using friend function in c++
|
View Answer
|
|
In the following code, in which order the functions would be called? x = f1(23,14)*f2(12/4)+f3();
a) f1, f2, f3 b) f3, f2, f1 c) The order may vary from compiler to compiler d) None of the above
|
View Answer
|
|
What would be the output of the following program? main() { const int x=5; int *ptrx; ptrx=&x; *ptrx=10; printf("%d",x); }
|
View Answer
|
|
According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments?
|
View Answer
|
|
Would the following program compile?
main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("n%u%u",j,k); }
|
View Answer
|
|
If the following program (myprog) is run from the command line as myprog friday tuesday sunday, What would be the output?
main(int argc, char *argv[]) { printf("%c",*++argv[1]); }
|
View Answer
|
|
If the following program (myprog) is run from the command line as myprog friday tuesday sunday, What would be the output?
main(int argc, char*argv[]) { printf("%c",**++argv); }
|
View Answer
|
|
What would be the output of the following program?
main() { char near * near *ptr1; char near * far *ptr2; char near * huge *ptr3; printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3)); }
|
View Answer
|
|
What would be the output of the following program?
main() { int y=128; const int x=y; printf("%d",x); }
|
View Answer
|
|
What would be the output of the following program?
main() { int y=128; const int x=y; printf("%d",x); }
|
View Answer
|
|
If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday What would be the output?
main(int argc, char *argv[]) { while(--argc >0) printf("%s",*++argv); }
|
View Answer
|
|
If the following program (myprog) is run from the command line as myprog 1 2 3, What would be the output?
main(int argc, char *argv[]) { int i,j=0; for(i=0;i<argc;i++) j=j+ atoi(argv[i]); printf("%d",j); }
|
View Answer
|
|
If the program (myprog) is run from the command line as myprog 1 2 3 , What would be the output?
main(int argc, char *argv[]) { int i; for(i=0;i<argc;i++) printf("%s",argv[i]); }
|
View Answer
|
|
In which line of the following, an error would be reported? 1. #define CIRCUM(R) (3.14*R*R); 2. main() 3. { 4. float r=1.0,c; 5. c= CIRCUM(r); 6. printf("n%f",c); 7. if(CIRCUM(r))==6.28) 8. printf("nGobbledygook"); 9. }
|
View Answer
|
|
What is the output of the following program?
#define SQR(x) (x*x)
main()
{
int a,b=3;
a= SQR(b+2);
printf("%d",a);
}
|
View Answer
|
|
What would be the output of the following program? main() { int i=4; switch(i) { default: printf("n A mouse is an elephant built by the Japanese"); case 1: printf(" Breeding rabbits is a hair raising experience"); break; case 2: printf("n Friction is a drag"); break; case 3: printf("n If practice make perfect, then nobody's perfect"); } }
|
View Answer
|
|
main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } }
|
View Answer
|
|
main() { if (!(1&&0)) { printf("OK I am done."); } else { printf("OK I am gone."); } }
|
} else { printf("OK I am go - C Interview Questions & Answers">
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All C Interview Questions & Answers - Exam Mode /
Learning Mode
|