#include <stdio.h>
int main (void)
{
int hist,geo,phy,chem,bio;
int credits=0;
printf("Enter marks in history : ");
scanf("%d",&hist);
if(hist>40)
credits =10;
else
printf("No credits awarded for history");
printf("Credits obtained is %d",&credits);
return(0);
}
当我运行代码时,我得到变量'Credits'的值为230586。请帮忙。我是C的初学者
答案 0 :(得分:1)
&x
就像问一个问题“变量x
的地址是什么?” ,这就是为什么你得到这个奇怪的数字。要打印变量值,请将credits
而不是&credits
传递给printf
函数。
printf("Credits obtained is %d", credits);