Results 1 to 4 of 4

Thread: Finding Prime number without any loop

  1. #1
    RanaFaheemAg's Avatar
    RanaFaheemAg is offline Senior Member+
    Last Online
    30th December 2014 @ 11:53 PM
    Join Date
    10 Sep 2012
    Location
    Mianwali
    Age
    31
    Gender
    Male
    Posts
    38
    Threads
    12
    Credits
    0
    Thanked
    0

    Default Finding Prime number without any loop

    #include<iostream.h> //Created by:RanaFaheemA.G Oct/28/2013
    #include<conio.h>
    void main(){
    clrscr();
    long user;
    repeat:
    cout<<"\n\n\tType an integer to know whether it is prime num or not\t";
    cin>>user;
    // 2,3,5,7 are prime numbers
    if(user==2 || user==3 || user==5 || user==7 )
    cout<<"\n\t"<<user <<"\tis a prime number";
    // these are not prime numbers
    else if(user%2==0 || user%3==0 || user%5==0 || user%7==0 || user%9==0)
    cout<<"\n\t"<<user <<"\tis not prime number";
    //these are prime numbers
    else
    cout<<"\n\t"<<user <<"\tis a prime number";

    //continuing program
    char choice;
    cout<<"\n\n\tContinue? (Y/N)\t";
    cin>>choice;
    if(choice=='Y' || choice=='y')goto repeat;
    else
    cout<<"\n\tPress any key to close...\n\n\n\n\n";
    getch();
    }

  2. #2
    Xeathprynx is offline Junior Member
    Last Online
    16th April 2015 @ 09:00 PM
    Join Date
    25 Jun 2013
    Location
    Rwp
    Age
    30
    Gender
    Male
    Posts
    28
    Threads
    8
    Credits
    0
    Thanked: 1

    Unhappy

    but 11*11 = 121 it is not prime.you showed only modulus of 2, 3, 5 and 7 .plz give it a try

  3. #3
    Samar Kazmii is offline Senior Member+
    Last Online
    30th September 2021 @ 01:21 PM
    Join Date
    30 Oct 2013
    Location
    Sindh,Khairpur
    Age
    29
    Gender
    Male
    Posts
    280
    Threads
    32
    Credits
    90
    Thanked
    11

    Default

    Very nice post..... Zbrdast thanx

  4. #4
    hamzachohan is offline Advance Member
    Last Online
    24th November 2023 @ 02:41 AM
    Join Date
    26 Dec 2010
    Age
    30
    Gender
    Male
    Posts
    632
    Threads
    57
    Credits
    1,306
    Thanked
    192

    Default

    gud one (Y)

Similar Threads

  1. Part#1 :Mobile Secret Codes
    By aariyan in forum General Mobile Discussion
    Replies: 6
    Last Post: 1st June 2012, 01:02 PM
  2. Ufone 1 sim say 2 number wow
    By Jani194 in forum General Mobile Discussion
    Replies: 62
    Last Post: 11th September 2011, 09:40 AM
  3. Portible Karne ka tariqa warid mein
    By akram123khan25 in forum General Mobile Discussion
    Replies: 5
    Last Post: 2nd August 2011, 06:55 PM
  4. Mobile Secret codes...........
    By nasir rehman in forum General Mobile Discussion
    Replies: 16
    Last Post: 22nd August 2009, 01:32 PM
  5. Nokia mobile codes..SEE IT FIRST BE IT FISRT
    By DeadMan in forum General Mobile Discussion
    Replies: 9
    Last Post: 12th August 2009, 12:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •