Tutor profile: Bibhuti Bhusan S.
Subject: C++ Programming
Is it possible to execute any statement before the execution of main() function?
Yes, it is possible. If we instantiate an object of a class globally, then the constructor of the class will be executed before the execution of main() function.
Subject: C Programming
If a structure has two member variables. One is of type int and the other is of type char. Then what will be the size of the structure when it is created in memory?
The compiler in which it will be tested, if the size of the int is 4 bytes in that compiler, then the size of the structure will be 8 bytes. Though the char takes only 1 byte and int takes 4 bytes, ideally the size of the structure should be 5 bytes, but to align the memory allocation to the word boundary which is normally 4 bytes, the compiler will allocate 8 bytes instead of 5 bytes. If the word boundary will be adjusted to 1 byte using #pragma pack, then the structure will take 5 bytes in memory.
A 5 volt power supply is given. Only using basic electronic components (without using any devices like multimeter, oscilloscope, etc.), how to know if the supply is DC (Direct Current) or AC (Alternating Current).
If we connect a 5 volt LED to the supply and observe if it is glowing. Then reverse the terminals of the LED and connect again. If the LED glow in both cases, then it is an AC supply. If it glow in one way and not in the other way, then it is DC supply.
needs and Bibhuti Bhusan will reply soon.