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
Explain how do you view the path?
Explain what is the most efficient way to store flag values?
What are the different types of constants?
For what purpose null pointer used?
Why is this loop always executing once?
Why c is called procedure oriented language?
a value that does not change during program execution a) variabe b) argument c) parameter d) none
How many data structures are there in c?
How to write a code for reverse of string without using string functions?
What is c basic?
What is logical error?
What is dynamic dispatch in c++?
which type of aspect you want from the student.
What is time null in c?
How do you determine whether to use a stream function or a low-level function?