write the program for prime numbers?
Answer Posted / karthik
#include<stdio.h>
#include<conio.h>
void main()
{
int n,c=0,i;
clrscr();
printf("enter any number");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(n%i==0)
c++;
}
(c==2)? printf("%d is a prime number",n):
printf("%d is not a prime number",n);
getch();
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
#define PRINT(int) printf("int = %d ",int) main() {< BR> intx,y,z; x=03;y=02;z=01; PRINT(x^x); z<<=3;PRINT(x); y>>=3;PRINT(y); }
How can I avoid the abort, retry, fail messages?
Can we increase size of array in c?
Write a code on reverse string and its complexity.
given post order,in order construct the corresponding binary tree
What is the modulus operator?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
What is a void pointer? When is a void pointer used?
What is pointers in c?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
What is the use of header?
What is the difference between if else and switchstatement
Write a program to check armstrong number in c?
What is stack in c?