我正在做這個簡單的代碼,如果我把兩個數字,它顯示的解決方案。這是代碼:錯誤未在此範圍內聲明
#include <stdio.h>
int main()
{
printf("Enter two numbers:")
;scanf("&d &d", a, b)
;printf("=======================\n"); /* */
/* */
printf("The sum of %d and %d is %d.\n\n", 3, 4, 3 + 4)
/* */
;printf("The difference of %d and %d is %d. \n\n", 3, 4, 3-4)
/* */
;printf("The product of %d and %d is %d. \n\n", 3, 4, 3*4)
/* sum of squares would be a*a + b*b */
;printf("The sum of the squares of %d and %d is %d. \n\n", 3, 4, 3*3 + 4*4)
;printf("**end**"); /* :-) */
;return (0);
}
,我不斷收到一個錯誤,指出:
[Error] 'a' was not declared in this scope
and
[Error] 'b' was not declared in this scope
這有什麼錯呢?
您需要聲明它們,正如它所說的那樣。像「int a,b;」 –
有趣的風格:_(。 – this
你需要聲明變量a和b,然後再嘗試在其中存儲任何內容 – tylerism