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
Who invented b language?
What is the purpose of void pointer?
What are the preprocessor categories?
Which header file is essential for using strcmp function?
Given an array of 1s and 0s arrange the 1s together and 0s together in a single scan of the array. Optimize the boundary conditions?
What is difference between Structure and Unions?
What is a shell structure examples?
What is difference between static and global variable in c?
What is maximum size of array in c?
What is difference between arrays and pointers?
What are c identifiers?
Write a c program to demonstrate character and string constants?
What's the best way of making my program efficient?
What are the types of type qualifiers in c?
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?