C语言程序设计试验二.docVIP

  • 77
  • 0
  • 约2.67千字
  • 约 6页
  • 2016-12-25 发布于贵州
  • 举报
实验二 逻辑运算和判断选取控制 (验证性实验 2学时) (一)、实验目的 1.了解逻辑量在C语言中的表示方法 2.学会使用逻辑运算符和逻辑表达式 3.熟练掌握if语句和switch语句 (二)、实验内容 1.写出下列程序的运行结果 (1)#include stdio.h void main( ) { int a,b,x=10,y=9; a=(--x == y++)? --x : ++y; b= y; printf(“%d,%d\n”,a,b); } 运行结果及分析: 8,10 (2)#include stdio.h void main() { int a=2,b=-1,c=2; if(ab) if(b0)c=0; else c+=1; printf(“%d\n”,c); } 运行结果及分析:2 (3)#include stdio.h void main( ) { int a=0,b=0,c=0; if(++a 0 || ++b 0) ++c; printf(“\na=%d,b=%d,c=%d”,a,b,c); } 运行结果及分析:a=1,b=0,c=1 (4)#include stdio.h void main() { int x=-1; switch (x) { default: printf(“a”);

文档评论(0)

1亿VIP精品文档

相关文档