PROGRAM TO FIND OUT WHETHER THE GIVEN NUMBER IS PRIME OR NOT

C, C++, etc Programing examples. Post as many you can. Test the programs and discuss about the output of the programes.
Forum rules
Please Discuss & post only about the programes and its Output

PROGRAM TO FIND OUT WHETHER THE GIVEN NUMBER IS PRIME OR NOT

Postby rohit.wadhwa » Wed Mar 18, 2009 5:58 pm

Code: Select all
     
/* PROGRAM TO FIND OUT WHETHER THE GIVEN NUMBER IS PRIME OR NOT PRIME*/
     /* author-Rohit Wadhwa*/
     #include<stdio.h>
     #include<conio.h>
     void  main()
    {
    int n;
    int val;
    int i=2;
    int flag=1;
    printf("Enter a number Check for Prime or not prime:\n");
    scanf("%d",&n);
    while(i<n)
    {
   if(n%i==0) /*also there is a  2nd algo only replace with this if((n/2)%i==0)*/
        {
   flag=0;
   break;
   }
   i++;
    }
    if(flag==1)
     printf("%d is a prime number",n);
     else
     printf("%d is  not a prime number",n);
    getch();
    }
Thanks
Rohit Wadhwa
Site : Study Site
User avatar
rohit.wadhwa
Moderator
 
Posts: 53
Joined: Mon Mar 16, 2009 4:00 pm
Location: Hisar(Haryana)
membership: Senior Technician of The Institution of Engineers (India)- ST

Re: PROGRAM TO FIND OUT WHETHER THE GIVEN NUMBER IS PRIME OR NOT

Postby skyblue » Thu Mar 19, 2009 9:21 am

Thanks rohit for sharing Programming with us .
I would like to request u that can u make word document of all programms which u r having & send it to mail ID.we will upload it in FTP.It will be easier for all to refer.
Please if u can.
Komal
User avatar
skyblue
Site Advisor
 
Posts: 435
Joined: Mon Feb 16, 2009 12:59 pm
membership: Senior Technician of The Institution of Engineers (India)- ST

Re: PROGRAM TO FIND OUT WHETHER THE GIVEN NUMBER IS PRIME OR NOT

Postby rohit.wadhwa » Thu Mar 19, 2009 9:59 am

ok i am also include some program posted by parveen sir ,
actually i am make a document today( Wednesday ).
i am share a Google Doc with you and update it time 2 time,
Wednesday i have some time so i make some program and post here!

so in my Google doc you find same program! if i have update i tell you

i am sharing with you ok!
Thanks
Rohit Wadhwa
Site : Study Site
User avatar
rohit.wadhwa
Moderator
 
Posts: 53
Joined: Mon Mar 16, 2009 4:00 pm
Location: Hisar(Haryana)
membership: Senior Technician of The Institution of Engineers (India)- ST

Re: PROGRAM TO FIND OUT WHETHER THE GIVEN NUMBER IS PRIME OR NOT

Postby rohit.wadhwa » Thu Mar 19, 2009 10:58 am

As per your request, i send the docs to you
pls collect it.
And i am able to download the question paper but for reading, i have no password so please provide me the password as soon as possible .
Thanks in advance
Thanks
Rohit Wadhwa
Site : Study Site
User avatar
rohit.wadhwa
Moderator
 
Posts: 53
Joined: Mon Mar 16, 2009 4:00 pm
Location: Hisar(Haryana)
membership: Senior Technician of The Institution of Engineers (India)- ST

Re: PROGRAM TO FIND OUT WHETHER THE GIVEN NUMBER IS PRIME OR NOT

Postby praveen » Thu Mar 19, 2009 12:54 pm

hI Rohit,
You can post programs as you posted in this topic, The category "Some Sample Programs " is only for discussing about the programs. so no problem just you can copy paste here..

Password has been provided with the post itself. check the post again. let me know if you have any password issue..

Thanks
Praveen
Regards,
Praveen
AMIE Study

-------------------------------------------------------------------------------------------
Work from Home | Malayalam Fun | Sree Narayana Guru | Technical Discussion
User avatar
praveen
Site Admin
 
Posts: 804
Joined: Thu Oct 23, 2008 1:42 pm
Location: Mumbai
membership: Senior Technician of The Institution of Engineers (India)- ST

Re: PROGRAM TO FIND OUT WHETHER THE GIVEN NUMBER IS PRIME OR NOT

Postby skyblue » Thu Mar 19, 2009 2:44 pm

Praveen/Rohit,
Praveen ,it will be easier for the reader if it is in one document.
Anyway rohit u can post it whatever way u feel ok .

Komal
User avatar
skyblue
Site Advisor
 
Posts: 435
Joined: Mon Feb 16, 2009 12:59 pm
membership: Senior Technician of The Institution of Engineers (India)- ST


Return to Computer Notes : Some Sample Programs

Who is online

Users browsing this forum: No registered users and 0 guests