【发布时间】:2014-08-18 05:02:07
【问题描述】:
#include<stdio.h>
#include<conio.h>
void main()
{
int m,a,i,b;
printf("Enter the number upto which the prime number is to be displayed:");
scanf("%d",&m);
for(a=1;a<=m;a++)
{
for(i=1;i<=a;i++)
{
if(a%i==0)
{
b++;
}
}
if(b==2)
{
printf("\t%d",a);
}
}
getch();
}
【问题讨论】:
-
哪个部分不起作用?你期望什么,你得到了什么?你能详细说明一下吗?
-
请任何人回答这个问题...
-
考虑格式化您的代码?
-
@Bala chander:回答什么? “不工作”并不是对问题的有意义的描述。
-
初始化变量 b 并将其放入第二个 for 循环(如果存在)。它在主循环中
标签: c