# 程式 語法錯誤 尋求解答

#include "stdio.h"

float a,b;

void main(void)

void sum(void)

void sub(void)

float sum(a,b)

{

return a*b;

}

float sub(a,b)

{

return a/b;

}

{

printf("Enter two words. This program will output the sum and subtract of two numbers.\n");

scanf_s("%f",&a);

printf("\n");

scanf_s("%f",&b);

printf("\n");

printf("The product of two numbers is %d.\n ",sum(a,b));

printf("The first number dividing the second is %d.\n ",sub(a,b));

}

Rating
• 小玉
Lv 7

#include <stdio.h>

#include <stdlib.h>

float sum(float a, float b); //宣告函式

float sub(float a, float b);

void main(void)

{

float a,b;

printf("Enter two words. This program will output the sum and subtract of two numbers.\n");

scanf("%f",&a);

printf("\n");

scanf("%f",&b);

printf("\n");

printf("The product of two numbers is %f.\n",sum(a,b));

printf("The first number dividing the second is %f.\n",sub(a,b));

system("pause"); //程式暫停

}

float sum(float a, float b)

{

return a*b;

}

float sub(float a, float b)

{

return a/b;

}