C语言-Day 4

2021/6/18 23:28:56

本文主要是介绍C语言-Day 4,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

学习内容:

1. 逻辑类型:

  • bool

2. 逻辑运算:

  • :逻辑非
  • &&:逻辑与
  • ||:逻辑或

3.条件运算

4.if-else的运用


学习时间:

下午20点–下午22点


学习产出:

1.bool的运用

#include<stdio.h>
#include<stdbool.h>

int main()
{
   bool b=6>5;
   bool t= true;
   t=2;
   printf("%d\n",b);
   return 0;

}

2.逻辑运算

#include<stdio.h>

int main()
{
	int a=-1;
	if(a>0&&a++> 1){
	printf("OK\n");
	}
	printf("%d\n",a);
	
	return 0;
 } 

3.swich的运用

#include<stdio.h>

int main()
{
	const int MRN = 2;
	int type;
	
	scanf("%d",&type);
	
	switch(type){
	
	case 1:
		printf("你好");
		break; 
	case 2:
		printf("早上好");
		break;
	case 3:	
		printf("晚上好");
		break;
	case 4:
		printf("再见");
		break;
	default:
		printf("啊?什么啊?");
		break; 
	}
	} 


这篇关于C语言-Day 4的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程