用函数编写一个程序求两个数的和与积

如题所述

第1个回答  推荐于2017-10-02
不知道你用的是什么语言,我用C++编的
#include<iostream.h>
void get(int a,int b,int &c,int &d)
{
c = a+b;
d = a*b;
}
void main()
{
int a,b,c,d;
a=20,b=30;
get(a,b,c,d);
cout<<c<<" "<<d<<endl;
}本回答被提问者采纳
第2个回答  2007-06-23
c语言
#include<stdio.h>
int he(int a,int b)
{
return a+b;
}
int ji(int a,int b)
{
return a*b;
}

VB的

function he(a,b)
he=a+b
end function
function ji(a,b)
ji=a*b
end function
第3个回答  2015-10-06
Pascal程序:
var a,b:longint;
begin
readln(a,b);
write(a+b,a*b);
end.
C程序:
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
printf("%d %d",a+b,a*b);
return 0;
}