i want to asked a question about c program the question is:
create a c program that displays all prime numbers less than
500? using looping statement
Answer Posted / vadivelt
Hi.
Have a look on the code i hav written below.
Just give max no(in this question 500) as a input, u ll get
the prime nos in this range.
#include<stdio.h>
#include<conio.h>
main()
{
int n, j, k, flag = 0;
printf("ENTER THE NO\n");
scanf("%d", &n);
printf("\nPRIME NOS IN THIS RANGE\n");
for(j = 1; j<= n; j++)
{
for(k = j; k>=1; k--)
{
if(j%k == 0)
flag++;
}
if(flag == 2)
{
printf("%d ", j);
}
flag = 0;
}
getch();
}
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
how to build a exercise findig min number of e heap with list imlemented?
Write a program to implement queue.
What is the scope of global variable in c?
Is that possible to add pointers to each other?
Why main is not a keyword in c?
What are the disadvantages of c language?
What language is lisp written in?
Explain the difference between exit() and _exit() function?
What is auto keyword in c?
How can I list all of the predefined identifiers?
Explain function?
Explain #pragma statements.
Write a program to check whether a number is prime or not using c?
Explain 'far' and 'near' pointers in c.
a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor