--program--
Title; Even Or Odd
Programm:
Easy programming and better way to learn the programming . if you like the scorce code do like like share and subscribe the chennel.
--program--
Title; Even Or Odd
Programm:
Title:- Progam to count the occurrence of a substring in the string
Program
Title : Reverse the number
Program:
//program to calculate the rteverse tof the enterdnumber;
Title: Print statement without using semicolan(;)
Program:
Title : Natural Number Without using Loop
Program:
Title: Min max without using if else
Program:
Title :- linear Search
Program:
Decimal to binary
program:
Aim : armStrong number
Program
title: Swap using template
program:
#include<iostream>
using namespace std;
template<class T>
void swapme(T & x, T & y)
{
T temp = x;
x=y;
y=temp;
}
int main()
{
int a,b;
cout<<"Enter the two integer values : ";
cin>>a>>b;
swapme(a,b);
cout<<"After Sapping A ="<<a<<", B = "<<b<<endl;
double p,q;
cout<<"Enter the two double values :";
cin>>p>>q;
swapme(p,q);
cout<<"After the swapping : P ="<<p<<" , Q = "<<q<<endl;
return 0;
}
OUPUT
Program
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
char base[48]="1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./";
char c[100];
int i,l;
cout<<"\n\tEnter the String: ";
gets(c);
l=strlen(c);
strupr(c);
for(i=0;i<l;i++)
{
int j;
for(j=0;j<47;j++)
{
if((base[j]==c[i]) && c[i]!='q' && c[i]!='a' && c[i]!='z')
{
cout<<base[j-l];
}
else if(c[i] == ' ')
{
cout<<" ";
break;
}
}
}
return 0;
}
output
Aim:-Fibonacci series
program
#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
int main()
{
long int fibb1=0,fibb2=1,n,a,b,i,c=0;
long int sum;
cout<<"\tEnter th einput for A:";
cin>>a;
cout<<"\tEnter the input for B:";
cin>>b;
cout<<"\tA is: "<<a<<"\t B is: "<<b;
n=b;
cout<<"\n\t Fibnacci series :";
while(b>0)
{
sum=fibb1+fibb2;
if(sum>a&&sum<n)
{
c++;
cout<<"\t"<<sum;
}
fibb1=fibb2;
fibb2=sum;
b--;
}
cout<<"\n\n\tOutput Count = "<<c;
return 0;
}
Output:
Title: implementation of stack
Aim: a study of the implementation of stack
Theory:
Container – is the Type of underlying container object.
Member Types:-
value_type- The first template parameter, T. It denotes the element types.
container_type- The second template parameter, Container. It denotes the underlying container type.
size_type- Unsigned integral type.
The functions associated with stack are:
empty() – Returns whether the stack is empty – Time Complexity: O(1)
size() – Returns the size of the stack – Time Complexity: O(1)
top() – Returns a reference to the topmost element of the stack – Time Complexity: O(1)
push(g) – Adds the element ‘g’ at the top of the stack – Time Complexity: O(1)
pop() – Deletes the topmost element of the stack – Time Complexity: O(1)
Program:
#include <iostream>
#include<conio.h>
using namespace std;
int stack[100], n=100,top=-1;
void push(int val)
{
if(top >=n-1)
{
cout<<"stack is Overflow";
}
else
{
top++;
stack[top]=val;
}
}
void pop()
{
if(top <=-1)
{
cout<<"Stack is Underflow";
}
else
{
cout<<"The Popped Element is "<<stack[top];
top--;
}
}
void display()
{
if(top >=0)
{
cout<<"Stack Elements are:";
for(int i=top;i>=0;i++)
{
cout<<stack[i]<<" ";
cout<<endl;
}
}
else
{
cout<<"Stack is Empty:";
}
}
int main()
{
int ch,val;
cout<<"1) Push in Stack"<<endl;
cout<<"2) Pop in Stack"<<endl;
cout<<"3) Display Stack"<<endl;
cout<<"4) Exit"<<endl;
do{
cout<<"Enter Choice:"<<endl;
cin>>ch;
switch(ch)
{
case 1:
{
cout<<"Enter Value to be Pushed:"<<endl;
cin>>val;
push(val);
break;
}
case 2:
{
pop();
break;
}
case 3:
{
display();
break;
}
case 4:
{
cout<<"Exit"<<endl;
break;
}
default:
{
cout<<"Wrong Choice"<<endl;
}
}
}
while(ch!=4);
return 0;
}
OutPut