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
I hope this is right code for you
1st it promt for max number then enter 500 then you will
get result.
#include<stdio.h>
#include<conio.h>
int main()
{
int value,j,i,value2,flag=0,count=0;
clrscr();
printf("enter limit up to which prime numbers to be
printed : ");
scanf("%d",&value2);
printf("\n\n\nlist of prime numbers are:\n\n");
for(j=1;j<=value2;j++)
{
flag=0;
value=j;
for(i=2;i<value;i++)
{
if(value%i==0)
{
flag=flag+1;
goto l1;
}
}
l1:
if(!(flag==1||value==2))
{
printf("%-10d",value);
count+=1;
}
}
printf("\n\ntotal number of prime numbers between 1 and %d
are : %d",value2,count);
getch();
return 0;
}
if their is any changes required or any suggestions mail
me at molugu.ashwin@gmail.com
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
What is difference between structure and union in c?
Explain b+ tree?
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a
What are variables and it what way is it different from constants?
What is file in c preprocessor?
i got 75% in all semester am i eligible for your company
In a header file whether functions are declared or defined?
What do you understand by friend-functions? How are they used?
How can I send mail from within a c program?
formula to convert 2500mmh2o into m3/hr
How do you use a pointer to a function?
Are pointers integer?