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
What is the use of a semicolon (;) at the end of every program statement?
Explain how can you determine the size of an allocated portion of memory?
Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.
HOW TO SOLVE A NUMERICAL OF LRU IN OS ??????
Write a program to show the change in position of a cursor using c
What is header file in c?
What is the difference between NULL and NUL?
Why c is called a middle level language?
What is chain pointer in c?
Explain indirection?
What is void c?
Explain about the functions strcat() and strcmp()?
Explain logical errors? Compare with syntax errors.
Can variables be declared anywhere in c?
How can I find the modification date and time of a file?