write a Program to dispaly upto 100 prime numbers(without
using Arrays,Pointer)

Answer Posted / faizan n

/*A program to print all primes b\w 1-100*/
#include<stdio.h>
#include<conio.h>

void main()
{
int count,i=1;
int a;
int col=0;
clrscr();

for(i=1; i<101; i++)
{
count=0;
a=1;

while(a<=i)
{
if(i%a==0)
count++;
a++;
}

if(count==2)
{
printf("%d\t",i);
col++;
if(col%10==0)
printf("\n");
}

}
getch();
}

Is This Answer Correct ?    7 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a

1449


Differentiate between new and malloc(), delete and free() ?

664


Why void main is used in c?

559


Is null always equal to 0(zero)?

578


Can you please compare array with pointer?

611






What is bash c?

552


Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

5790


What is #include conio h?

587


Why is c so powerful?

679


What is a double c?

584


What is a node in c?

543


What is fflush() function?

640


Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon

5462


Why is struct padding needed?

625


What is "Duff's Device"?

697