Skip to main content

C++ Program to find out the Prime number's By sieve Method

NOTE : YOU CAN DOWNLOAD EXE FILE HERE: SIEVE.EXE
SORUCE CODE (RTF): source.cpp click here




 #include <iostream>
 2  #include <conio.h>
 3  using namespace std;
 4  int main()
 5 
 6  {
 7 
 8  int number,n=2;
 9  cout<<"Program to find out Prime number by sieve method\n\n\a";
10 
11  cout<<"Enter upto which number you want to find out the prime number\n";
12  cin>>number;
13  int arr[number];
14  for(int i=0;i<number;i++)
15  arr[i]=i+1;
16  cout<<"  Original number:\n";
17 
18  for(int i=0;i<number;i++)
19  {
20 
21 
22      cout<<arr[i]<<"\t\a";
23 
24  }
25  while((n*n)<number// while nis less than original  number
26 
27  {
28 
29  for(int i=n;i<number;i++)
30  {
31  if(arr[i]%n==0)
32  {
33  arr[i]=-1;
34  }
35  }
36  n++;
37 
38 
39  }
40  cout<<" \n\n Sieve Format:\n";
41 
42  for(int i=0;i<number;i++)
43  {
44 
45      if(arr[i]==-1) cout<<"X\t";
46  else
47 
48      cout<<arr[i]<<"\t\a";
49 
50  }
51  cout<<"  Prime number's are given belows:\n";
52 
53  for(int i=0;i<number;i++)
54  {
55 
56      if(arr[i]==-1) continue;
57 
58 
59      cout<<arr[i]<<"\t\a";
60 
61  }
62 
63  getch();

64  }




NOTE : YOU CAN DOWNLOAD EXE FILE HERE: SIEVE.EXE

Comments

Popular posts from this blog

13 websites to register your free domain

Register your Free Domain Now!! 1)  .tk Dot TK is a FREE domain registry for websites on the Internet. It has exactly the same power as other domain extensions, but it’s free! Because it’s free, millions of others have been using .TK domains since 2001 – which makes .TK powerful and very recognizable.  Your website will be like www.yourdomainname.tk . It is free for 1 year. It’s a ccTLD domain whixh having the abbreviation  Tokelau. To create a .tk domain, Visit   www.dot.tk 2) co.cc Co.cc is completely free domain which is mostly used by blogspot bloggers because of it’s easy to use DNS system. Creating a co.cc for blogger is simple ( for instructions- “click here”). Your website will be like www.yourdomainname.co.cc . To create a .co.cc domain, visit www.co.cc 3)   co.nr co.nr is too like co.cc. Your website will be like  www.yourdomainname.co.nr . You can add it for blogger also.. To create a .co.cc domain, vi...

How to Put Google Adsense Below Post Title in Blogger?

Adsense is used by majority of expert bloggers for their website monetization because it is a cookie based contextual advertising system that shows targeted ads relevant to the content and reader. As bloggers are paid on per click basis, they try various ad placements on the blog to  increase the revenue  and get maximum clicks on the ad units. Well, on some blogs, you might have seen Adsense ad units placed below the post title. Do you know why? It is because the area just below the post title gets the most exposure and is the best place to put AdSense ad units to increase  Click Through Rate (CTR). Even though ads below post title work like a charm but this doesn’t mean that it will work for you as well. If you want to find out the best AdSense ads placement for your blog, try experimenting by placing ads at various locations such as header, sidebar, footer, etc. You can try other  blog monetization methods  as well to effectively monetize y...

QWERTY-keyboard when this idean came

QWERTY QWERTY   / ˈ k w Éœr t i /  is the most common modern-day  keyboard layout . The name comes from the first six  keys  appearing on the top left letter row of the keyboard and read from left to right: Q-W-E-R-T-Y. The QWERTY design is based on a layout created for the  Sholes and Glidden typewriter  and sold to  Remington  in 1873. It became popular with the success of the Remington No. 2 of 1878, and remains in use on electronic keyboards due to the  network effect  of a standard layout and a belief that  alternatives  fail to provide very significant advantages. [ 1 ]  The use and adoption of the QWERTY keyboard is often viewed as one of the most important case studies in  open standards  because of the widespread, collective adoption and use of the product. [ 2 ] History and purposes [ edit ] Keys are arranged on diagonal columns, to give space for the levers. Main article:  Sh...

Find Serial Key / Cracks for Any Software !

This time i am going to explain you that how you can "Find Serial Key / Cracks for Any Software !".I assume that most of you use pirated software. Not everyone can afford buying a program like Photoshop, which costs $699. In this case you can use alternative, free software or you can download a pirated, cracked version of the program. There is a vast number of websites out there, where you can find serial numbers and cracks for any program, but most of them aren't safe to use. Actually most of them are spam sites that “bombard” you with full-screen popup ads, or commandeer your computer into a spam-loving Kraken or Srizbi Botnet army. In this post I will show you the most efficient way of downloading cracks and serial numbers without any risk to your pc. This is the part of Hacking/Cracking using "Google hacking". Google Hacking : I will explain google hacking in details in next article very soon.But for now its enough to know that,Google hacking means..ho...

python program to Print Starting Series OF Indian Mobile Number for a State or operator or both

import requests import urllib.request import time from bs4 import BeautifulSoup as bs import re url = ' https://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India' state_to_extract = "UE" #if set to None all state is considered telecom_to_extracted = None #if set to none all operator from particular city is extracted response = requests . get(url) print (response) soup = bs(response . text, "html.parser" ) one_a_tag = soup . findAll( 'tr' )[ 35 :] lst = [] for k in one_a_tag: s = k . findAll( 'td' ) limit = len (s) i = 0 while True : if i == limit: break no = s[i] . text i += 1 if i == limit: break operator = s[i] . text i += 1 if i == limit: break state = s[i] . text i += 1 if i == limit: break res = f "{no} {operator} {state}" if state_to_extract is None : if telecom_to_extracted is None : lst . append(no) elif telecom_to_e...

Binary to Decimal using Stack in C

CODE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 #include <stdio.h> #include <stdlib.h> #define SIZE 8 int STACK[SIZE],TOP =- 1 ; int power ( int i) { int res = 1 ; while (i -- ) { res = res * 2 ; } return res; } void push ( int n) { if (TOP == SIZE) printf( "OVerflow" ); else STACK[ ++ TOP] = n; } int pop () { if (TOP ==- 1 ) return - 1 ; else return STACK[TOP -- ]; } void main () { int num,i = 0 ,arr[SIZE],j,res = 0 ,temp; printf( "Enter the number" ); scanf( "%d" , & num); printf( " \n Entered number=%d \n " ,num); while (num) { arr[i ++ ] = num % 10 ; num /= 10 ; } for (j = i - 1 ;j >= 0 ;j -- ) push(arr[j]); for (j = 0 ;j < i;j ++ ) { res = res + (pop() * power(j)); } printf( " \n Result=%d" ,res); getchar...

Data Types in C

Objectives: Having read this section you should be able to: 1.declare (name) a local variable as being one of C's five data types 2.initialise local variables 3.perform simple arithemtic using local variables Now we have to start looking into the details of the C language. How easy you find the rest of this section will depend on whether you have ever programmed before - no matter what the language was. There are a great many ideas common to programming in any language and C is no exception to this rule. So if you haven't programmed before, you need to take the rest of this section slowly and keep going over it until it makes sense. If, on the other hand, you have programmed before you'll be wondering what all the fuss is about It's a lot like being able to ride a bike! The first thing you need to know is that you can create variables to store values in. A variable is just a named area of storage that can hold a single value (numeric or character). C is very f...

what is LOREM ipsum and why do designers use it

What is Lorem Ipsum? Lorem Ipsum  is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now...

Access Your Facebook Account with 3 Passwords

Did you know that you can login to your Facebook account using 3 different passwords? Seems interesting isn’t it? Yep! Unlike any other online account which has only one password to access, Facebook lets you log in using 3 different variants of your password. Only a few Facebook users are aware of this fact, but for many others, this might seem a bit surprising. Facebook accepts the following forms of your password: 1. Your Original Password Let me explain this to you with the following example. Assume that your default Facebook password that you created during the sign-up process is: 2. Password with the Case Toggled In the above password the letters ‘F’ and ‘P’ are in uppercase and the remaining are in the lowercase. If you TOGGLE the case where all the UPPERCASE characters are converted into the lowercase and vice versa, your default password “myFacebookPass” would become: Now if you log in using the above toggled password, your Facebook will accept it and welcomes yo...