APP下载
首页
>
IT互联网
>
信息技术知识竞赛c语言
搜索
信息技术知识竞赛c语言
题目内容
(
单选题
)
要求通过while循环不断读入字符,当读入字母N时结束循环。若变量已正确定义,以下正确的程序段是()。

A、while((ch=getchar())!="N")printf("%c",ch);

B、while(ch=getchar()!="N")printf("%c",ch);

C、while(ch=getchar()=="N")printf("%c",ch);

D、while((ch=getchar())=="N")printf("%c",ch);

答案:A

信息技术知识竞赛c语言
有以下程序
#include "stdio.h"
#include "string.h"
void main( )
{ char str[100] ="How do you do";
strcpy( str + strlen(str)/2, "es she");
printf("%s\n", str);
}
执行后的输出结果是( )。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6860-c089-2897e0346513.html
点击查看题目
设有定义:struct {char mark[12];int num1;double num2;} t1,t2;,若变量均已正确赋初值,则以下语句中错误的是()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-54d8-c089-2897e0346502.html
点击查看题目
有以下程序段
  int i,n;
  for(i=0;i<8;i++)
  { n=rand()%5;
  switch (n)
  { case 1:
  case 3:printf("%d\n",n); break;
  case 2:
  case 4:printf("%d\n",n); continue;
  case 0:exit(0);
  }
  printf("%d\n",n);
  }
以下关于程序段执行情况的叙述,正确的是( )。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6090-c089-2897e034651c.html
点击查看题目
在嵌套使用if语句时,C语言规定else总是()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-50f0-c089-2897e0346508.html
点击查看题目
有以下程序
  #include
  main()
  { int x=1,y=0;
  if(!x) y++;
  else if(x==0)
  if (x) y+=2;
  else y+=3;
  printf("%d\n",y);
  }
  程序运行后的输出结果是()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6090-c089-2897e034651f.html
点击查看题目
已知字符0的ASCII码为十六进制的30,下面程序的输出是()。
main()
{ union { unsigned char c;
unsigned int i[4];
} z;
z.i[0]=0x39;
z.i[1]=0x36;
printf("%c\n",z.c);}
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6090-c089-2897e0346504.html
点击查看题目
判断两个字符串是否相等,正确的表达方式是( )。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-50f0-c089-2897e034651f.html
点击查看题目
请读程序:
main()
{ int a=1,b=2;
printf("%d\n",a=a+1,a+6,b+2);}
则上面程序的输出结果是()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-54d8-c089-2897e034651d.html
点击查看题目
设有以下程序段,则值为6的表达式是( )。
struct st { int n; struct st *next;};
static struct st a[3]={5,&a[1],7,&a[2],9,0 },*p;
p=&a[0];
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-54d8-c089-2897e0346515.html
点击查看题目
main()
{ int x=3,i;
for(i=0;i<3;i++) printf("%d",f(x));
}
int f(int a)
{ int b=0;
static c=3;
b++;c++;
return(a+b+c);
}
执行此程序后屏幕上显示的结果是()。
https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-5ca8-c089-2897e034650e.html
点击查看题目
首页
>
IT互联网
>
信息技术知识竞赛c语言
题目内容
(
单选题
)
手机预览
信息技术知识竞赛c语言

要求通过while循环不断读入字符,当读入字母N时结束循环。若变量已正确定义,以下正确的程序段是()。

A、while((ch=getchar())!="N")printf("%c",ch);

B、while(ch=getchar()!="N")printf("%c",ch);

C、while(ch=getchar()=="N")printf("%c",ch);

D、while((ch=getchar())=="N")printf("%c",ch);

答案:A

信息技术知识竞赛c语言
相关题目
有以下程序
#include "stdio.h"
#include "string.h"
void main( )
{ char str[100] ="How do you do";
strcpy( str + strlen(str)/2, "es she");
printf("%s\n", str);
}
执行后的输出结果是( )。

A. How do you do

B. es she

C. How are you

D. How does she

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6860-c089-2897e0346513.html
点击查看答案
设有定义:struct {char mark[12];int num1;double num2;} t1,t2;,若变量均已正确赋初值,则以下语句中错误的是()。

A.  t1=t2;

B. t2.num1=t1.num1;  

C. t2.mark=t1.mark;

D. t2.num2=t1.num2;

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-54d8-c089-2897e0346502.html
点击查看答案
有以下程序段
  int i,n;
  for(i=0;i<8;i++)
  { n=rand()%5;
  switch (n)
  { case 1:
  case 3:printf("%d\n",n); break;
  case 2:
  case 4:printf("%d\n",n); continue;
  case 0:exit(0);
  }
  printf("%d\n",n);
  }
以下关于程序段执行情况的叙述,正确的是( )。

A. for循环语句固定执行8次

B. 当产生的随机数n为4时结束循环操作

C. 当产生的随机数n为1和2时不做任何操作

D. 当产生的随机数n为0时结束程序运行

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6090-c089-2897e034651c.html
点击查看答案
在嵌套使用if语句时,C语言规定else总是()。

A. 和之前与其具有相同缩进位置的if配对

B. 和之前与其最近的if配对

C. 和之前与其最近的且不带else的if配对

D. 和之前的第一个if配对

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-50f0-c089-2897e0346508.html
点击查看答案
有以下程序
  #include
  main()
  { int x=1,y=0;
  if(!x) y++;
  else if(x==0)
  if (x) y+=2;
  else y+=3;
  printf("%d\n",y);
  }
  程序运行后的输出结果是()。

A. 3

B. 2

C. 1

D. 0

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6090-c089-2897e034651f.html
点击查看答案
已知字符0的ASCII码为十六进制的30,下面程序的输出是()。
main()
{ union { unsigned char c;
unsigned int i[4];
} z;
z.i[0]=0x39;
z.i[1]=0x36;
printf("%c\n",z.c);}

A. 6

B. 9

C. 0

D. 3

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-6090-c089-2897e0346504.html
点击查看答案
判断两个字符串是否相等,正确的表达方式是( )。

A. while(s1==s2)

B. while(s1=s2)

C. while(strcmp(s1,s2)==0)

D. while(strcmp(s1,s2)=0)

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-50f0-c089-2897e034651f.html
点击查看答案
请读程序:
main()
{ int a=1,b=2;
printf("%d\n",a=a+1,a+6,b+2);}
则上面程序的输出结果是()。

A. 2

B. 3

C. 4

D. 1

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-54d8-c089-2897e034651d.html
点击查看答案
设有以下程序段,则值为6的表达式是( )。
struct st { int n; struct st *next;};
static struct st a[3]={5,&a[1],7,&a[2],9,0 },*p;
p=&a[0];

A. p++->n

B. ++p->n

C. p->n++

D. (*p).n++

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-54d8-c089-2897e0346515.html
点击查看答案
main()
{ int x=3,i;
for(i=0;i<3;i++) printf("%d",f(x));
}
int f(int a)
{ int b=0;
static c=3;
b++;c++;
return(a+b+c);
}
执行此程序后屏幕上显示的结果是()。

A. 8 10 10

B. 7 9 10

C. 8 9 11

D. 8 9 10

https://www.shititong.cn/cha-kan/shiti/0005eb65-536a-5ca8-c089-2897e034650e.html
点击查看答案
试题通小程序
试题通app下载