当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- On the concurrency of update operation
- Awk implements SQL like join operation
- Gopherchina 2020 Conference
- Talk about go code coverage technology and best practices
- B站stm32视频学习
- 佛萨奇forsage以太坊智能合约是什么?以太坊全球滑落是怎么回事
- GopherChina 2020大会
- How does the system response time and throughput change with the increase of concurrency pressure during performance pressure testing
- [开源] .Net 使用 ORM 访问 华为GaussDB数据库
- 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
猜你喜欢

习题五

C + + things: from rice cookers to rockets, C + + is everywhere

Solution of DEV-C + + unable to debug in Windows Environment

Build simple business monitoring Kanban based on Alibaba cloud log service

Flink's sink: a preliminary study

小青台正式踏上不归路的第3天

Summary of template engine

Recurrence of Apache kylin Remote Code Execution Vulnerability (cve-2020-1956)

总结: 10月海外DeFi新项目,更多资管策略来了!

Liteos message queuing
随机推荐
Solution of DEV-C + + unable to debug in Windows Environment
“他,程序猿,35岁,被劝退”:不要只懂代码,会说话,胜过10倍默默努力
. net large data concurrency solution
awk实现类sql的join操作
What are the necessary laws and regulations to know when entering the Internet?
Awk implements SQL like join operation
漫画:寻找股票买入卖出的最佳时机(整合版)
TypeScript(1-2-2)
Tencent: Although Ali's Taichung is good, it is not omnipotent!
Talking about, check the history of which famous computer viruses, 80% of the people do not know!
PHP生成唯一字符串
The first open source Chinese Bert pre training model in the financial field
Blockchain weekly: the development of digital currency is written into the 14th five year plan; Biden invited senior adviser of MIT digital currency program to join the presidential transition team; V
Examples of unconventional aggregation
Google's AI model, which can translate 101 languages, is only one more than Facebook
.NET 大数据量并发解决方案
2035 we will build such a country
Leancloud changes in October
Jsliang job series - 07 - promise
我用 Python 找出了删除我微信的所有人并将他们自动化删除了