对于如下C语言程序 int main() { printf("Hello World\n"); fork(); printf("Hello World\n"); } 在UNIX操作系统中正确编译链接后,其正确的运行结果是
A.共打印出2行Hello World
B.共打印出3行Hello World
C.共打印出4行Hello World
D.共打印出5行Hello World
第1题:
有以下程序 #include <stdio.h> main() { int n,*p=NULL; *p=&n; printf("Input n:");scanf("%d",&p);printf("output n:");printf("%d\n",p); } 该程序试图通过指针p为变量n读入数据并输出,但程序有多处错误,以下语句正确的是
A.int n,*p=NULL;
B.*p=&n;
C.scanf("%d",&p)
D.printf("%d\n",p);
第2题:
分析下列程序。 int main() { printf("Hello") ; fork(); printf("Hello") ; fork(); printf("Hello") ; fork(); printf("Hello") ;} 不考虑其他因素,程序正常运行后共打印出多少个"Hello"?
A.15
B.11
C.7
D.4
第3题:
假设在UNIX操作系统环境下执行以下程序: main() { printf("Hello World\n"); fork(); printf("Hello World\n"); } 若程序正常运行,子进程创建成功,那么,屏幕上得到输出的有
A.1个Hello World
B.2个Hello World
C.3个Hello World
D.4个Hello World
第4题:
先有两个C程序文件T18.c和myfun.c同在TC系统目录(文件夹)下,其中T18.c文件 如下: include<stdio.h> include"myfun.C" main() {fun();printf("\n");} //myfun.c文件如下: void fun() { char s[80],c;int n=0; while((c=getchar())!='\n') s[n++]=c; n--; while(n>=0)printf("%c",s[n--]); } 当编译连接通过后,运行程序T18时,输入Hello!则输出结果是( )。
第5题:
有以下程序: #include <string.h> main() { char str[][20]={"Hello","Beijing"}*p=str; printf("%\n",strlen(p+20)); } 程序运行后的输出结果是
A.0
B.5
C.7
D.20
第6题:
有以下程序: # include<string.h> main() { char str[][20]={"Hello","Beijing"},*p=str; printf("%d\n",strlen(p+20)); } 程序运行后的输出结果是 ______。
A.0
B.5
C.7
D.20
第7题:
下列程序的输出结果是______。 #include<iostream> using namespace std; int main() { char a []="Hello, World"; char *ptr=a; while (* ptr) { if(*ptr)= 'a'&& *ptr' <= 'z') cout << char(*ptr+'A'-'a'); else cout << *ptr; ptr++; } return 0; }
A.HELLO,WORLD
B.Hello,World
C.hELLO, wORLD
D.hello,world
第8题:
运行下面程序时,从键盘输入字母H,则输出结果是
#include<stdio.h>
main()
{ char ch;
ch=getchar();
switch(ch)
{case ′H′:printf("Hello!\n");
case ′G′:printf("Good morning!\n");
default:printf("Bye_Bye!\n");
}
}
A.Hello!
B.Hello! Good Moring!
C.Hello! Good morning! Bye_Bye!
D.Hello! Bye_Bye!
第9题:
有如下程序void func1(int st[],int i){ printf("%c",st[i]); if(i}void func2(int st[],int i){ printf("%c",st[i]); if(i}main(){ char st[ ]="hello,friend! "; int i=0;func1(st,i); printf("\n");}程序执行后输出的结果是A.hello B.hel C.hlo D.编译出错
第10题:
有以下程序: #include<stdio.h> void func(int n) { int i; for(i=0;i<=n;i++)printf("*"): printf("#"); } main( ) {func(3);printf("????");func(4);printf("n\"); 程序运行后的输出结果( )。
A.****#????***#
B.***#????****#
C.**#????****#
D.****#????*****#