Write a program to print the prime numbers from 1 to 100?
Answer Posted / nikith
#include<stdio.h>
#include<conio.h>
int main()
{
int num,n,div,p;
printf("Enter any number: ");
scanf("%d", &num);
for(n=2; n<=num; n++)
{
for(div=2; div<n; div++)
{
if(n%div==0)
{
p=0;
break;
}
p=1;
}
if(p)
printf("\t%d",n);
}
getch();
return 0;
}
| Is This Answer Correct ? | 8 Yes | 8 No |
Post New Answer View All Answers
Is main an identifier in c?
What is difference between union All statement and Union?
What are the types of unary operators?
What is the best way to store flag values in a program?
Write programs for String Reversal & Palindrome check
State the difference between x3 and x[3].
What library is sizeof in c?
What is static memory allocation? Explain
What are header files and what are its uses in C programming?
Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?
How many keywords are there in c?
Why use int main instead of void main?
What is exit() function?
Explain what is meant by 'bit masking'?
What is meant by operator precedence?