Write a program to print the prime numbers from 1 to 100?

Answer Posted / prth

#include<stdio.h>
#include<conio.h>
void main()
{
int flag,x;
clrscr();
printf("1\t");
for(int i=1;i<=100;i++)
{
flag=0;
for(x=2;x<=i;x++)
{
if(i%x==0)
{
flag=1;
break;
}
else
continue;
}
if(i==x)
printf("%d\t",i);
}
getch();
}

Is This Answer Correct ?    48 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do character constants represent numerical values?

852


What is the difference between array_name and &array_name?

785


What is stack in c?

622


What is the purpose of macro in C language?

674


What is the difference between exit() and _exit() function?

612






How to throw some light on the b tree?

609


Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?

1606


explain what are pointers?

629


a program that can input number of records and can view it again the record

1494


Why static variable is used in c?

570


What is the difference between strcpy() and memcpy() function in c programming?

633


Do you have any idea about the use of "auto" keyword?

671


What header files do I need in order to define the standard library functions I use?

545


Is int a keyword in c?

568


Why we not create function inside function.

1760