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 significance of static storage class specifier?
How do you determine a file’s attributes?
What is the difference between a function and a method in c?
What is the difference between int main and void main in c?
What is a spanning Tree?
Explain how can a program be made to print the name of a source file where an error occurs?
Are c and c++ the same?
Why dont c comments nest?
What does != Mean in c?
How can I call fortran?
Explain what are preprocessor directives?
Explain the difference between #include "..." And #include <...> In c?
What is c preprocessor mean?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
How do you use a pointer to a function?