HomeHome  SearchSearch  RegisterRegister  Log in  

Share | 
 

 Various Useful Programs

Go down 
AuthorMessage
Anupam (Administrator)
Admin
avatar

Posts : 117
Join date : 2012-02-25

PostSubject: Various Useful Programs   Fri Nov 23, 2012 10:26 am

• M.S.
PALINDROME NO.

Quote :
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,n,s=0;
cout<<"Enter the number:";
cin>>n;
int x=n;
while(n!=0)
{
a=n%10;
s=(s*10)+a;
n=n/10;
}
if(x==s)
cout<<"Palindrome";
else
cout<<"Not palindrome";
getch();
}

M.S.
1-u+ u^2/2! - u^3/3!..........
Quote :
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
long n,x,j;
float sum=1;
int fact(int);
cout<<"Enter the limit:";
cin>>n;
cout<<"Enter the value of x:";
cin>>x;
for(int i=1;i<=n;i++)
{
sum=sum+((pow(-x,i))/fact(i));
}
cout<<"The Sum is:"<<sum;
getch();
}
int fact(int a)
{
int f=1;
for(int j=1;j<=a;j++)
{
f=f*j;
}
return f;
}

M.S.
DIGITAL CLOCK

Quote :
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
long s,m,h,m1,m2,s1,h1,h2,day;
cout<< "Enter The Hour Minutes Seconds:" ;
cin>>h>>m>>s;
if(s>=60)
{
s1=s%60;
m1=s/60;
}
else
{
s1=s;
m1=m;
}
if(m>=60)
{
m2=m1+(m%60);
h1=h+(m2/60);
}
else
{
h1=h;
m2=m1=m;
}
if(h>=24)
{
h2=h1+(h%24);
day=h/24;
}
else
{
day=0;
h2=h1;
}
if(h2>24)
{
h2=h2%24;
}
else if(m2>60)
{
m2=m2%60;
}
else if(s1>60)
{
s1=s1%60;
}
cout<<h2<<":"<<m2<<":"<<s1<<"\n"<<"The Number of days="<<day;
getch();
}
M.S.
PASCAL'S TRIANGLE

Quote :
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int n,i,j,c;
cout<<"Enter the number of Rows:";
cin>>n;
for(i=0;i<=n;i++)
{
c=1;
for(j=0;j<=i;j++)
{
cout<<c<<" ";
c=c*(i-j)/(j+1);
}
cout<<"\n";
}
getch();
}

M.S.
FLOYDS TRIANGLE

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int i,j,n,k=1;
cout<<"Enter the number of rows:";
cin>>n;

for(i=1;i<=n;i++)
{
cout<<"\n";
for(j=1;j<=i;j++)
{
cout<<k++<<" ";
}
}
getch();
}
M.S.
DIAMOND

Quote :
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int i,j,k,n,s;
cout<<"Enter the number of Rows:";
cin>>n;
s=n-1;
for(i=1;i<=n;i++)
{

for(k=1;k<=s;k++)
{
cout<<" ";
}
--s;
for(j=1;j<=2*i-1;j++)
{
if(j==1||j==2*i-1)
cout<<" * ";
else if(j==2*n)
cout<<" * ";
else
cout<<" * ";
}
cout<<"\n";
}
int l=1;
for(int p=i;p>=0;p--)
{
for(int m=1;m<=l;m++)
{
cout<<" ";
}
l++;
for(m=1;m<=(2*(p-2)-1);m++)
{
if(m==2*(p-2)-1)
cout<<" * ";
else if(m==1)
cout<<" * ";
else
cout<<" * ";
}
cout<<"\n";
}
getch();
}

o

M.S.
AMSTRONG NO.

Quote :
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,n;
int s=0;
cout<<"Enter the No.:";
cin>>n;
int x=n;
while(n!=0)
{
a=n%10;
s+=pow(a,3);
n/=10;
}
cout<<"\n";
if(s==x)
cout<<"Its an Amstrong No.";
else
cout<<"Not an Amstrong No.";
getch();
}
Back to top Go down
View user profile http://milanstopper.fullboards.com
 
Various Useful Programs
Back to top 
Page 1 of 1
 Similar topics
-
» PV-Creating Programs
» What Programs are Used to Make 2d PVs?

Permissions in this forum:You cannot reply to topics in this forum
 :: PUBLIC :: C++ TUTORIALS-
Jump to: