Program to Reverse Number in C++

Here you will get program to reverse number in C++. #include<iostream> using namespace std; int main() { long n,rev=0,d; cout<<“Enter any number:”; cin>>n; while(n!=0) { d=n%10; rev=(rev*10)+d; n=n/10; } cout<<“The reversed number is “<<rev; return 0; }   Output Enter any number:12674 The reversed number is 47621

C++ program to print the following pattern:

#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) { cout<<“n”; for(j=n;j>i;j-=2) cout<<” “; for(k=0;k<=i;++k) cout<<“*”; } 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) { cout<<“n”; for(j=1;j<i;j+=2) cout<<” “; for(k=n-1;k>i;–k) cout<<“*”; } getch(); //to stop the screen}

Matrix Multiplication in C

Here is the program for matrix multiplication in C. m and n are rows and columns of first matrix. p and q are rows and columns of second matrix. Then, multiplication is possible only if n==p.   Matrix Multiplication in C #include<stdio.h> int main() { int a[5][5],b[5][5],c[5][5],m,n,p,q,i,j,k; printf(“Enter rows and columns of first matrix:”); scanf(“%d%d”,&m,&n); …

Matrix Multiplication in C Read More »

C++ program to create a loading bar

#include<iostream.h> #include<conio.h> #include<graphics.h> #include<dos.h> void main() { int x=170,i,gdriver=DETECT,gmode; initgraph(&gdriver,&gmode,”c:\tc\bgi”); settextstyle(DEFAULT_FONT,HORIZ_DIR,2); outtextxy(170,180,”LOADING,PLEASE WAIT”); for(i=0;i<300;++i) { delay(30); line(x,200,x,220); x++; } getch(); closegraph(); }

C++ Matrix Multiplication Program

Here you will get C++ matrix multiplication program. What we are doing in this program. Read number of rows and columns for two matrix. Then check if matrix multiplication is possible or not. If not possible then show a message to user otherwise multiply them. Finally display the result. C++ Matrix Multiplication Program #include<iostream> using …

C++ Matrix Multiplication Program Read More »

C program to find the sum of the series x+x^2/2+x^3/3+…..+x^n/n

#include<stdio.h>#include<conio.h>#include<math.h>void main(){ int i,n; float x,sum=0; clrscr(); //to clear the screen printf(“x+x^2/2+x^3/3+…..+x^n/n”); printf(“nEnter value of x and n:”); scanf(“%f%d”,&x,&n); for(i=1;i<=n;++i) sum+=pow(x,i)/i; printf(“nsum=%f”,sum); getch(); //to stop the screen}