当前位置:网站首页>Experiment one
Experiment one
2020-11-06 22:11:40 【Wang Jing】
1. Abbreviated program , Output the following information : **********¥¥ ¥¥¥ This is my first C program! **********¥¥¥¥¥
#include<stdlib.h>
int main(void)
{
printf("**********¥¥\n");/*wj*/
printf("¥¥¥\n");
printf("This i my first C program!\n");
printf("**********¥¥¥¥¥\n");
system("pause");
return 0;
}```
2. Enter the radius of the cylinder r And high h, Calculate and output its volume .
```#include<stdio.h>
#include<stdlib.h>
#define PI 3.1415926
int main(void)
{
float r, h;
float v;
printf(" Please enter the radius of the cylinder r:");
scanf("%f", &r);
printf(" Please enter the height of the cylinder h:");
scanf("%f", &h);
v = PI * r * r * h;
printf(" The volume of the cylinder v by :%f", v);
system("pause");
return 0;
}```
3. Enter three numbers to variables a,b,c in , Average them .
```#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int a, b, c;/*number*/
float aver;
printf(" Please enter a:");
scanf("%d", &a);
printf(" Please enter b:");
scanf("%d", &b);
printf(" Please enter c:");
scanf("%d", &c);
aver = (a + b + c) / 3.0;
printf(" The average value is :%f", aver);
system("pause");
return 0;
}
4. Enter seconds , Press it by the hour . minute . Seconds to output . For example, the input 24680, The output 6 Hours 51
branch 20 second .
```#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int s;
int hour, minute, second;/* Company */
printf(" Please enter the number of seconds :");
scanf("%d", &s);
hour = s/3600;
minute = (s % 3600) / 60;
second = s % 60;
printf("%d The second is equal to %d Hours %d branch %d second ", s, hour, minute, second);
system("pause");
return 0;
}```
5.
(1) Write a program to calculate the volume of the sphere , Where the radius of the sphere is 10m( Pay attention to the way the score is written )
(2) Modify the procedure in the above question , Allows you to enter the radius of the sphere .
```#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#define PI 3.1415926
int main(void)
{
float r;/* radius */
float v;/* Volume */
printf(" Please enter the radius of the sphere r:");
scanf("%f", &r);
v = 4.00/ 3.00* PI * r * r * r;
printf(" The volume of the sphere v by :%f", v);
system("pause");
return 0;
}```
6. Write a program , Use printf Show the following graphics on the screen :
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> int main(void) { printf(" *\n"); printf(" *\n"); printf(" *\n"); printf(" * *\n"); printf(" * *\n"); printf(" *\n"); system("pause"); return 0; }``` 7. Write a program , Ask the user to enter a dollar variable , And then it shows an increase 5% The corresponding amount after the tax rate forehead , The format is as follows Enter an amount: 100.00 With tax added:$105.00
int main(void)
{
float money;/* money */
float moneyWithTax;
printf("Enter an amount:");
scanf("%f", &money);
moneyWithTax = money * (1 + 0.05);
printf("With tax added:$%.2f",moneyWithTax);
system("pause");
return 0;
}```
8.(1) Programming requires user input x Value , Then display the values of the following polynomials :
3x5+2x4-5x3-x2+7x-6
```#include<stdio.h>
#include<stdlib.h>
int main(void)
{
float x, y;/* Count */
printf(" Please enter x Value :");
scanf("%f", &x);
y = 3 * x * x * x * x * x + 2 * x * x * x * x - 5 * x * x * x - x * x + 7 * x - 6;
printf(" polynomial 3x5+2x4-5x3-x2+7x-6 The value of is :%f", y);
system("pause");
return 0;
}```
(2) Revise the question above , Use the following formula to evaluate polynomials
((((3x+2)x-5)x-1)x+7)x-6
```#include<stdio.h>
#include<stdlib.h>
int main(void)
{
float x, y;/* Count */
printf(" Please enter x Value :");
scanf("%f", &x);
y = ((((3 * x + 2) * x - 5) * x - 1) * x + 7) * x - 6;
printf(" polynomial ((((3x+2)x-5)x-1)x+7)x-6 The value of is :%f", y);
system("pause");
return 0;
}```
9. Write a program , Ask the user to enter a dollar amount , Then show how to use the least 20 dollar 、10
dollar 、5 The dollar and 1 Dollars to pay
Enter a dollar amount:93
$20 bills:4
$10 bills:1
$5 bills:0
$1 bills:3
( Tips : Divide the payment amount by 20, determine 20 The amount of dollars , And then subtract... From the payment amount 20 The dollar
Total sum , Repeat for other denominations , Make sure you use integer values in your program , Don't use floating point numbers )
```#include<stdio.h>
#include<stdlib.h>
int main(void)
{
int money, twenty, ten, five, one;/*12345*/
printf("Enter a dollar amount:");
scanf_s("%d", &money);
twenty = money / 20;
money = money - twenty * 20;
ten = money / 10;
money = money - ten * 10;
five = money / 5;
money = money - 5 * five;
one = money;
printf("$20 bills:%d\n", twenty);
printf("$10 bills:%d\n", ten);
printf("$5 bills:%d\n", five);
printf("$1 bills:%d\n", one);
system("pause");
return 0;
}```
版权声明
本文为[Wang Jing]所创,转载请带上原文链接,感谢
边栏推荐
- C++ 数字、string和char*的转换
- C++学习——centos7上部署C++开发环境
- C++学习——一步步学会写Makefile
- C++学习——临时对象的产生与优化
- C++学习——对象的引用的用法
- C++编程经验(6):使用C++风格的类型转换
- Won the CKA + CKS certificate with the highest gold content in kubernetes in 31 days!
- C + + number, string and char * conversion
- C + + Learning -- capacity() and resize() in C + +
- C + + Learning -- about code performance optimization
猜你喜欢
-
C + + programming experience (6): using C + + style type conversion
-
Latest party and government work report ppt - Park ppt
-
在线身份证号码提取生日工具
-
Online ID number extraction birthday tool
-
️野指针?悬空指针?️ 一文带你搞懂!
-
Field pointer? Dangling pointer? This article will help you understand!
-
HCNA Routing&Switching之GVRP
-
GVRP of hcna Routing & Switching
-
Seq2Seq实现闲聊机器人
-
【闲聊机器人】seq2seq模型的原理
随机推荐
- LeetCode 91. 解码方法
- Seq2seq implements chat robot
- [chat robot] principle of seq2seq model
- Leetcode 91. Decoding method
- HCNA Routing&Switching之GVRP
- GVRP of hcna Routing & Switching
- HDU7016 Random Walk 2
- [Code+#1]Yazid 的新生舞会
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- HDU7016 Random Walk 2
- [code + 1] Yazid's freshman ball
- CF1548C The Three Little Pigs
- HDU7033 Typing Contest
- Qt Creator 自动补齐变慢的解决
- HALCON 20.11:如何处理标定助手品质问题
- HALCON 20.11:标定助手使用注意事项
- Solution of QT creator's automatic replenishment slowing down
- Halcon 20.11: how to deal with the quality problem of calibration assistant
- Halcon 20.11: precautions for use of calibration assistant
- “十大科学技术问题”揭晓!|青年科学家50²论坛
- "Top ten scientific and technological issues" announced| Young scientists 50 ² forum
- 求反转链表
- Reverse linked list
- js的数据类型
- JS data type
- 记一次文件读写遇到的bug
- Remember the bug encountered in reading and writing a file
- 单例模式
- Singleton mode
- 在这个 N 多编程语言争霸的世界,C++ 究竟还有没有未来?
- In this world of N programming languages, is there a future for C + +?
- es6模板字符
- js Promise
- js 数组方法 回顾
- ES6 template characters
- js Promise
- JS array method review
- 【Golang】️走进 Go 语言️ 第一课 Hello World
- [golang] go into go language lesson 1 Hello World