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 typedef example?
What is the Purpose of 'extern' keyword in a function declaration?
This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory
What is boolean in c?
develop algorithms to add polynomials (i) in one variable
Can the “if” function be used in comparing strings?
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.
Explain what are bus errors, memory faults, and core dumps?
What are the functions to open and close file in c language?
Is void a keyword in c?
pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)
Explain what is the difference between #include and #include 'file' ?
Give me the code of in-order recursive and non-recursive.
What is the difference between union and anonymous union?
How can I sort more data than will fit in memory?