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
What is a macro?
What is the difference between array and pointer?
What is the process to generate random numbers in c programming language?
What is property type c?
Is it cc or c in a letter?
What are the types of macro formats?
What is the difference between declaring a variable by constant keyword and #define ing that variable?
Explain bitwise shift operators?
What is the c value paradox and how is it explained?
What are header files and what are its uses in C programming?
What does d mean?
Write a program to identify if a given binary tree is balanced or not.
How can I read in an object file and jump to locations in it?
Write a program to swap two numbers without using the third variable?
we called a function and passed something do it we have always passed the "values" of variables to the called function. such functions calles are called a) calls by reference b) calls by value c) calls by zero d) none of the above