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
Write a program to print “hello world” without using semicolon?
What is the basic structure of c?
What are the different types of errors?
Explain what is wrong in this statement?
using only #include
Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix
What is a memory leak? How to avoid it?
What are the keywords in c?
Write a C program to help a HiFi’s Restaurant automate its breakfast billing system. Your assignment should implement the following items: a. Show the customer the different breakfast items offered by the HiFi’s Restaurant. b. Allow the customer to select more than one item from the menu. c. Calculate and print the bill to the customer. d. Produce a report to present your complete program and show more sample output. Assume that the HiFi’s Restaurant offers the following breakfast menu: Plain Egg $2.50 Bacon and Egg $3.45 Muffin $2.20 French Toast $2.95 Fruit Basket $3.45 Cereal $0.70 Coffee $1.50 Tea $1.80
What’s a signal? Explain what do I use signals for?
How #define works?
What is scope rule of function in c?
Can a file other than a .h file be included with #include?
a number whose only prime factors are 2,3,5, and 7 is call humble number,,write a program to find and display the nth element in this sequence.. sample input : 2,3,4,11,12,13, and 100.. sample output : the 2nd humble number is 2,the 3rd humble number is 3,the 4th humble number is ,the 11th humble number is 12, the 12th humble number is 14, the 13th humble number is 15, the 100th humble number is 450.
How can I get random integers in a certain range?