hii,I'm a new programer.. and now I have a homework. And I stuck with this,, This homework about find 100 first number.. I have one solution but,this solution is using syntax goto().. and the problem is my homework is restricted using syntax goto()..this my first solution
#include<conio.h>
#include<stdio.h>
#include<stdlib>
main()
{
int a,b,c,d;
a=2;
c=1;
printf("Prime number %d is %d",c,a);
loop1:
if(c==100)
exit(0);
{
b=2;
a=a+1;
loop2:
if(b==a)
{
c=c+1;
printf("Prime number %d is %d",c,a);
goto loop1;
}
else
{
d=a%b;
if(d==0)
goto loop1;
else
{
b=b+1;
goto loop2;
}
}
getch();
}
}
this is sucess to answer my homework but it is restricted to use goto. So help me to change goto with while or do while,,because I'm not really know about using while or do while,,and please give some information about the different between while and do-while..