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

What is #error and use of it?

675


What is function prototype in c language?

606


in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

7387


what are the advanced features of functions a) function declaration and prototypes b) calling functions by value or by reference c) recursion d) all the above

667


Why string is used in c?

575






What is the size of empty structure in c?

589


Describe dynamic data structure in c programming language?

599


Do you know the use of 'auto' keyword?

653


Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

830


What does == mean in texting?

659


Explain the difference between getch() and getche() in c?

560


How can a process change an environment variable in its caller?

648


How many types of operator or there in c?

597


write a progrmm in c language take user interface generate table using for loop?

1571


What is "Duff's Device"?

697