Wednesday, September 23, 2009
Wednesday, September 16, 2009
KNOW ABOUT POLLUTION
Types Of Pollutions
- Air pollution
- Water pollution
- Land pollution
- Sound pollution
- Light pollution
- Radiation
CPP PROGRAMS
STACK PROGRAM
#include
#include
#include
#define size 5
int top=-1;
int item,i;
int s[size];
class stack
{
int item,i;
int s[size];
public:
void push();
void pop();
void display();
};
void stack::push()
{
if(top==size-1)
{
cout<<" stack is overflow"<
}
else
{
cout<<" enter the item to be insert---->";
cin>>item;
s[++top]=item;
}
}
void stack::pop()
{
if(top==-1)
{
cout<<" stack is underflow"<
}
else
{
cout<<"the deleted item is------------>"<
s[top--];
}
}
void stack::display()
{
if(top==-1)
{
cout<<"stack is underflow"<
}
else
{
cout<<" the stack items are------------>";
for(i=0;i<=top;i++)
cout<
}
}
void main()
{
stack p;
int ch;
clrscr();
while(1)
{
cout<<"\n 1.push\n 2.pop\n 3.display\n 4.exit\n";
cout<<" enter ur choice---------------->";
cin>>ch;
switch(ch)
{
case 1:p.push();
break;
case 2:p.pop();
break;
case 3:p.display();
break;
case 4:exit(0);
}
}
getch();
}
#include
#include
#include
#define size 5
int top=-1;
int item,i;
int s[size];
class stack
{
int item,i;
int s[size];
public:
void push();
void pop();
void display();
};
void stack::push()
{
if(top==size-1)
{
cout<<" stack is overflow"<
}
else
{
cout<<" enter the item to be insert---->";
cin>>item;
s[++top]=item;
}
}
void stack::pop()
{
if(top==-1)
{
cout<<" stack is underflow"<
}
else
{
cout<<"the deleted item is------------>"<
s[top--];
}
}
void stack::display()
{
if(top==-1)
{
cout<<"stack is underflow"<
}
else
{
cout<<" the stack items are------------>";
for(i=0;i<=top;i++)
cout<
}
}
void main()
{
stack p;
int ch;
clrscr();
while(1)
{
cout<<"\n 1.push\n 2.pop\n 3.display\n 4.exit\n";
cout<<" enter ur choice---------------->";
cin>>ch;
switch(ch)
{
case 1:p.push();
break;
case 2:p.pop();
break;
case 3:p.display();
break;
case 4:exit(0);
}
}
getch();
}
C PROGRMS
BIGGEST OF THREE NOS
main()
{
int a,b,c,big;
printf("enter three values\n");
scanf("%d%d%d",&a,&b,&c);
big=a;
if(b>big)
big=b;
if(c>big)
getch();
}
TYPE-2
main()
{
int a,b,c;
clrscr();
printf("enter three numbers\n");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
printf("the lorgest is %d \n",a);
else
if((b>a)&&(b>c))
printf("the lorgest is %d\n",b);
else
printf("the lorgest is %d",c);
getch();
}
SIMPLE INTEREST
main()
{
int p,t,r;
float si;
clrscr();
printf("enter values of p t r \n");
scanf("%d%d%d",&p,&t,&r);
si=(p*t*r)/100;
printf("simple interest is=%f\n",si);
getch();
}
SUM OF NATURAL NOS
main()
{
int n,i,sum=0;
clrscr();
printf("enter the number\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+i;
}
printf("sum of n natural number is %d",sum);
getch();
}
FIBBONACCI SERIES USING FUNCTION
main()
{
int n;
clrscr();
printf("enter the no\n");
scanf("%d",&n);
printf("fibbonacci series\n");
fibbo(n);
getch();
}
int fibbo(int n)
{
int a=0,b=1,c,i;
printf("%d\n",a);
printf("%d\n",b);
for(i=1;i<=n-2;i++)
{
c=a+b;
printf("%d\n",c);
a=b;
b=c;
}
return(c);
}
main()
{
int a,b,c,big;
printf("enter three values\n");
scanf("%d%d%d",&a,&b,&c);
big=a;
if(b>big)
big=b;
if(c>big)
big=c;
printf("the biggest of the three numbers is %d",big);getch();
}
TYPE-2
main()
{
int a,b,c;
clrscr();
printf("enter three numbers\n");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
printf("the lorgest is %d \n",a);
else
if((b>a)&&(b>c))
printf("the lorgest is %d\n",b);
else
printf("the lorgest is %d",c);
getch();
}
SIMPLE INTEREST
main()
{
int p,t,r;
float si;
clrscr();
printf("enter values of p t r \n");
scanf("%d%d%d",&p,&t,&r);
si=(p*t*r)/100;
printf("simple interest is=%f\n",si);
getch();
}
SUM OF NATURAL NOS
main()
{
int n,i,sum=0;
clrscr();
printf("enter the number\n");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
sum=sum+i;
}
printf("sum of n natural number is %d",sum);
getch();
}
FIBBONACCI SERIES USING FUNCTION
main()
{
int n;
clrscr();
printf("enter the no\n");
scanf("%d",&n);
printf("fibbonacci series\n");
fibbo(n);
getch();
}
int fibbo(int n)
{
int a=0,b=1,c,i;
printf("%d\n",a);
printf("%d\n",b);
for(i=1;i<=n-2;i++)
{
c=a+b;
printf("%d\n",c);
a=b;
b=c;
}
return(c);
}
Subscribe to:
Posts (Atom)