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 exit() and _exit() function in c?
How do you define CONSTANT in C?
What is a function simple definition?
What is the difference between single charater constant and string constant?
Explain the advantages and disadvantages of macros.
What extern c means?
What does d mean?
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
How are pointers declared in c?
What is volatile variable how do you declare it?
what are the program that using a two dimensional array that list the odd numbers and even numbers separately in a given 10 inputs values
What is the difference between #include
Is swift based on c?
Write programs for String Reversal & Palindrome check
How can I avoid the abort, retry, fail messages?