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
Why is struct padding needed?
Explain the array representation of a binary tree in C.
What are the different categories of functions in c?
In C language, a variable name cannot contain?
What is the condition that is applied with ?: Operator?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
What is sizeof int?
What is wrong in this statement? scanf(“%d”,whatnumber);
in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.
What is c language used for?
Why main is not a keyword in c?
Explain that why C is procedural?
When should volatile modifier be used?
How is actual parameter different from the formal parameter?
Can we assign string to char pointer?