当前位置:网站首页>Exercise 5
Exercise 5
2020-11-08 16:22:00 【S rookie program ape s】
The first question is
/*huang
*/
#iinclude<stdio.h>
#define MIN_PER_HOU 60 // There are... Every hour 60 minute
int main (int argc,char *argv[]){
int hours, minutes, input;
printf("CONVERT MINUTES TO HOURS!\n");
printf("PLEASE INPUT THE NUMBER OF MINNUTES(<=0 TO QUIT):“);
scanf("%d",&input);
while(input >0){
hours=input/MIN_PRT_HOU:
printf("CONVERT TO %d HOUT AND %dMINUTES\n",houts,minutes);
printf("PLEASE CONTINUE INPUT UHE NUMBER OF MINUTES (<=0TO QUIT):");
scant("%d",&input);
}
printf("PROGRAM EXIT!\n");
}
The second question is
/*huang
*/
#include<stdio.h>
int main(int rgc,char *argv[]){
int counter,i=0;
printf("PRINT COUNTINUE 10 NUMBERS!\n");
printf("PLEASE INPUT THESTART NUMBER :");
scanf("%d",&counter);
while(i+<11){
printf("%d\n",counter++);
printf("PROGRAM EXIT!\n");
returen 0;
}
Third question
/*huang
*/
#include<stdio.h.
#define WEEK_PER_DAY 7// There are... Every week 7 God
int main (int argc,char*argv[]){
int daysmweeks,input;
printf("CONVERT FAYS TO WEEKS!\n");
printf("PLEASE INPUT THE NUMBER OF DAYS (<=0 TO QUIT):");
scanf("%d",&input);
while (input>0){
weeks=input/WEEK_PER_DAY;
days=input%WEEKK_PER_DAY;
printf("%d days are %d weeks, %d days\n",input,weeks,days);
printf("PLEASE INPUT THE NUMBER OF DAYS(<=0 TO QUIT):");
scanf("%d",&input);
}
printf("PROGRAM EXIT!\n");
return 0;
}
Fourth question
/*huang
*/
#include<stdio.h>
#define FEET_TO_CM 30.48
#define INCH_TO_CM 2.54
int main (int argc, char*argv[]){
int feet;
float inches,cm;
printf("CONVERT CM TO INCHES!\n");
printf("Enter the height in centimeters:");
scanf("%f",&cm);
while (cm>0){
feet=cm/FEET_TO_CM;
inches=(cm -feet*FEET_TO_CM)/INCH_TO_CM;
printf("%.1f cm=%d feet , %.1f inches\n",cm,feet,inches);
printf("Enter the height in centimeters(<=0 TO QUIT):");
scanf(‘%f",&cm);
}
printf("PROGRAM EXIT!\n);
return 0;
}
Fifth question
/*huang
*/
#include<stdio.h>
int main(int argc,char *argv[]){
int count = 0,sum=0;
printf("Enter the number of days you work:");
scanf ("%d",&count);
while(count>o){
sum=sum+count--;
}
printf("You earned $ %d total!\n",sum);
printf("PROGRAM EXIT !\n");
return 0;
}
Sixth question
/*huang
*/
#include<stdio.h>
int main(int argc,char *argv[){
int count=0,sum=0;
printf("Enter the number of fays you work:");
scanf("%d",&count);
while(count>0){
sum=sum+count * count;
count--;
}
printf("You earned $ %d total!\n",sum);
printf("PROGAM EXIT!\n");
return 0;
}
Question seven
/*huang
*/
#include<stdio.h>
double cubic(double n);
int main(int argc,char *argv[]){
double input;
printf("Enter the double datum to calc cubic :");
scanf("%f",&input);
cubic(inrut);
printf("PROGRAM EXIT!\n");
return 0;
}
double cubic(double n){
double t=n*n*n;
printf("The %1g's cubic is %1g !\n",n,t);;
return t;
}
The eighth question
/*huang
*/
#include<stdio.h>
int main (int argc,char *argv[]){
int first,second;
printf("This program computes 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,(first%second));
printf("Enter next number for first operand(<=0 to quit):");
scanf("%d",&first);
}
printf("Done!\n");
return 0;
}
Question 9
/*huang
*/
#include<stdio.h>
int Temperatures(douuble fahrenheit);
int main(int argc,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){
Temperatures(input);
printf("Enter next fahrenheit!(q to quit):");
}
printf("Done!\n");
return 0;
}
int Temperatures(double fahrenheit){
const double F_TO_C = 32.0;
const double C_TO_K = 273.16;
celsius = 5.0/9.0*(fahrenheit - F_TO_C);
kelvin = celsius + C_TO_K;
printf("%.2,fahrennheit, equal %.2f celsius, and %.2f kelvin\n",fahrenheit,
return 0;
}
版权声明
本文为[S rookie program ape s]所创,转载请带上原文链接,感谢
边栏推荐
- Dev-c++在windows环境下无法debug(调试)的解决方案
- Summary of rendering of water wave and caustics (etching) in webgl
- Xiaoqingtai officially set foot on the third day of no return
- How much disk IO does a byte of read file actually take place?
- Do these mistakes in your resume affect your annual salary of one million?
- Elasticsearch 学习一(基础入门).
- 打工人,打工魂,抽终身会员,成为人上人!
- rabbitmq(一)-基础入门
- The first open source Chinese Bert pre training model in the financial field
- AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
猜你喜欢
Arduino ide build esp8266 development environment, slow file download solution | esp-01 make WiFi switch tutorial, transform dormitory lights
10 common software architecture patterns
.NET 大数据量并发解决方案
How to solve the conflict when JD landed on Devops platform?
On the concurrency of update operation
二叉树的四种遍历方应用
We made a medical version of the MNIST dataset, and found that the common automl algorithm is not so easy to use
Comics: looking for the best time to buy and sell stocks
漫画:寻找股票买入卖出的最佳时机(整合版)
Millet and oppo continue to soar in the European market, and Xiaomi is even closer to apple
随机推荐
基于阿里云日志服务快速打造简版业务监控看板
How to make a correct summary for 7 years?
Drink soda, a bottle of soda water 1 yuan, two empty bottles can change a bottle of soda, give 20 yuan, how much soda can you
Liteos message queuing actual combat
二叉树的四种遍历方应用
Do these mistakes in your resume affect your annual salary of one million?
GopherChina 2020大会
区块链周报:数字货币发展写入十四五规划;拜登邀请MIT数字货币计划高级顾问加入总统过渡团队;委内瑞拉推出国营加密交易所
我们做了一个医疗版MNIST数据集,发现常见AutoML算法没那么好用
Design by contract (DBC) and its application in C language
Welcome to offer, grade P7, face-to-face sharing, 10000 words long text to take you through the interview process
Huawei has an absolute advantage in the 5g mobile phone market, and the market share of Xiaomi is divided by the market survey organization
When to write disk IO after one byte of write file
使用K3S创建本地开发集群
read文件一个字节实际会发生多大的磁盘IO?
10个常见的软件架构模式
The network adapter could not establish the connection
别再在finally里面释放资源了,解锁个新姿势!
Five phases of API life cycle
We made a medical version of the MNIST dataset, and found that the common automl algorithm is not so easy to use