C Test Question - C Test 1st round written test Refer the...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
C Test 1 st round written test Refer the Dennis Book 1. Pointer can be converted into void pointer - Say True or False 2. What will be the ' break' document? 3. int main () { int a,b,c; printf ("%d",scanf ("%d%d%d",&a,&b,&c); } 4. Int main () { struct { int a; int b; } x,y; x.a=10; x.b=20; y=x; printf("%d,%d,%d",y.a,y.b); } 5.int main() { int oct=1; switch (oct) { Default: printf("default case"); break; Case 1: printf("case 1"); } } 6. int main() { enum number = { one=1,two,three=two-1,four=three-1} } The o/p three=? , Four=? 7. #define swap (int a,b) a=a+b:b=a-b;a=a-b; int main() { int a,b; a=10; b=20; swap(a,b);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
printf("%d,%d",a,b); swap2(a,b); printf("%d,%d",a,b); } swap2(int a,int b) { int c; c=a; a=b; b=c; } 8.int main() { int i=0; j=0; printf("Demo"); printf("case some"); } 9. int main() { int x[5]={1,2,3,4,5} int *p; p=x; p++ printf("%d";*p); } 1. What error in this program? Explain Void main () { Char*p=”Protech”; *(p+5)=”Technology”; Fun(p); Printf(“%s”,p); } fun(int*p) { Strcat(p,”protech soft”); }
Background image of page 2
2.Write a program for Pointer to Function? Void printf(char*p) { Printf (“%c”,*p++); } Void main() { Char name[]=”ptr soft”; Print(name); } 3.Write a program ,one string to another string with concatenation but not using strlen (),strcpy(),strcmp() 4. Write a program structure to function? 5.Dynamic pointer, Static pointer with examples? 1.error checking 2.Write a function in two lines for one string to another concatenation without using strlen(),strcat(),strcpy()? 3.Write a program for pointer to function,pointer to structure? 4.Write notes on static? 1.what is static method in c? 2.write c a program using HEAP method using function to pointer and structure to pointer 3.write a c program function in 2 line concatenate one string and another except srtcpy srtcpy Pointers are data types that hold integer values, those "integer" values are simply addresses of another  variables.  Example:  int x = 15; // this is an integer variable with value 15  int* ptr; // this is a pointer to an integer 
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ptr = &x; // now we assigned the address of x to the pointer ptr  // if you want to access the value of x (15 in this example),  // you should use the deterrence *  // so you can say:  printf("%d", *ptr); // this will print 15  // you can print the value of ptr (which is the address of x) using:  printf("%p", ptr); // this will print an integer, which is the address of x.  ==========================================================  More explanation, let's imagine that this is a memory:  -00--01-02-03-04 =====> these are the address of the memory  |--- |--- |---|---|---| =====> values inside the memory  For the example I gave before, let's imagine the following:  -00-01-02--03--04  |---|15|--- | 01 |---|  ------x------- ptr  As you can see, x hold the value 15, ptr holds the value 01 which is actually the address of x. Now ptr have 
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

C Test Question - C Test 1st round written test Refer the...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online