資源描述:
《C語言用函數(shù)寫兩數(shù)之和.doc》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、#includevoidmain(){inta,b,sum;scanf("%d,%d",&a,&b);sum=a+b;printf("%d+%d=%d",a,b,sum);}主函數(shù)接收和輸出,被調(diào)函數(shù)求和#includeintadd(inta,intb);voidmain(){inta,b,sum;scanf("%d,%d",&a,&b);sum=add(a,b);printf("%d+%d=%d",a,b,sum);}intadd(inta,intb){intsum;sum=a+b;returnsum;}主函數(shù)接收和求和,被調(diào)函
2、數(shù)打印輸出#include//調(diào)用函數(shù)聲明voidadd(inta,intb);//主函數(shù)voidmain(){//接受兩個整數(shù)inta,b;scanf("%d,%d",&a,&b);//求和//調(diào)用add函數(shù)add(a,b);}voidadd(inta,intb){intsum;sum=a+b;//輸出結(jié)果printf("%d+%d=%d",a,b,sum);}主函數(shù)輸出打印,被調(diào)函數(shù)接受和求和#includeintadd();voidmain(){intsum;sum=add();printf("%d",sum);}intad
3、d(){inta,b,sum;scanf("%d,%d",&a,&b);sum=a+b;returnsum;}主函數(shù)什么也不做,被調(diào)函數(shù)接收、求和、打印輸出#includevoidadd();voidmain(){add();}voidadd(){inta,b,sum;scanf("%d,%d",&a,&b);sum=a+b;printf("%d",sum);}主函數(shù)接收,被調(diào)函數(shù)求和、打印輸出#includevoidadd(intsum);voidmain(){inta,b,sum;scanf("%d,%d",&a,&b);su
4、m=a+b;add(sum);}voidadd(intsum){printf("%d",sum);}