Write a program to print the prime numbers from 1 to 100?
Answer Posted / tirth raj
#include<stdio.h>
#include<conio.h>
void main()
{
int num,div;
clrscr();
printf("First two prime no.1&2");
for(num=3;num<=100;num++)
{
div=2;
while(div<=num-1)
{
if(num%div==0)
{
break;
}
else
{
div++;
}
}
if(div==num)
printf("\nPrime Number = %d",num);
}
getch();
}
| Is This Answer Correct ? | 6 Yes | 6 No |
Post New Answer View All Answers
What is the use of pragma in embedded c?
What is meant by type specifiers?
Why n++ execute faster than n+1 ?
What do you understand by friend-functions? How are they used?
What does 1f stand for?
What is clrscr ()?
Explain logical errors? Compare with syntax errors.
Multiply an Integer Number by 2 Without Using Multiplication Operator
What are the disadvantages of a shell structure?
how to find binary of number?
What is c definition?
Is c pass by value or reference?
What is function in c with example?
Differentiate between #include<...> and #include '...'
What is the advantage of c?