Download - Questions typedef and macros
![Page 1: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/1.jpg)
![Page 2: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/2.jpg)
Primitive Syntax : typedef existing-type new-name ;
Examples:
![Page 3: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/3.jpg)
![Page 4: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/4.jpg)
Is this correct / valid?
How do I type define an String
![Page 5: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/5.jpg)
![Page 6: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/6.jpg)
![Page 7: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/7.jpg)
![Page 8: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/8.jpg)
![Page 9: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/9.jpg)
![Page 10: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/10.jpg)
In the above declaration, SavingsAccount is an Variable or Typedefinition?.
![Page 11: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/11.jpg)
![Page 12: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/12.jpg)
P1 is pointer to constP2 is constant
pointerP3 is constant
pointerP4 is constant
pointer
![Page 13: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/13.jpg)
int main( ){
#define PI 3.14int r = 3;float area = PI * r * r;printf(" %f",area);
}
![Page 14: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/14.jpg)
void calculateArea( );int main( ){
#define PI 3.14 calculateArea( );
}
void calculateArea( ){
int r = 3;float area = PI * r * r;printf(" %f",area);
}
![Page 15: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/15.jpg)
void calculateArea( );int main( ){
#define PI 3.14int r = 3;float area = PI * r * r;printf(" %f",area); calculateArea( );
}
void calculateArea( ){
int r = 3;float area = PI * r * r;printf(" %f",area);
}
![Page 16: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/16.jpg)
void calculateArea( );int main( ){
#define PI 3.14int r = 3;float area = PI * r * r;printf(" %f",area);#undef PI calculateArea( );
}void calculateArea( ){
int r = 3;float area = PI * r * r;printf(" %f",area);
}
void calculateArea( );int main( ){
#define PI 3.14int r = 3;float area = PI * r * r;printf(" %f",area); calculateArea( );#undef PI
}void calculateArea( ){
int r = 3;float area = PI * r * r;printf(" %f",area);
}
![Page 17: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/17.jpg)
1. int main( )2. {3. int a = 5;4. if( a )5. printf(“if
executed");
6. #if (a)7. printf("#if
executed");8. #endif9. }
a) Compilation Error in Line 6
b) Both printf are executedc) Only the first pf is
executed
![Page 18: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/18.jpg)
1. #define a 02. int main( )3. {4. if( a )5. {6. #ifdef a7. printf(“A")8. #endif9. }10. }
a) No Error, No Outputb) Error in printf - ; missing
1. #define a 02. int main( )3. {4. if( a )5. {6. #if a7.
printf(“A")8. #endif9. }10. }
![Page 19: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/19.jpg)
![Page 20: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/20.jpg)
#define MAYUR 0int main( ){
#if MAYURprintf("#if executed");
#endif#ifdef MAYUR
printf("#ifdef executed");#endif
}
![Page 21: Questions typedef and macros](https://reader035.vdocument.in/reader035/viewer/2022062302/5878303d1a28abef5d8b67ef/html5/thumbnails/21.jpg)
int main( ){
#ifdef MAYURprintf("#ifdef executed");
#endif}
gcc file.c -DMAYUR