当前位置:网站首页>Experiment one
Experiment one
2020-11-06 22:11:00 【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]所创,转载请带上原文链接,感谢
边栏推荐
- MRAM高速缓存的组成
- ES中删除索引的mapping字段时应该考虑的点
- 2020-09-04:函数调用约定了解么?
- window系统 本机查找端口号占用方法
- 超高频RFID医疗血液管理系统应用
- Python 100 cases
- C calls SendMessage to refresh the taskbar icon (the icon does not disappear at the end of forcing)
- [graffiti Internet of things footprints] panoramic introduction of graffiti cloud platform
- The use of Xunwei imx6 development board device tree kernel menuconfig
- 2020-08-18:介绍下MR过程?
猜你喜欢
August 30, 2020: naked write algorithm: the nearest common ancestor of two nodes in a binary tree.
20个XR项目路演,近20个资本机构出席!诚邀您参加2020 Qualcomm XR生态合作伙伴大会
小熊派开发板实践:智慧路灯沙箱实验之真实设备接入
插件Bilibili新版0.5.5
Markdown tricks
Detailed software engineering -- the necessary graphs in each stage
“非洲用户的付费意愿并不低”——专访四达时代研发总监张亮
How to make characters move
Count the number of project code lines
Characteristics of magnetic memory chip STT-MRAM
随机推荐
A concise tutorial for Nacos, ribbon and feign
This project allows you to quickly learn about a programming language in a few minutes
Stm32f030c6t6 compatible to replace mm32spin05pf
August 30, 2020: naked write algorithm: the nearest common ancestor of two nodes in a binary tree.
Event monitoring problem
Js数组-数组的用法全在这里(数组方法的重构、数组的遍历、数组的去重,数组的判断与转换)
预留电池接口,内置充放电电路及电量计,迅为助力轻松搞定手持应用
STM32F030C6T6兼容替换MM32SPIN05PF
非易失性MRAM存储器应用于各级高速缓存
How to prepare for the system design interview
Count the number of project code lines
[doodling the footprints of Internet of things] Introduction to Internet of things
STM32F030F4P6兼容灵动微MM32F031F4P6
实验一
磁存储芯片STT-MRAM的特点
With this artifact, quickly say goodbye to spam messages
The method of local search port number occupation in Windows system
List to map (split the list according to the key, and the value of the same key is a list)
Application insights application insights use application maps to build request link views
August 18, 2020: introduce Mr process?