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 difference between malloc() and calloc() function in c language?
What does %2f mean in c?
What is atoi and atof in c?
Explain what standard functions are available to manipulate strings?
What is wrong with this declaration?
What is advantage of pointer in c?
What is the difference between a function and a method in c?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
What is meant by 'bit masking'?
Which programming language is best for getting job 2020?
Can we initialize extern variable in c?
how to write optimum code to divide a 50 digit number with a 25 digit number??
What is const keyword in c?
Why can’t constant values be used to define an array’s initial size?
What are the features of c languages?