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
What are the two types of structure?
How many levels of pointers can you have?
What is the use of getchar() function?
What is the size of a union variable?
What is c definition?
what are bit fields? What is the use of bit fields in a structure declaration?
Is it better to bitshift a value than to multiply by 2?
Why doesnt the call scanf work?
Explain how can I manipulate strings of multibyte characters?
What's the right way to use errno?
How do you construct an increment statement or decrement statement in C?
Is it cc or c in a letter?
When should the volatile modifier be used?
Badboy is defined who has ALL the following properties: Does not have a girlfriend and is not married. He is not more than 23 years old. The middle name should be "Singh" The last name should have more than 4 characters. The character 'a' should appear in the last name at least two times. The name of one of his brothers should be "Ram" Write a method: boolean isBadBoy(boolean hasGirlFriend , boolean isMarried, int age , String middleName , String lastName , String[] brotherName); isHaveGirlFriend is true if the person has a girlfriend isMarried is true if the person is married age is the age of the person middleName is the middle name of the person lastName is the last name of the person brotherName is the array of the names of his brothers
What are the advantages of Macro over function?