Write a program to check whether a number is prime or not using c?



Write a program to check whether a number is prime or not using c?..

Answer / Ram Dwivedi

[Code omitted due to character limit. Here's the code in multiple lines:]nn```cn#include <stdio.h>nnint main() {n int num, i;n printf("Enter a number: ");n scanf("%d", &num);nn if (num <= 1) {n printf("%d is not prime
", num);n } else {n for (i = 2; i < sqrt(num); i++) {n if (num % i == 0) {n printf("%d is not prime
", num);n break;n }n }n if (i > sqrt(num)) {n printf("%d is prime
", num);n }n }n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

In this assignment you are asked to write a multithreaded program to find the duplicates in an array of 10 million integers. The integers are between -5000,000 to 5000,000 and are generated randomly. Use 10 threads, each thread works on 1000,000 integers. Compare the time needed to accomplish the task with single thread of execution program. Do not include the time to fill the array with integers in the execution time.

1 Answers  


How would you rename a function in C?

1 Answers   Tech Mahindra,


how we can make 3d venturing graphics on outer interface

2 Answers   Microsoft,


how to execute with out main in cprogram

15 Answers   Infosys,


What are static functions?

1 Answers  


In which language linux is written?

1 Answers  


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

1 Answers  


Explain union. What are its advantages?

1 Answers  


Write a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors

3 Answers  


Write programs for String Reversal & Palindrome check

1 Answers   TISL,


whitch value return void main?

11 Answers  


What is the Difference between Class and Struct?

10 Answers   Motorola,


Categories