write the program for prime numbers?
Answer Posted / arafat buet
#include<stdio.h>
int main()
{
int i,n,r;
printf("enter any number:");
scanf("%d",&n);
if(n==1)
printf("not prime\n");
for(i=2;i<n;i++)
{
r=n%2;
if(r==0)
{
printf("\nnot prime\n");
break;
}
}
if(i==n)
printf("prime\n");
return 0;
}
| Is This Answer Correct ? | 24 Yes | 19 No |
Post New Answer View All Answers
What are the different types of linkage exist in c?
What is the collection of communication lines and routers called?
What is restrict keyword in c?
How do you search data in a data file using random access method?
How can I read data from data files with particular formats?
What is unary operator?
How is a pointer variable declared?
What is nested structure in c?
What does c mean in standard form?
What is the advantage of using #define to declare a constant?
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?
What is the method to save data in stack data structure type?
Are the outer parentheses in return statements really optional?
program to convert a integer to string in c language'
What is an expression?