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 / ashwin kumar
its just to find weather given number is prime or not
#include<stdio.h>
#include<conio.h>
int main()
{
int value,i,flag=0;
clrscr();
printf("enter value to check for prime number : ");
scanf("%d",&value);
for(i=2;i<value;i++)
{
if(value%i==0)
{
flag=flag+1;
break;
}
}
if(flag==1||value==2)
printf(" %d is not a prime number",value);
else
printf(" %d is a prime number",value);
getch();
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Is python a c language?
What is the main difference between calloc () and malloc ()?
Is it possible to use curly brackets ({}) to enclose single line code in c program?
What is const volatile variable in c?
Is it cc or c in a letter?
Explain what are multidimensional arrays?
Distinguish between actual and formal arguments.
What does it mean when a pointer is used in an if statement?
What is a ternary operator in c?
What is the difference between single charater constant and string constant?
which of the following statement is wrong a) mes=123.56; b) con='T'*'A'; c) this='T'*20; d) 3+a=b;
Explain how do you list files in a directory?
What is an arrays?
What is scanf () in c?
How do I use strcmp?