how to find the given number is prime or not?
Answer Posted / shweta
#include<stdio.h>
#include<conio.h>
void main()
{
int n,ctr=2,flag=0;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=n/2;ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==1)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
flag=0;
getch();
}
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
Can we change the value of constant variable in c?
How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
Is c call by value?
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
How do I use void main?
Explain how do you view the path?
What is a union?
What do you mean by command line argument?
What is the difference between local variable and global variable in c?
Explain what is the stack?
What is hash table in c?
How can I read/write structures from/to data files?
Why is c called c not d or e?
How do I copy files?