针对一下C语言程序,请按要求回答问题。
已知weekday. c源程序如下:
include<stidio. h>
include<conio. h>
/ *主函数* /
Int main()
{
Char letter;
Printf("please input the first letter,"Y'to exit!\n");
While((letter=getch())!="Y")//当输入字母为Y时结束
{
Switch(letter)
{
Case'S':
Printf("%c\n",letter);
Printf("please input second letter\n");//输入第二个字母
If((letter=getch())=='a')
Printf("Saturday\n");
Else if(letter=='u')
Printf("Sunday\n");
Else printf('data error\n);
Break;
Case'F':
Printf("fridaykn");
Break;
Case 'M':
Printf("mondayha");
Break;
Case 'T':
Printf("%c\n",letter);
Printf("please input second letter\a");//输入第二个字母
If((letter=getch())=='u')
Printf("Tuesday\n"):
Else if(letter=='h')
Printf("Thursday\n");
Break;
Case 'W':
Printf("Wednesday\n");
}
}
Return 0;
}
(1) 画出主函数main的控制流程图;
(2) 设计一组测试用例,使main函数的语句覆盖率尽量达到100%;
(3) Main函数的语句覆盖率能否达到100%?如果认为无法达到,需说明原因。
第1题:
12、一个C语言源程序中如果调用了函数fabs,那必须有编译预处理命令()。
A.#include <stdio.h>
B.#include <math.h>
C.#include <ctype.h>
D.#include <stdlib.h>
第2题:
2、某源程序使用了STC单片机的相关寄存器,则应该使用()预定义。
A.#include “intrins.h”
B.#include “STC15Wxxx.h“
C.#include “math.h”
D.#include “stdio.h”
第3题:
1、如下C语言程序,请填写结果。 程序: #include<stdio.h> int main() { int i=0; do { i++; } while(i<=3); printf("%d",i); return 0; } 该程序运行的结果是()。
第4题:
15、已知字符‘7’的ASCII码值是55,请写出如下程序的输出结果: #include <stdio.h> int main() { char c=‘5’ ; printf(“%d",c+3); }
第5题:
已知字符‘7’的ASCII码值是55,请写出如下程序的输出结果: #include <stdio.h> int main() { char c=‘5’ ; printf(“%d",c+3); }
第6题:
02610031:使用scanf函数时,在源程序开头()。
A.书写#include <stdio.h>
B.书写#include <math.h>
C.不必写#include
D.书写#include <scanf.h>
第7题:
#include命令可以包含一个含有函数定义的C语言源程序文件。
第8题:
使用scanf()函数时,在源程序开头必须写预处理命令()
A.#include <stdio.h>
B.#include <stdio >
C.include <stdio.h>
D.#include <scanf.h>
第9题:
使用VC6打开考生文件夹下的工程test34_1,此工程包含一个源程序文件test34_1.cpp,但该程序运行有问题,请改正程序中的错误,使该程序的输出结果为:
David 3123 1000
源程序文件test34_1.cpp清单如下:
include <iostream.h>
include <string.h>
class person
{
public:
char name[20];
unsigned long id;
float salary;
void print(){cout<<name<<' '<<id<<' '<<salary<<
/***************** found *****************/
}
void main( )
{
person p;
person *ptr;
/***************** found *****************/
ptr=p;
/***************** found *****************/
strcpy("David",ptr->name);
ptr->id=3123;
ptr->salary=1000;
ptr->print();
}