C++ program to find sum of series 1+x+x^2+……+x^n

#include<iostream.h>#include<conio.h>#include<math.h> void main(){ clrscr(); //to clear the screen long i,n,x,sum=1; cout<<“1+x+x^2+……+x^n”; cout<<“nnEnter the value of x and n:”; cin>>x>>n; for(i=1;i<=n;++i) sum+=pow(x,i); cout<<“nSum=”<<sum; getch(); //to stop the screen}

C program to print following trianlge using character *

#include<stdio.h> #include<conio.h> void main() { int i,j,k,n; clrscr(); //to clear the screen printf(“How many lines?”); scanf(“%d”,&n); for(i=0;i<n;++i) { printf(“n”); for(j=0;j<i;++j) printf(” “); for(k=n;k>i;–k) printf(“*”); } getch(); //to stop the screen }

C program to print following square using character *

#include<stdio.h> #include<conio.h> void main() { int i,j,n; clrscr(); //to clear the screen printf(“Enter size of the square:”); scanf(“%d”,&n); for(i=0;i<n;++i) { printf(“n”); for(j=0;j<n;++j) { if(i==0||i==n-1||j==0||j==n-1) printf(“*”); else printf(” “); } } getch(); //to stop the screen }

C++ program to print following square using character *

#include<iostream.h>#include<conio.h> void main(){ clrscr(); //to clear the screen int i,j,n; cout<<“Enter size of the square:”; cin>>n; for(i=0;i<n;++i) { cout<<“n”; for(j=0;j<n;++j) { if(i==0||i==n-1||j==0||j==n-1) cout<<“*”; else cout<<” “; } } getch(); //to stop the screen}

C program to print the following design

#include<stdio.h> #include<conio.h> void main() { int i,j,k,n; clrscr(); //to clear the screen printf(“How many lines?”); scanf(“%d”,&n); n*=2; for(i=0;i<n;i+=2) { for(j=n-2;j>i;j-=2) printf(” “); for(k=0;k<=i;++k) printf(“*”); printf(“n”); } for(i=0;i<n;i+=2) { for(j=0;j<i;j+=2) printf(” “); for(k=n-1;k>i;–k) printf(“*”); printf(“n”); } getch(); //to stop the screen }

C++ program to print the following design

#include<iostream.h>#include<conio.h> void main(){ clrscr(); //to clear the screen int i,j,k,n; cout<<“How many lines?”; cin>>n; n*=2; for(i=0;i<n;i+=2) { for(j=n-2;j>i;j-=2) cout<<” “; for(k=0;k<=i;++k) cout<<“*”; cout<<“n”; } for(i=0;i<n;i+=2) { for(j=0;j<i;j+=2) cout<<” “; for(k=n-1;k>i;–k) cout<<“*”; cout<<“n”; } getch(); //to stop the screen}

Basic concepts of OOP

The object oriented programming has been developed with a view to overcome the drawbacks of conventional programming approaches. The OOP approach is based on certain concepts that help it attain its goal of overcoming the drawbacks of shortcomings of conventional programming approaches. These general concepts of OOP are given below: Also Read: How to write and …

Basic concepts of OOP Read More »