当前位置:网站首页>Chapter 5 programming
Chapter 5 programming
2020-11-08 23:53:00 【Cx330】
**2 Print values **
#include<stdio.h>
int main()
{
int a, b;
printf(" Enter the number you want : ");
scanf("%d", &a);
b = a;
while (b <= a + 10)
{
printf("%d\n", b);
b++;
}
}
````
** 3 Day to week **
#include <stdio.h>
int main()
{
int a, b, c;
printf(" Please enter the number of days :");
scanf("%d", &a);
printf("%d God =%d Zhou %d God \n", a, a / 7, a % 7);
return 0;
}
````
** 4 Height shift **
#include <stdio.h>
#define a 30.48
#define b 2.54
int main()
{
int feet;
float inches, cm;
printf("CONVERT CM TO INCHES!\n");
printf("Enter the hight in centimeters:");
scanf("%f", &cm);
while (cm > 0) {
feet = cm / a;
inches = (cm - feet * a / b);
printf("%.1fcm=%dfeet,%.1f inches\n", cm, feet,inches);
printf("Enter the hight in centimeters(<=0 to quit):");
scanf("%f", &cm);
}
printf("PROGRAM EXIT!\n");
return 0;
}
5 To make money
#include<stdio.h>
int main()
{
int a, b; printf(" Enter the money you earn in a day :\n");
scanf("%d", &a);
printf(" Enter the number of days :\n");
scanf("%d", &b);
printf(" I've made a lot of money %d element ", a * b);
}
**8 Modular operation **
#include<stdio.h>
int main(int argc, char* argv[])
{
int first, second;
printf("This program computers moduli.\n");
printf("Enter an integer to server as the second operand:");
scanf("%d", &second);
printf("now enter the first operand:");
scanf("%d", &first);
while (first > 0) {
printf("%d %% %d is %d\n", first, second);
printf("Enter next number for first operand:");
scanf("%d", &first);
}
printf("done!\n");
return 0;
}
#include <stdio.h>
int T(double fahrenheit);
int main(int arge, char* argv[])
{
double input;
printf("This program convert fahrenheit to celsius and kelvin.\n");
printf("Enter a fahrenheit to start:");
while (scanf("%1f",&input) == 1) {
T(input);
printf("Enter next fahrenheit!:");
}
printf("Done!\n");
return 0;
}
int T(double fahrenheit) {
const double FC = 32.0;
const double CK = 273.16;
double celsius, kelvin;
celsius = 5.0 / 9.0 * (fahrenheit - FC);
kelvin = celsius + CK;
printf("%.2f.fahrenheit,equal %.2f celsius, and %.2f kelvin\n", fahrenheit, celsius,kelvin);
return 0;
}
版权声明
本文为[Cx330]所创,转载请带上原文链接,感谢
边栏推荐
猜你喜欢
STS安装
Installation record of SAP s / 4hana 2020
How to reduce the resource consumption of istio agent through sidecar custom resource
Database design: paradigms and anti paradigms
Realization of file copy
Leetcode-15: sum of three numbers
教你如何 分析 Android ANR 问题
为什么需要使用API管理平台
Fiddler无法正常抓取谷歌等浏览器的请求_解决方案
Copy on write collection -- copyonwritearraylist
随机推荐
How to analyze Android anr problems
简单介绍c#通过代码开启或关闭防火墙示例
Share API on the web
Constructors and prototypes
Swagger介绍和应用
Brief introduction of Integrated Architecture
Using annotation + interceptor to implement asynchronous execution
实现图片的复制
写时复制集合 —— CopyOnWriteArrayList
What courses will AI programming learn?
装饰器(二)
几行代码轻松实现跨系统传递 traceId,再也不用担心对不上日志了!
How does semaphore, a thread synchronization tool that uses an up counter, look like?
APReLU:跨界应用,用于机器故障检测的自适应ReLU | IEEE TIE 2020
Get the first cover image of video through canvas
CMS垃圾收集器
文件拷贝的实现
Copy on write collection -- copyonwritearraylist
云计算之路-出海记-小目标:Hello World from .NET 5.0 on AWS
六家公司CTO讲述曾经历的“宕机噩梦”