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

  • 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

文档评论(0)

1亿VIP精品文档

相关文档