SlideShare a Scribd company logo
1 of 2
#include <iostream>

#include <cstdlib>

#include <math.h>




int main(){

     system C"color f1");



     int B=2;

     int C=2;

     int D=0;

     int I=0;

     int E=200;

cout<<"....................Numeros Primos........................nnn";



cout<<"Numeros Primos entre 1 y 200: nn";



 scanf("%d",&E);

     for(B;B<=E;B++){

                C=2;

                while((C<=B) && (B%C!=0)){

                       C++;}

                       if(B==C){printf("%6d",C); D++; I++; if(D==10){printf("n");D=0;}}

 }

printf("nTotaL D NuMeRoS pRiMoS eS D: %dn",I);
system("PAUSE");

    return 0;

}
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
int n,suma=0;
cout<<"Ingrese N: ";
cin>>n;
if(n<2)
cout<<"Error.n";
else {for(int i=2;i<=n;i+=2)
suma+=i;
cout<<"La suma es: "<<suma<<endl;}
system("pause");
return 0;}

More Related Content

What's hot

C & Python Introduction
C & Python IntroductionC & Python Introduction
C & Python IntroductionSpy Seat
 
Project code for Project on Student information management system
Project code for Project on Student information management systemProject code for Project on Student information management system
Project code for Project on Student information management systemREHAN IJAZ
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Syed Umair
 
Assignement of c++
Assignement of c++Assignement of c++
Assignement of c++Syed Umair
 
Programa.eje
Programa.ejePrograma.eje
Programa.ejeguapi387
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloadingmohamed sikander
 
Oops in c++
Oops in c++Oops in c++
Oops in c++DravidSh
 

What's hot (14)

C & Python Introduction
C & Python IntroductionC & Python Introduction
C & Python Introduction
 
HOTEL MANGEMENT
HOTEL MANGEMENTHOTEL MANGEMENT
HOTEL MANGEMENT
 
Project code for Project on Student information management system
Project code for Project on Student information management systemProject code for Project on Student information management system
Project code for Project on Student information management system
 
Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)Assignement of programming & problem solving u.s ass.(1)
Assignement of programming & problem solving u.s ass.(1)
 
Assignement of c++
Assignement of c++Assignement of c++
Assignement of c++
 
10 3 다중 배열
10 3 다중 배열10 3 다중 배열
10 3 다중 배열
 
Programa.eje
Programa.ejePrograma.eje
Programa.eje
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Ruby haskell extension
Ruby haskell extensionRuby haskell extension
Ruby haskell extension
 
C++ Question on References and Function Overloading
C++ Question on References and Function OverloadingC++ Question on References and Function Overloading
C++ Question on References and Function Overloading
 
Code
CodeCode
Code
 
Cpp
Cpp Cpp
Cpp
 
Oops in c++
Oops in c++Oops in c++
Oops in c++
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 

Viewers also liked (10)

Estación 5
Estación 5Estación 5
Estación 5
 
4
44
4
 
Fira Almenar 2012
Fira Almenar 2012Fira Almenar 2012
Fira Almenar 2012
 
Fichas de trabajo
Fichas de trabajoFichas de trabajo
Fichas de trabajo
 
Miasms
MiasmsMiasms
Miasms
 
TUGAS TIK XI MIPA 7 KELOMPOK 4
TUGAS TIK XI MIPA 7 KELOMPOK 4TUGAS TIK XI MIPA 7 KELOMPOK 4
TUGAS TIK XI MIPA 7 KELOMPOK 4
 
Presentation2
Presentation2Presentation2
Presentation2
 
Certificate (1)
Certificate (1)Certificate (1)
Certificate (1)
 
Rogers-Vincent-II
Rogers-Vincent-IIRogers-Vincent-II
Rogers-Vincent-II
 
certificate sexual
certificate sexualcertificate sexual
certificate sexual
 

Similar to C++ Prime Number Printer

C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st StudyChris Ohk
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in CSaket Pathak
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207Syed Tanveer
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020vrgokila
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2Koshy Geoji
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentalsZaibi Gondal
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_papervandna123
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 
Lecture no 3
Lecture no 3Lecture no 3
Lecture no 3hasi071
 
Program flowchart
Program flowchartProgram flowchart
Program flowchartSowri Rajan
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 

Similar to C++ Prime Number Printer (20)

C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 
C++ Programming - 1st Study
C++ Programming - 1st StudyC++ Programming - 1st Study
C++ Programming - 1st Study
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
Lab. Programs in C
Lab. Programs in CLab. Programs in C
Lab. Programs in C
 
Cpd lecture im 207
Cpd lecture im 207Cpd lecture im 207
Cpd lecture im 207
 
programs
programsprograms
programs
 
Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020Basic c programs updated on 31.8.2020
Basic c programs updated on 31.8.2020
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
C Programming
C ProgrammingC Programming
C Programming
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Programming fundamentals
Programming fundamentalsProgramming fundamentals
Programming fundamentals
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
Lecture no 3
Lecture no 3Lecture no 3
Lecture no 3
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 

C++ Prime Number Printer

  • 1. #include <iostream> #include <cstdlib> #include <math.h> int main(){ system C"color f1"); int B=2; int C=2; int D=0; int I=0; int E=200; cout<<"....................Numeros Primos........................nnn"; cout<<"Numeros Primos entre 1 y 200: nn"; scanf("%d",&E); for(B;B<=E;B++){ C=2; while((C<=B) && (B%C!=0)){ C++;} if(B==C){printf("%6d",C); D++; I++; if(D==10){printf("n");D=0;}} } printf("nTotaL D NuMeRoS pRiMoS eS D: %dn",I);
  • 2. system("PAUSE"); return 0; } #include <iostream> #include <stdlib.h> using namespace std; int main(){ int n,suma=0; cout<<"Ingrese N: "; cin>>n; if(n<2) cout<<"Error.n"; else {for(int i=2;i<=n;i+=2) suma+=i; cout<<"La suma es: "<<suma<<endl;} system("pause"); return 0;}