how to find the given number is prime or not?

Answer Posted / rajamanickam.m

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,flag=0,ctr;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=sqrt(n);ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==0)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
getch();
}

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is 1d array in c?

602


how could explain about job profile

1455


which type of aspect you want from the student.

1703


The statement, int(*x[]) () what does in indicate?

647


C program to find all possible outcomes of a dice?

1855






If you know then define #pragma?

676


What is hungarian notation? Is it worthwhile?

699


In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]

1959


Which header file should you include if you are to develop a function which can accept variable number of arguments?

810


What’s the special use of UNIONS?

659


How many keywords (reserve words) are in c?

621


Explain setjmp()?

659


Under what circumstances does a name clash occur?

692


what is stack , heap ,code segment,and data segment

2224


Differentiate between Macro and ordinary definition.

731