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