【发布时间】:2014-05-07 18:18:13
【问题描述】:
我是初学者,请你告诉我为什么程序中的for循环后面没有大括号{ }。我已对此问题发表评论。
void main()
{
int a[50],n,count_neg=0,count_pos=0,I;
printf("Enter the size of the array\n");
scanf("%d",&n);
printf("Enter the elements of the array\n");
for (I=0;I < n;I++) /* i dont understand why no {} occuerred after this for loop please explain*/
scanf("%d",&a[I]);
for(I=0;I < n;I++)
{
if(a[I] < 0)
count_neg++;
else
count_pos++;
}
printf("There are %d negative numbers in the array\n",count_neg);
printf("There are %d positive numbers in the array\n",count_pos);
}
【问题讨论】:
-
还有你为什么提到像
count number of negative and positive number in an array这样的主题行?因为您的问题与 for 循环理解有关。 -
是的,这并不反映您的实际怀疑;请给出适当的标题和描述。