write the program for prime numbers?

Answer Posted / akhilesh singh(m.c.a-iisem ois

main()
{
int i,j=2,ch=0;
clrscr();
printf("\nENTER ANY NUMBER");
scanf("%d",&i);
while(j<=i/2)
{
if(i%j==0)
{
printf("%d IS NOT PRIME",i);
ch=1;
break;
}
else
{
j++;
}
}
if(ch==0)
{
printf("%d IS PRIME",i);
}
}

Is This Answer Correct ?    1243 Yes 384 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the advantages of a macro over a function?

641


main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none

722


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

1654


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

634


State the difference between x3 and x[3].

648






What is the difference between near, far and huge pointers?

628


What are void pointers in c?

574


What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?

583


Why c is known as a mother language?

636


What is a pointer value and address in c?

630


A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?

1508


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

637


Explain void pointer?

587


Why n++ execute faster than n+1 ?

1838


What is a pointer and how it is initialized?

605