【试题033】C语言程序分析题1.1

1.题目:

void main(){ int a ,b,k=4,m=6,*p1=&k,*p2=&m;

a=(p1==p2);

b=(*p1)/(*p2)+7; printf("a=%d\n,b=%d\n",a,b);}

2.代码+分析:

#include 
void main() {
  int a, b, k = 4, m = 6, *p1 = &k, *p2 = &m;

  a = (p1 == p2);

  b = (*p1) / (*p2) + 7;
  printf("a=%d,b=%d\n", a, b);
  //分析:指针变量p1指向变量k,指针变量p2指向变量m
  //首先a = (p1 == p2),p1和p2不相等,所以a=0
  //然后b = (*p1) / (*p2) + 7,b=4/6+7=7
  //输出a=0,b=7
}

3.截图:

【试题033】C语言程序分析题1.1_第1张图片

你可能感兴趣的:(c语言,开发语言,笔记)