日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

C语言作业界面,c语言作业20191011121223

發(fā)布時間:2024/9/19 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C语言作业界面,c语言作业20191011121223 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.通過試驗(即編寫帶有此類問題的程序)觀察系統(tǒng)如何處理整數(shù)上 溢、浮點數(shù)上溢和浮點數(shù)下溢的情況。

#include

int main(void)

{

int z1;

float f1,f2;

z1=-2147483647;

f1=3.4e56;//上限很大的數(shù)

f2=0.12e9;//下限小數(shù)

printf("%d,%d,%d\n",z1,z1-1,z1-2);

printf("%f,%f\n",f1,f1*10);

printf("%f,%f\n",f2,f2/10);

return 0;

}

2.編寫一個程序,發(fā)出一聲警報,然后打印下面的文本: Startled by the sudden sound, Sally shouted,

"By the Great Pumpkin, what was that!"

#include

int main(void)

{

int ascii=7;

printf("%c\n",ascii);

printf ("Startled by the sudden sound, Sally shouted,\n");```c

printf("‘By the Great Pumpkin, what was that!’\n");

return 0;

}

?

3.編寫一個程序,讀取一個浮點數(shù),先打印成小數(shù)點形式,再打印成指 數(shù)形式。然后,如果系統(tǒng)支持,再打印成p記數(shù)法(即十六進(jìn)制記數(shù)法)。 按以下格式輸出(實際顯示的指數(shù)位數(shù)因系統(tǒng)而異): Enter a floating-point value: 64.25

fixed-point notation: 64.250000

exponential notation: 6.425000e+01

p notation: 0x1.01p+6

#include

int main()

{

float num;

printf("Enter a floating-point value");

scanf("%f",&num);

printf("fixed-point notation:%f\n",num);

printf("exponential nation:%e\n",num);

printf("p notation:%a\n",num);

return 0;

}

4.一年大約有3.156×107秒。編寫一個程序,提示用戶輸入年齡,然后顯 示該年齡對應(yīng)的秒數(shù)。

#include

int main()

{

int ageyear;

long totalsecond;

printf("please input your age:\n");

scanf("%d",&ageyear);

totalsecond=ageyear*3.156e7;

printf("your age is %d second\n",totalsecond);

return 0;

}

5.1個水分子的質(zhì)量約為3.0×10?23克。1夸脫水大約是950克。編寫一個 程序,提示用戶輸入水的夸脫數(shù),并顯示水分子的數(shù)量。

#include

#define MASS_H2o 3.0e-23

#define MASS_QT 950

int main()

{

float quarts,countH2o;

printf("piease input the number of quart of water\n");

scanf("%f",&quarts);

countH2o=quarts*MASS_QT/MASS_H2o;

printf("%f quarts of water contain %e count of H2o",quarts,countH2o);

return 0;

}

6.1英寸相當(dāng)于2.54厘米。編寫一個程序,提示用戶輸入身高(/英 寸),然后以厘米為單位顯示身高。

#include

int main()

{

float high=0;

float totalhigh=0;

printf("請輸入您的身高(英寸):");

scanf("%f",&high);

totalhigh=high*2.54;

printf("your high is %f (cm)\n",totalhigh);

return 0;

}

7.在美國的體積測量系統(tǒng)中,1品脫等于2杯,1杯等于8盎司,1盎司等 于2大湯勺,1大湯勺等于3茶勺。編寫一個程序,提示用戶輸入杯數(shù),并以 品脫、盎司、湯勺、茶勺為單位顯示等價容量。思考對于該程序,為何使用 浮點類型比整數(shù)類型更合適?

#include

#define PINT_CUP 2

#define CUP_OZ 8

#define OZ_SPOON 2

#define SPOON_TEASPOON 3

int main()

{

float cup,pint,oz,spoon,teaSpoon;

printf("please input number od cups\n");

scanf("%f",&cup);

pint=cup/PINT_CUP;

oz=cup*CUP_OZ;

spoon=oz*OZ_SPOON;

teaSpoon-spoon*SPOON_TEASPOON;

printf("%f cups means %f pint,%f oz,%f spoon,%f teaspoon\n",cup,pint,oz,spoon,teaSpoon);

return 0;

}

8.編寫一個程序,要求提示輸入一個ASCII碼值(如,66),然后打印 輸入的字符。

#include

int main(void)

{

int ascii;

printf("please input an ascii code\n");

scanf("%d",&ascii);

printf("%d is the ascii code for %c\n",ascii,ascii);

return 0;

}

總結(jié)

以上是生活随笔為你收集整理的C语言作业界面,c语言作业20191011121223的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。