- 10
- 0
- 约4.11千字
- 约 6页
- 2017-06-24 发布于湖北
- 举报
4. Some Tests With switch-case :
A student’s letter grade is calculated according to the following schedule.Write a C program with switch that accepts a students numerical grade.and displays the letter grade.
Numerical grade letter grade
greater than or equal to 90 A
less than 90 but greater than or equal to 80 B
less than 80 but greater than or equal to 70 C
less than 70 but greater than or equal to 60 D
less than 60 E
#includestdio.h
main()
{
int marks,index;
printf(please input a mark\n);
scanf(%d,marks);
index=marks/10;
switch(index)
{
case 10:
case 9:
printf(grade=A\n);
break;
case 8:
printf(grade=B\n);
break;
case 7:
printf(grade=C\n);
break;
case 6:
printf(grade=D\n);
break;
default:
printf(grade=E\n);
break;
}
}
1. Some Tests With if –else :
Write a program to determine whether a input number is greater than 100 and less than 200 and divisible by 7 or not,please print the appropriate message on the screen.
Document the output for your report. You dont have to write all the sections in the report. Just paste the program and its output in a word file.
#includestdio.h
main()
{
int a;
printf(input a number\n);
scanf(%d,a);
if(a100a200a%7==0)
printf(true);
else
printf(false);
}
3. Some Tests With getchar() and putchar:
Write a C program that can convert capital letter to lowercase.Example: input ‘A’,then the screen output ‘a’.
When you are sure your program is working correctly,use it to complete the following table.
uppercase lowercase A F G K R Y #includestdio.h
main()
{
char ch;
printf(please input a char);
ch=getchar();
ch=ch+32;
putchar(ch);
}
1. Some Tests With while :
Write a C program that continuously requests a grade to be entered.If the grade is less than 0 or greater than 100,your program should print an appropri
您可能关注的文档
- 4第二节 互连技术FCB.pdf
- 第八章 材料力学资料.doc
- 第六章 电子文件长期存取技术要求.pptx
- 音频信息的采集及编辑.docx
- 第八章 TCL彩电总线进入方法大全.docx
- 浅谈MRI图像质量控制.docx
- 全国大学生网络安全知识竞赛试题和答案.docx
- 第十三章 计算机组成原理测试题一.docx
- 互联网+新形势下-企业在电子商务经营中所面临过的法律风险和应对措施.docx
- 影响药品储存质量因素.doc
- 人教版九年级英语Unit 4曾害怕课件3a-4c.pdf
- 雅思口语考题回顾:朗阁海外考试研究中心2019年10月10日Part 1考题总结.pdf
- 2026届高三地理一轮复习课件小专题河流袭夺.pptx
- 【名师原创】复习专题5 三角函数 作者:合肥市第八中学 蒲荣飞名师工作室.docx
- 高中数学一轮复习 微专题2 抽象函数.docx
- 高中数学——复习专题4 空间向量与立体几何.docx
- 高中数学一轮复习 微专题3 空间几何体中的截面、轨迹问题.docx
- 高中数学一轮复习 微专题4 空间几何体的最值、范围问题.docx
- 导流洞施工质量通病防治手册.docx
- 江苏省徐州市第一中学、徐市第三中学等五校2026届高三上学期12月月考历史试题含答案.docx
原创力文档

文档评论(0)