其他分享
首页 > 其他分享> > 课程1.6 练习 第1章

课程1.6 练习 第1章

作者:互联网

复习并巩固一下C,感觉C学的不够好,买了本书从头过一遍


练习
·1.判断真假
a. 通常,C语言语句是大小写敏感的 。(T)
b. 默认情况下,C语言语句是位置敏感的。(F)对位置不敏感
c.C语言语句必须以句号结尾。(F)分号
e.main(){}是一个完整且正确的C程序(T)
f. printf 和main都是C语言的单词。(T)
·
2.在下面语句中查找错误
a.void main (void);
void main (void) 该语句没有分号
b.printf ( “Do we need parentheses here?”);
没错误
c.printf ( “where do we need a blank space?”);
没错误
d.printf(" Is any thing wrong here?")
printf(“Is any thing wrong here?”)
3.输入,编译并运行下面程序:
main ( )
{ printf (“There is no class tomorrow!”); }
改正你发现的任何错误。


解答:
有瑕疵的代码F:\Cplus\1.0\test\test1-6\main.c|4|warning: return type defaults to ‘int’ [-Wimplicit-int]|
翻译:警告:返回类型默认为“int”
因为main函数没有定义返回类型,而返回类型默认为int
加完int 后
规范的代码

4.输入、编译并运行下面程序:
ma in() PRINTF *, (What is wrong?}
改正任何你发现的错误。


解答
这个就不用纠错了,因为它全是错。
正确如下
int main () { printf("What is wrong?"); }


解答

5.修改本课程的程序使得它在屏幕上打印你的姓名和地址

#include <stdio.h>
#include <stdlib.h>

int main ()
{
    printf("name    :On the wind \n");
    printf("address : https://blog.csdn.net/m0_46211715?spm=1011.2124.3001.5343");
    }


标签:1.6,int,void,练习,C语言,wrong,课程,printf,main
来源: https://blog.csdn.net/m0_46211715/article/details/118035341