write the program for prime numbers?
Answer Posted / pratibha
#include<stdio.h>
#include<conio.h>
void main()
{
int no,i,count=0;
clrscr();
printf("enter the no");
scanf("%d",&no);
for(i=1;i<=no;i++)
{
if(no%i==0)
{
count=count+1;
}
}
if(count<=2)
{
printf("this is prime no");
}
else
{
printf("this is not prime");
}
getch();
}
| Is This Answer Correct ? | 17 Yes | 14 No |
Post New Answer View All Answers
What is sorting in c plus plus?
What standard functions are available to manipulate strings?
What is the difference between malloc calloc and realloc in c?
given post order,in order construct the corresponding binary tree
What is the difference between new and malloc functions?
What does node * mean?
what is event driven software and what is procedural driven software?
What is a header file?
What should malloc(0) do? Return a null pointer or a pointer to 0 bytes?
What are the storage classes in C?
what will be maximum number of comparisons when number of elements are given?
Explain how are 16- and 32-bit numbers stored?
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?
Write a program for finding factorial of a number.
Is there anything like an ifdef for typedefs?