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
How will you divide two numbers in a MACRO?
Explain what is the difference between #include and #include 'file' ?
What is auto keyword in c?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
What is struct node in c?
Is calloc better than malloc?
What are the difference between a free-standing and a hosted environment?
What is an expression?
How many keywords (reserve words) are in c?
What is meant by 'bit masking'?
Explain what will be the outcome of the following conditional statement if the value of variable s is 10?
Can we increase size of array in c?
Does c have class?
The statement, int(*x[]) () what does in indicate?
What is echo in c programming?