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
Why array is used in c?
What is #pragma statements?
What is the difference between procedural and declarative language?
What is the need of structure in c?
What is pointer & why it is used?
What does the && operator do in a program code?
What is LINKED LIST? How can you access the last element in a linked list?
Can we declare variable anywhere in c?
How can I sort a linked list?
What is operator precedence?
What are the 4 data types?
How many levels of indirection in pointers can you have in a single declaration?
Explain high-order bytes.
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
can anyone please tell about the nested interrupts?