什么是这个程序的输出,如果0(零)然后如何。 [英] What is output of this program and if 0(zero ) then how.?

查看:111
本文介绍了什么是这个程序的输出,如果0(零)然后如何。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#包括< stdio.h中> 
int main(void)
{
int a = 1,b = 2,c = 3;

a = b == c;
printf(%d,a);

printf(\ n);


}





我的尝试:



这个程序的输出是什么,如果为0(零)那么how.?

解决方案

输出为0.

这是因为 b == c 是' false '等于0.

如果是''则为1(例如,如果b为3)。

在线试用:免费在线IDE和终端 [ ^ ]



如果您更愿意使用 true false 就像在C#中一样,请参阅: [ stdbool.h

#include<stdio.h>
int main(void)
{
	int a=1, b=2,c=3;
		
	a=b==c;
  printf("%d",a);

 printf("\n");

    
}



What I have tried:

what is output of this program and if 0(zero ) then how.?

解决方案

The output is 0.
This is because b==c is 'false' which is equal to 0.
If it were 'true' it would be 1 (e.g. if b would be 3).
Try it out online: Free Online IDE and Terminal[^]

If you would rather like to use true and false like in C#, see: [stdbool.h]


这篇关于什么是这个程序的输出,如果0(零)然后如何。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆