C语言程序设计---帮忙做一下吧

来源:百度知道 编辑:UC知道 时间:2024/06/21 16:49:57
1、有下面的C程序,目的是想计算由键盘输入的任意两个整数的积。
/*exl.c*/
#include (stdio.h);
main()
scanf(“%x,%y”,&x,%y)
p=prodct(x,y)
printf(“The product is :”,p)
int prodct(int a ,int b )
int c
c=a*b
return c
请按下面的步骤对该程序进行调试。
(1) 在编辑状态下照原样键入上述程序,编译并运行上述程序,根据系统提示的出错信息改正程序中的错误。再编译执行纠错后的程序。如还有错误,再编辑改正,直到不出现语法错误为止。
(2) 将改好的程序用下面给出的6组测试用例进行测试,查看运行结果是否正确。
(1)0, 0
(2)0, 99
(3)20,50
(4)33000,20
(5)-5,-2
(6)-5,2

第一个人回答的有点问题,运行33000,20时会出现错误,是变量的类型没定义好,下面这样就对啦:
#include<stdio.h>
void main()
{
long x,y,p;
long prodct(long a,long b);
scanf("%ld,%ld",&x,&y);
p=prodct(x,y);
printf("The product is:%ld\n",p);
}
long prodct(long a,long b)
{
long c;
c=a*b;
return c;
}

#include<stdio.h>
int main(void)
{
int x,y,p;
int prodct(int a,int b);
scanf("%d,%d",&x,&y);
p=prodct(x,y);
printf("The product is:%d\n",p);
system("PAUSE");
return 0;
}
int prodct(int a,int b)
{
int c;
c=a*b;
return c;
}
谢谢你的分。~O~

我来学习的 ……
system("PAUSE");
return 0;

这个用来干吗的?

本程序是按你的要求改的,绝对正确。
#include <stdio.h>
main()
{
int prodct(int a ,int b );
int x,y,p;
scanf("%d,%d",&x,&y);
p=prodct(x,y);