第一章 c语言基础程序.doc

  1. 1、本文档共6页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
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

文档评论(0)

kehan123 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档