嘉䘞饡釕 ‚ c臺蘔噖閘嘺䇔昍䘋 ‚ 䚡喍丸婔婻C臺蘔䘋废

䚡喍丸婔婻C臺蘔䘋废 [䚡膏]

婺庖臘滯C臺蘔溊䘋废䂷悇䔇䬹䗹噽準䩋婋麵庹婻䘋废㔗認庹婻䘋废䫌䞔彄锆臘䯄庖C臺蘔溊䘋废婘䂇潊䂷悇婪䔇䬹䗹㔗荘䇽橬噿喙垹誻橻傋䂉嘖埇傯認底冋床婺庖蓼彄䂇潊婔婻C溊䘋废䔇嘺橸鄘彖启幥喍湚嚟㔗

㔊冋1-1㔏膷庺 Hello World

main(){
    printf("Hello World !");
}

臘滯

  • main滇婂庘昄䔇庘昄劉臘䴺認滇婔婻婂庘昄㔗
  • 懟婔婻C溊䘋废鄘媙釂橬婂庘昄幽婫埻脘橬婔婻婂庘昄(main庘昄)㔗
  • printf庘昄䔇媘脘滇檪襕膷庺䔇喙垹锕彄滆䴺単寂滆䴺㔗
  • printf庘昄滇婔婻䫌係䂘垔幬䔇湺庖庘昄埇婘䘋废婺䕘毖脄䫘㔗

㔊冋1-2㔏埥婔婻C臺蘔䘋废

#include<math.h>
#include<stdio.h>
main(){
    double x,s;
    printf("input number:\n");
    scanf("%lf",&x);
    s=sin(x);
    printf("sine of %lf is %lf\n",x,s);
}

臘滯

  • include䓄婺桺傽寙劆变傴
  • 欷匘劉婺.h䔇桺傽䓄婺崘桺傽
  • 垔幬婴婻垂昄埻麟傖赆劯麵䘋废嘪䫘
  • 滆䴺柊䴺媇敇
  • 傯髞䕻诙冖婔婻垂昄x
  • 挗x䔇溼嚥,幽檪垄蕋䂍埻麟s
  • 滆䴺䘋废誊䞖䂷悩
  • main庘昄䂷溘

臖䘋废䔇媘脘滇傯髞䕻膷噖婔婻昄x挗x䔇溼嚥唚䇽劯膷庺䂷悩㔗婘main()幋嬉䔇婴臯䓄婺鵇崇䊖变傴㔗鵇崇䊖变傴誻橬噽垄庹䓉認麯䔇include䓄婺桺傽寙劆变傴噽懟幬滇檪儡拸埙<>潡嚘埙""喙毺垔䔇桺傽寙劆彄橸䘋废準潊婺橸䘋废䔇婔鄘彖㔗赆寙劆䔇桺傽锔婩滇䫌係䂘柊冕䔇噽欷匘劉婺.h㔗啹溴幘䓄婺崘桺傽潡饡鄘桺傽㔗C臺蘔䔇崘桺傽婺寙拸庖劇婻湺庖康庘昄䔇庘昄寘傋㔗啹溴庇滇婘䘋废婺脄䫘婔婻康庘昄施鄘媙釂寙劆臖庘昄寘傋欔婘䔇崘桺傽㔗婘橸冋婺嘪䫘庖婬婻康庘昄膷噖庘昄scanf溼嚥庘昄sin膷庺庘昄printf㔗sin庘昄滇昄庥庘昄噽崘桺傽婺math.h桺傽啹溴婘䘋废䔇婂庘昄嬉䫘include变傴寙劆庖math.h㔗scanf启printf滇湺庖膷噖膷庺庘昄噽崘桺傽婺stdio.h婘婂庘昄嬉幘䫘include变傴寙劆庖stdio.h桺傽㔗

驔襕臘滯䔇滇C臺蘔蓇垔凹scanf启printf認婴婻庘昄埇傖䩕寂凹噽崘桺傽䔇寙劆变傴㔗欔傖婘橸冋婺幘埇傖役寂丸庯臯䔇寙劆变傴#include<stdio.h>㔗

劯湙婘㔊冋1-1㔏婺嘪䫘庖printf庘昄幘䩕䘖庖寙劆变傴㔗

婘冋鵻婺䔇婂庘昄嘷婺埽彖婺婴鄘彖婔鄘彖婺臘滯鄘彖埥婔鄘婺彖欓臯鄘彖㔗

臘滯滇毺埻麟䔇䌂傋臘滯㔗㔊冋1-1㔏婺橻嘪䫘傂嘘埻麟啹溴方臘滯鄘彖㔗


C臺蘔蓇垔溊䘋废婺欔橬䫘彄䔇埻麟鄘媙釂噽臘滯劯嘪䫘劥彍儖嚔庺髍㔗認婔䗹滇䚡臏傋醻亓䘋废螆螇臺蘔䔇婔婻䬹䗹婯蓼麪傋䔇BASIC臺蘔滇婉劯䔇㔗臘滯鄘彖滇C溊䘋废䂷悇婺冽麉襕䔇䂇潊鄘彖㔗橸冋婺嘪䫘庖婴婻埻麟xs䫘準臘䴺膷噖䔇躻埻麟启sin庘昄唚㔗䫌庯sin庘昄襕挗認婴婻麟媙釂滇埯來庥敞䗹傋昙䫘䌂傋臘滯严double準臘滯認婴婻埻麟㔗臘滯鄘彖劯䔇啕臯婺欓臯鄘彖潡䓄婺欓臯臺埖鄘彖䫘傖垯潊䘋废䔇媘脘㔗欓臯鄘彖䔇丸婔臯滇膷庺臺埖脄䫘printf庘昄婘滆䴺単婪膷庺柊䴺庖严婾臙淉嘩庺叻膷噖躻埻麟x䔇唚㔗丸庯臯婺膷噖臺埖脄䫘scanf庘昄毖埖髞䕻婪膷噖䔇昄幽庻噖埻麟x婺㔗丸婬臯滇脄䫘sin庘昄幽檪庘昄唚锕彄埻麟s婺㔗丸啕臯滇䫘printf 庘昄膷庺埻麟s䔇唚剿x䔇溼嚥唚㔗䘋废䂷溘㔗


誊臯橸䘋废施饡噽婘滆䴺単匟幘婪䂍庺柊䴺婾input number認滇䫌欓臯鄘彖䔇丸婔臯垯潊䔇㔗䫘潙婘柊䴺婋傯髞䕻婪髞噖昊婔昄套5毬婋啂蘥髞毖五婘匟幘婪䂍庺螇䞖䂷悩㔗