第4堂课后作业

来源:互联网 发布:手机酷狗链接不到网络 编辑:程序博客网 时间:2024/05/21 22:42

作业1:

Visual Studio 2012 主要用于C++、C#和VB语言的开发

······················································································分割线······················································································

作业2:

1,分析问题

根据问题来设计一种解决方案。

2编制程序

通过程序语言严格描述这个方案。

3编译

编译中发现错误,要分析原因,修改源程序。

4连接

连接中发生错误,要分析原因,修改源程序。

5调试运行

调试运行中发现问题分析本身有错误,要重新分析问题.

·································································分割线····················································································

作业3-1:

1) -abc    8) #micro   合法的变量名,在c语言中,只能由字母,数字和下滑线组成,且第一位只能是字母或下划线。

3) for    11) while       c语言中的基本字不能成为变量名

作业3-2:

(1):int的特点是保存整数,常用于年龄、月份等数据的保存。
(2):无符号整型unsigned int 和int类似,但只取正值。

(3):短整型 short int 在32位机中占2个字节

(4):长整型 long int 在32位机中占8个字节

(5): 无符号的长整型的最高位不代表正负,所以它的大小比普通长整大,但同时也失去了表示负数的功能

(6): 字符型 char 表示字符串
(7):无符号字符型 unsigned char   unsigned是无符号字符,只有正没有负,char是8位,是0~255

(8) :单精度 float   float的精度是6位有效数字,取值范围是10的-38次方到10的38次方,float占用4字节空间
(9): 双精度double   double的精度是15位有效数字,取值范围是10的-308次方到10的308次方,double占用8字节空间

(10) 长双精度 long double   long double的精度不少于double的精度,就像int和long int一样

····································································分割线············································································

作业4:

#include<stdio.h>
void main()
{
 char tip[11]="yanhaofeng";
  printf("%c %c\n",tip [0],tip[3]);
}
效果图

···················································································································································
作业5:

#include <stdio.h>

int main()

{

printf("%d\n",139133);

printf("%f\n",3.1415926);

}

作业6

6-1

(1):#include<stdio.h>
void main()
{
 int x;
 x= 25 + 0125;
printf("x=%d",x);
}

(2)#include<stdio.h>
void main()
{
 int x;
 x=24 * 3 / 5 + 6;
printf("x=%d\n",x);
}
(3)#include<stdio.h>
void main()
{
 int x;
 x=  36 + - (5 - 23 ) / 4;
printf("x=%d\n",x);
}
(4)#include<stdio.h>
void main()
{
 int x;
 x= 35 * 012 + 27 / 4 / 7 * (12 - 4);
printf("x=%d\n",x);
}
`````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
6-2
(1)#include<stdio.h>
#include<math.h>
void main()
{
 int x;
 x=3 * (2L + 4.5f) - 012 + 44 ;
printf("x=%d\n",x);
}
(2)#include<stdio.h>
#include<math.h>
void main()
{
 int x;
 x=3 * (int)sqrt(144.0);
printf("x=%d\n",x);
}
(3)#include<stdio.h>
#include<math.h>
void main()
{
 int x;
 x=cos(2.5f + 4) - 6 *27L + 1526 - 2.4L ;
printf("x=%d\n",x);
}
 
由浮点型转换为整型
·································································································分割线·····················································································
 
 
原创粉丝点击