write the program for prime numbers?

Answer Posted / harpreet dhillon

#include<stdio.h> \\harpreetdhillon7@gmail.com
#include<conio.h>
void main()
{
int i,n;
clrscr();
printf("enter any number which you want to check");
scanf("%d",&n);
for(i=2;i<=n-1;i++)
{
if(n%i==0)
{
printf("not a prime number\n");
break;
}
else
{
printf("prime number\n");
break;
}
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between procedural and declarative language?

649


What is a char c?

592


An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array

688


Sir,please help me out with the code of this question. Write an interactive C program that will encode or decode multiple lines of text. Store the encoded text within a data file, so that it can be retrieved and decoded at any time. The program should include the following features: (a) Enter text from the keyboard, encode the text and store the encoded text in a data file. (b) Retrieve the encoded text and display it in its encoded form. (c) Retrieve the encoded text, decode it and then display the decoded text. (d) End the computation. Test the program using several lines of text of your choice.

1766


What is actual argument?

589






Is it better to use malloc() or calloc()?

647


Explain what is the benefit of using an enum rather than a #define constant?

720


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

660


What is the difference between malloc() and calloc() function in c language?

602


what is event driven software and what is procedural driven software?

2015


List out few of the applications that make use of Multilinked Structures?

1296


Why cant I open a file by its explicit path?

593


What is the meaning of typedef struct in c?

594


Difference between MAC vs. IP Addressing

639


What are the different types of pointers used in c language?

612