当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- When we talk about data quality, what are we talking about?
- Solve the problem that the value of new date() of JS in IE and Firefox is invalid date and Nan Nan
- Iterm2 configuration and beautification
- Swagger介绍和应用
- Introduction skills of big data software learning
- MYCAT build
- 移动大数据自有网站精准营销精准获客
- AQS 都看完了,Condition 原理可不能少!
- salesforce零基础学习(九十八)Salesforce Connect & External Object
- 你有没有想过为什么交易和退款要拆开不同的表
猜你喜欢

Fiddler can't grab requests from browsers like Google_ Solution

分库分表的几种常见玩法及如何解决跨库查询等问题

Leetcode-11: container with the most water

Installation record of SAP s / 4hana 2020

程序员都应该知道的URI,一文帮你全面了解

你有没有想过为什么交易和退款要拆开不同的表

Concurrent linked queue: a non blocking unbounded thread safe queue

The interface testing tool eolinker makes post request

非阻塞的无界线程安全队列 —— ConcurrentLinkedQueue

为什么需要使用API管理平台
随机推荐
Nodejs中request出现ESOCKETTIMEDOUT解决方案
APP 莫名崩溃,开始以为是 Header 中 name 大小写的锅,最后发现原来是容器的错!
Leetcode-11: container with the most water
JVM真香系列:轻松理解class文件到虚拟机(下)
How to analyze Android anr problems
The vowels in the inverted string of leetcode
基于链表的有界阻塞队列 —— LinkedBlockingQueue
Using containers to store table data
Experiment 1 assignment
Computer network application layer
RabbitMQ快速入门详解
老大问我:“建表为啥还设置个自增 id ?用流水号当主键不正好么?”
非阻塞的无界线程安全队列 —— ConcurrentLinkedQueue
CMS垃圾收集器
理论与实践相结合彻底理解CORS
文件拷贝的实现
Python的特性与搭建环境
Programmers should know the URI, a comprehensive understanding of the article
salesforce零基础学习(九十八)Salesforce Connect & External Object
Introduction skills of big data software learning