Guess the OUTPUT | C Programming Tutorial | Tricky Question and Answer

preview_player
Показать описание
Here in this guess the output c programming language video tutorial for beginners we give you a c aptitude tricky question program which will be normally asked in interviews and you have to find the output of the program. In the end we explain the output.

When we build and run this program and we get the error at line number 6 and if I open up the error logs it says error At The Line Number 6 Invalid pre processor directive #check and then in the line number 8 it says error endif pre processor directive without a if pre processor directive.

now let’s see why we get this error.

In this program we have defined a macro called as check with the value of if and then we have defined another macro X with a value of 100.

And in this main function which we have used this check Macro here and then we are checking whether this X macro is containing a value of 100.
If it is so that we are including this line for the compilation process and then you know we have this printf function.

so here we are expecting this CHECK macro to expand to if and we are expecting it to work like #if here.

But in C programming the # and the preprocessor directive name cannot come from a macro expansion.

There are rules to use the preprocessor directives.

So first we need to use the symbol hash and then we need to write the pre processor directive name and then according to that pre processor directive name we will be writing the other values.

since this #CHECK is not a valid pre processor directive it generate the error.

This is about the first error and then we have another error and that is the endif preprocessor directive without the if pre processor directive.

Since this will not expand to #if, if we use this endif then it will be without a if pre processor directive.

so it generates that 2nd error.

SO one thing to remember is in C programming if you are using the preprocessor directives then the # and the preprocessor directive name cannot come from a macro expansion.

Watch the entire series at

Get the source code of this tutorial at our website

Watch Video tutorials in HINDI at

Catch us on Social Media
Рекомендации по теме
Комментарии
Автор

It's very nice and I liked it . But I want the same in c++ also

naveenajmeera
Автор

Y not u debug this and give a solution ???
So that viewer wil get more clarity !!!

SuriyaR
visit shbcf.ru