how to find the given number is prime or not?

Answers were Sorted based on User's Feedback



how to find the given number is prime or not?..

Answer / rahul tiwari

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=9
getch();
}

Is This Answer Correct ?    8 Yes 7 No

how to find the given number is prime or not?..

Answer / 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

how to find the given number is prime or not?..

Answer / shrikanth s.hallikhed

#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==1)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
getch();
}

Is This Answer Correct ?    3 Yes 3 No

how to find the given number is prime or not?..

Answer / arunkumar mt

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

Is This Answer Correct ?    2 Yes 3 No

how to find the given number is prime or not?..

Answer / 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

how to find the given number is prime or not?..

Answer / amit kumar

#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 ?    2 Yes 5 No

Post New Answer

More C Interview Questions

1) There is a singing competition for children going to be conducted at a local club. Parents have been asked to arrive at least an hour before and register their children’s names with the Program Manager. Whenever a participant registers, the Program Manager has to position the name of the person in a list in alphabet order. Write a program to help the Program Manager do this by placing the name in the right place each time the Program Manger enters a name. 2) the Event Manager has to send participants to the stage to perform in the order in which they registered. Write a program that will help the Event Manager know who to call to the stage to perform. The Logic should be in Data Structures

0 Answers   KPIT,


write a program to gat the digt sum of a number (et. 15= >1+5=6)

2 Answers  


What is floating point exception error? And what are different types of errors occur during compile time and run time? why they occur?

1 Answers  


#include <stdio.h> void main() { int i=-1,j=1,k,l; k=!i&&j; l=!i||j; printf ("%d%d",k,l) ; }

3 Answers   SRG,


The rich analysts of Fernand Braudel arid his fellow Annales historians have made significant contributions to historical theory and research. In a departure from traditional historical approaches, the Annales historians assume (as do Marxists) that history cannot be limited to a simple recounting of conscious human actions, but must be understood in the context of forces and material conditions that underlie human behavior. Braudel was the first Annales historian to gain widespread support for the idea that history should synthesize data from various social sciences, especially economics, in order to provide a broader view of human societies over time (although Febvre and Bloch, founders of the Annales school, had originated this approach). Braudel conceived of history as the dynamic interaction of three temporalities. The first of these, the evenmentielle, involved short-lived dramatic events such as battles, revolutions, and the actions of great men, which had preoccupied traditional historians like Carlyle. Conjonctures was Braudel’s term for larger cyclical processes that might last up to half a century. The longue duree, a historical wave of great length, was for Braudel the most fascinating of the three temporalities. Here he focused on those aspects of everyday life that might remain relatively unchanged for centuries. What people ate, what they wore, their means and routes of travel—for Braudel these things create “structures’ that define the limits of potential social change for hundreds of years at a time. Braudel’s concept of the longue duree extended the perspective of historical space as well as time. Until the Annales school, historians had taken the juridical political unit—the nation-state, duchy, or whatever—as their starting point. Yet, when such enormous timespans are considered, geographical features may well have more significance for human populations than national borders, In his doctoral thesis, a seminal work on the Mediterranean during the reign of Philip II, Braudel treated the geohistory of the entire region as a “structure” that had exerted myriad influences on human lifeways since the first settlements on the shores of the Mediterranean Sea. And so the reader is given such arcane information as the list of products that came to Spanish shores from North Africa, the seasonal routes followed by Mediterranean sheep and their shepherds, and the cities where the best ship timber could be bought. Braudel has been faulted for the imprecision of his approach. With his Rabelaisian delight in concrete detail, Braudel vastly extended the realm of relevant phenomena but this very achievement made it difficult to delimit the boundaries of observation, a task necessary to beginning any social investigation. Further, Braudel and other Annales historians minimize the differences among the social sciences. Nevertheless, the many similarly designed studies aimed at both professional and popular audiences indicate that Braudel asked significant questions that traditional historians had overlooked. 14) The primary purpose of the passage is to: a) show how Braudel’s work changed the conception of Mediterranean life held by previous historians. b) evaluate Braudel’s criticisms of traditional and Marxist historiography. c) contrast the perspective of the longue duree with the actions of major historical figures d) outline some of Braudel’s influential conceptions and distinguish them from conventional approaches. 15) The author refers to the work of Febvre and Bloch in order to: a) illustrate the limitations of the Annale tradition of historical interpretation. b) suggest the relevance of economics to historical investigation. c) debate the need for combining various sociological approaches. d) show that previous Annales historians anticipated Braudel’s focus on economics. 16) According to the passage, all of the following are aspects of Braudel’s approach to history EXCEPT that he: a) attempted to draw on various social sciences. b) studied social and economic activities that occurred across national boundaries. c) pointed out the link between increased economic activity and the rise of nationalism. d) examined seemingly unexciting aspects of everyday life. 17) In the third paragraph, the author is primarily concerned with discussing: a) Braudel’s fascination with obscure facts. b) Braudel’s depiction of the role of geography in human history. c) the geography of the Mediterranean region. d) the irrelevance of national borders. 18) The passage suggests that, compared with traditional historians, Annales/i> historians are: a) more interested in other social sciences than in history. b) critical of the achievements of famous historical figures. c) skeptical of the validity of most economic research. d) more interested in the underlying context of human behavior. 19) Which of the Following statements would be most likely to follow the last sentence of the passage? a) Few such studies however, have been written by trained economists. b) It is time, perhaps, for a revival of the Carlylean emphasis on personalities. c) Many historians believe that Braudel’s conception of three distinct “temporalities” is an oversimplification. d) Such diverse works as Gascon’s study of Lyon and Barbara Tuchman’s A Distant Mirror testify to his relevance. 20) The author is critical of Braudel’s perspective for which of the Following reasons a) It seeks structures that underlie all forms of social activity. b) It assumes a greater similarity among the social sciences than actually exists. c) It fails to consider the relationship between short-term events and long-term social activity. d) It rigidly defines boundaries for social analysis.

0 Answers   Accenture,






Write a C/C++ program that connects to a MySQL server and displays the global TIMEZONE.

0 Answers  


why do we use pointer instead directly acessing the data?

2 Answers  


How can I implement sets or arrays of bits?

0 Answers  


Does c have enums?

0 Answers  


main() { char x; while(x=0;x<=255;x++) printf("\nAscii value %d Charater %c",x,x); }

2 Answers  


What is the difference between a string and an array?

0 Answers  


what is the need for main function in c?

5 Answers  


Categories