交互

//与用户进行简单的交互
//实现的功能以下,用户输入名字和体重,计算机计算输出体积以及名字占的字节数以及储存名字的容量

#include <stdio.h>
#include <string.h>
#define DENSITY 62.4
int main()
{
float weight, volume;
int size, letter;
float name[40];
printf(“hello,what is your name\n”);
scanf("%s", name);
printf("%s,what is your weight in pounds?\n", name);
scanf("%f", &weight);
volume = weight/DENSITY;
size = sizeof(name);
letter = strlen(name);
printf(“well,%s,your volume is %2.2f cubic feet.\n”, name, volume);
printf(“also,your first name has %d letter,\n”, letter);
printf(“we have %d bytes to store it.\n”, size);
return 0;

}

  1. debug很重要,能学会看下面的注释
  2. sizeof在这里面没有定义,不知道怎么解决,以后还需要花时间了解这个软件
  3. 有关c语言的编写,必须先申明,否则会报错。

猜你喜欢

转载自blog.csdn.net/AKG420/article/details/87930030
今日推荐