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 c language and why we use it?
Write a simple code fragment that will check if a number is positive or negative.
What are loops c?
The file stdio.h, what does it contain?
to print the salary of an employee according to follwing calculation: Allowances:HRA-20% of BASIC,DA-45% of BASIC,TA-10%. Deductions:EPF-8% of BASIC,LIC-Rs.200/-Prof.Tax:Rs.200/- create c language program?
How can I get back to the interactive keyboard if stdin is redirected?
write a program that reads lines(using getline), converts each line to an integer using atoi, and computes the average of all the numbers read. also compute the standard deviation.
a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none
What is a spanning Tree?
What is the value of uninitialized variable in c?
What is the best way of making my program efficient?
What are global variables and how do you declare them?
Which node is more powerful and can handle local information processing or graphics processing?
When do we get logical errors?
What is #ifdef ? What is its application?