All about programming in GNU/LINUX

Macros for true=1 and false=0

#include<stdio.h>

int main()
{

printf(“%d %d “,true , false );

}
This piece of code gives an error as “true” and “false” ,which we are trying to print are undeclared.

 

#include<stdio.h>
#include<stdbool.h>
int main()
{

printf(“%d %d “,true , false );

}

but by adding the header <stdbool.h> and running the code gives you can output of 1 0 , as the macros for true=1 and false =0 is defined in <stdbool.h>.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s