题目详情
当前位置:首页 > 职业培训考试
题目详情:
发布时间:2023-10-12 07:08:22

[单项选择]以下程序试图把从终端输入的字符输出到名为abc.txt的文件中,直到从终端读入字符#时结束输入和输出操作,但程序有错,出错的原因是( )。
#include<stdio.h>
main( )

FILE *fout:
char ch:
fout=fopen('abc.txt','w');
ch=fgetc(stdin);
while(ch!='#')

fputc(ch,fout);
ch=fgetc(stdin);

fclose(fout);

A. 函数fopen调用形式错误
B. 输入文件没有关闭
C. 函数fgetc调用形式错误
D. 文件指针stdin没有定义

更多"以下程序试图把从终端输入的字符输出到名为abc.txt的文件中,直到从"的相关试题:

[单项选择]以下程序试图把从终端输入的字符输出到名为abc.txt的文件中,直到从终端读入字符串#号时结束输入和输出操作,但程序有错
#include<stdio.h>
main( )

FILE * fout;
char ch;
fout=fopen(’abc.txt’’w’);
ch=fgetc (stdin);
while(ch!=’#’)

fputc(ch,fout);
ch=fgetc(stdin);

fclose(fout);

出错的原因是 ______。
A. 函数fopen调用形式错误
B. 输入文件没有关闭
C. 函数fgetc调用形式错误
D. 文件指针stdin没有定义
[单项选择]以下程序企图把从终端输入的字符输出到名为abc.txt的文件中,直到从终端读入字符#号时结束输入和输出操作,但程序有错。
#include<stdio.h>
main( )
FILE*fout;char ch;
four=fopen('abc.txt','w');
ch=fgetc(stdin);
while(ch!='#')
fputc(ch,fout);
ch=fgetc(stdin);

felose(fout);

出错的原因是()
A. 函数fopen调用形式错误
B. 输入文件没有关闭
C. 函数fsetc调用形式错误
D. 文件指针stdin没有定义
[填空题]

以下程序统计从终端输入的字符中大写字母的个数,num[0]中统计字母A的个数, num[1]中统计字母B的个数,其他依次类推。用#号结束输入,请填空。
#include <stdio.h>
#include <ctype.h>
main( )
{ int num[26]={0},i; char c;
while(( 【16】 )!=’#’)
if(isupper(c)) hum [c-’A’ ]+= 【17】 ;
for(i=0; i<26; i++)
printf("%c: %d/n ",i+’A’, num[i]);


[单项选择]以下程序企图把从键盘终端输入的字符输出到名为abc.txt的文件中,当从终端读到字符’#’时,结束输入和输出操作。但该程序有错。 #include <iostream> #include <fstream> using namespace std; int main( ) { ofstream ofile; char ch; ofile.open("d://abc.txt", ’W’); do{ cin>>ch; ofile.put(ch); }while(ch!=’#’); ofile.close( ); return 0; } 程序出错的原因是( )。
A. 成员函数open调用形式错误
B. 输入文件没有关闭
C. 成员函数put调用形式错误
D. 对象ofile定义错误
[填空题]以下程序从终端读入数据到数组中,统计其中正数的个数,并计算它们之和。 #include<stdio.h> main( ) {int i,a[20],sum,count; sum=count=0: for(i=0;i<20;i++)scanf("%d",______);/*第一空*/ for(i=0;i<20;i++) {if(______)/*第二空*/ {count++; ______;}/*第三空*/ } printf("count=%d,sum=%d/n",count,sum); }
[填空题]以下程序从终端读入数据到数组中,统计其中正数的个数,并计算它们之和,请填空。
#include <stdio, h>
main( )
int i, a [20], sum, count;
sum = count = 0 ;
for(i=0;i<20;i++)scanf("%d", );
for(i=0;i<20;i ++)
if(a[i] >0)
count + +;
sum+ = ;

prinff( "sum = % d, count = % d // n", sum, count );

[填空题]以下程序从终端读入数据到数组中,统计其中正数的个数,并计算它们之和。请填空。   main( )   { int i,a[20],sum,count;    sum=count=0;    for(i=0;i<20;i++= scanf("%d",【 】);    fro(i=0;i<20;i++=    { if(a>0)     { count++;       sum+=【 】;     }    }    printf("sum=%d,count=%d/n",sum,count);   =
[填空题]以下程序从终端读入数据到数组中,统计其中正数的个数,并计算它们之和。请填空。
main( )
int i,a[20],sum,count;
sum=count=0;
for(i=0;i<20;i++)scanf("%d",( 【16】 );
for(i=0;i<20;i++)
if(a[i]>0)
count++;
sum+=( 【17】 );


printf("sum=%d,count=%dhn",sum,count);

[填空题]当运行以下程序时,输入abcd,程序的输出结果是:______。
insert(char str[])
int i;
i=strlen(str);
while(i>0)
str[2*i]=str[i]; str[2*i-1]:’*’; i-;
printf("%s/n",str);

main( )
char str[40];
scanf("%s/n",str); insert(str);

[填空题]当运行以下程序时,输入abcd,程序的输出结果是______。
#include<string.h>
voidinsert(char str[])
int i;
i=strlen(str);
while(i>=0)
str[2*i+1]=str[i]; str[2*i]=’*’; i--;
printf("%s/n",str);

void main( )
char str[40];
scanf("%s",str); insert(str);

[填空题]当运行以下程序时,输入abcd,程序的输出结果是:______。
insert(char str[])
int i;
i=strlen(str);
while(i>0)
str[2*i]=str[i];str[2*i-1]=’*’;i--;
printf("%s/n",str);

main( )
char str[40];
scanf("%s",str);insert(str);

[填空题]以下程序功能是输入一个学生的成绩,如果输入的成绩不在0~100之间,则显示出错信息。 main( ) { int s; scanf("%d",&s); if(100>=s>=0) printf("输入的成绩是%d/n",s); else printf("输入成绩出错"); } 错误:______ 改正:______
[填空题]以下程序运行后输入:3,abcde<回车>,则输出结果是【 】   #include  <string.h>   move(char *str, int n)   { char temp; int i;    temp=str[n-1];    for(i=n-1;i>0;i--) str[i]=str[i-1];    str[0]=temp;   }   main( )   { char s[50]; int n, i, z;    scanf("%d,%s",&n,s);    z=strlen(s);    for(i=1; i<=n; i++= move(s, z);    printf("%s/n",s);   =

我来回答:

购买搜题卡查看答案
[会员特权] 开通VIP, 查看 全部题目答案
[会员特权] 享免全部广告特权
推荐91天
¥36.8
¥80元
31天
¥20.8
¥40元
365天
¥88.8
¥188元
请选择支付方式
  • 微信支付
  • 支付宝支付
点击支付即表示同意并接受了《购买须知》
立即支付 系统将自动为您注册账号
请使用微信扫码支付

订单号:

截图扫码使用小程序[完全免费查看答案]
请不要关闭本页面,支付完成后请点击【支付完成】按钮
恭喜您,购买搜题卡成功
重要提示:请拍照或截图保存账号密码!
我要搜题网官网:https://www.woyaosouti.com
我已记住账号密码