Please tell me source code for Turbo C++ to print prime numbers upto 100.I need that because my 5 marks are depend on that.(Please do not give like cout%26lt;%26lt;'2' etc.)
I wrote code in TC was :
#include%26lt;iostream.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
clrscr();
int a,b;
for(a=1;a%26lt;=10;a++)
if((a%4==0)||(a%6==0)||(a%8==0)||(a%9=...
{
continue;
}
else
{
cout%26lt;%26lt;a;
for(b11;b%26lt;=100;b++)
if((b%2==0)||(b%3==0)||(b%5==0)||(b%7=...
{
continue;
}
else
{
cout%26lt;%26lt;b;
}
}
getch();
}
Can you tell me source code for Turbo C++ to print prime nos. to 100?
void main()
{
int i,num=1;
clrscr();
while(num%26lt;=100)
{
i=2;
while(i%26lt;=num)
{
if(num%i==0)
break;
i++;
}
if(i==num)
printf("\n%d is Prime",num);
num++;
}
getch();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment