prowessapps.in Series programs in C++

#include< iostream>
using namespace std;
int main() {
 int i, r, temp, sum =0;
 for(i=100; i<=500; i++) {
  temp = i;
  sum = 0;
  while(temp!=0) {
   r = temp%10;
   sum = sum+(r*r*r);
   temp = temp/10;
  }
  if(sum ==i) {
   cout<< i<<"  ";
  }
 }
cout<< endl;
return 0;
}
OUTPUT
153  370  371  407

#include< iostream>
using namespace std;
int main() {
 int n;
 cout<<"Enter the Value for N : ";
 cin>>n;
 for(int i = 1; i<=n; i++) {
  cout<< i<<"  ";
 }
 cout<< endl;
return 0;
}
OUTPUT
Enter the Value for N : 8
1  2  3  4  5  6  7  8

#include< iostream>
using namespace std;
int main() {
 int n;
 cout<<"Enter the Value for N : ";
 cin>>n;
 for(int i = 2; i<=n; i=i+2) {
  cout<< i<<"  ";
 }
 cout<< endl;
return 0;
}
OUTPUT
Enter the Value for N : 20
2  4  6  8  10  12  14  16  18  20 

#include< iostream>
using namespace std;
int main() {
 int n;
 cout<<"Enter the Value for N : ";
 cin>>n;
 for(int i = 1; i<=n; i=i+2) {
  cout<< i<<"  ";
 }
 cout<< endl;
return 0;
}
OUTPUT
Enter the Value for N : 20
1  3  5  7  9  11  13  15  17  19

#include< iostream>
using namespace std;
int main() {
 int n;
 cout<<"Enter the Value for N : ";
 cin>>n;
 for(int i = 1; i<=n; i++) {
  cout<< 3*i<<"  ";
 }
 cout<< endl;
return 0;
}
OUTPUT
Enter the Value for N : 10
3  6  9  12  15  18  21  24  27  30

#include< iostream>
#include< math.h>
using namespace std;
int main() {
 int n,value=0;
 cout<<"Enter the Value for N : ";
 cin>>n;
 for(int i = 0; i< n; i++) {
  value = value + pow(2,i);
  cout<< value<<"  ";
 }
 cout<< endl;
return 0;
}
OUTPUT
Enter the Value for N : 5
1  3  7  15  31

#include< iostream>
using namespace std;
int main() {
 int factors;
  for(int i = 1; i<=20; i++) {
   factors = 0;
   for(int j = 1; j<=i; j++) {
    if(i%j ==0)
     factors++;
   }
   if(factors ==2) {
	cout<< i<<"  ";
   }
  }
 cout<< endl;
 return 0;
}
OUTPUT
2  3  5  7  11  13  17  19 

#include< iostream>
using namespace std;
int main() {
 int n,a = -1, b = 1,c;
 cout<<"Enter the Value for N : ";
 cin>>n;
 for(int i = 1; i<=n; i++) {
  c = a+b;
  cout<< c<<"   ";
  a = b;
  b = c;
 }
 cout<< endl;
return 0;
}
OUTPUT
Enter the Value for N : 9
0   1   1   2   3   5   8   13   21

#include< iostream>
using namespace std;
int main() {
for(int i = 1; i<=5; i++) {
 for(int j = 1; j<=i; j++) {
  cout<< i<<"  ";
  }
 }
 cout<< endl;
return 0;
}
OUTPUT
1  2  2  3  3  3  4  4  4  4  5  5  5  5  5

#include< iostream>
using namespace std;
int main() {
 int i = 0, j = 0, n;
 cout<<"Enter the value for N : ";
 cin>>n;
 for(i = 1; i<=n; i++) {
  cout<< j<<"  ";
  j = j+i;
 }
 cout<< endl;
return 0;
}

OUTPUT
Enter the value for N : 7
0  1  3  6  10  15  21




CONTACT DETAILS

info@prowessapps.in
(8AM to 10PM):

+91-8527238801 , +91-9451396824

© 2017, prowessapps.in, All rights reserved