Posts

Showing posts from December, 2021

queue insertion deletion using array cpp c++ program

#include <iostream> using namespace std ; int queue [ 100 ], n = 100 , front = - 1 , rear = - 1 ; void Insert () {     int val ;     if ( front == - 1 )       front = 0 ;       cout << "Insert the element in queue : " << endl ;       cin >> val ;       rear ++;       queue [ rear ] = val ;     } } void Delete () {     cout << "Element deleted from queue is : " << queue [ front ] << endl ;       front ++;;     } } void Display () {     cout << "Queue elements are : " ;       for ( int i = front ; i <= rear ; i ++)       cout << queue [ i ]<< " " ;          cout << endl ;     } } int main () {     int ch ;    cout << "1) Insert element to queue" << endl ;    cout << "2) Delete element from queue" << endl ;    cout << "3) Display all the elements of queue" &l

cpp c++ programme for stack push pop implementation using linked list

#include <iostream> #include<stdlib.h> using namespace std ; struct Node {     int data ;     struct Node * next ; }; struct Node * top = NULL ; void push ( int val ) {     struct Node * newnode = ( struct Node *) malloc ( sizeof ( struct Node ));    newnode -> data = val ;    newnode -> next = top ;    top = newnode ; } void pop () {     cout << "The popped element is " << top -> data << endl ;       top = top -> next ;     } void display () {     struct Node * ptr ;     ptr = top ;       cout << "Stack elements are: " ;       while ( ptr != NULL ) {          cout << ptr -> data << " " ;          ptr = ptr -> next ;       }     }     } int main () {     int ch , val ;    cout << "1) Push in stack" << endl ;    cout << "2) Pop from stack" << endl ;    cout << "3)

stack implementation using array push pop operations in stack cpp c++ program

 #include<iostream> using namespace std; int stack[100]; int n,i,top,x; void push(); void pop(); void display(); int main() {   int ch;   cout<<"Enter the number of elements in the stack";   cin>>n;   i=1;   top=-1;   while(i)   { cout<<"Enter your choice (1-4)"<<endl;     cout<<"1.PUSH\n2.POP\n3.DISPLAY\n4.EXIT\n";     cin>>ch;     switch(ch)     {       case 1:push();              break;       case 2:pop();              break;       case 3:display();              break;       case 4:i=0;              break;       default:cout<<"Wrong Choice!!!!"<<endl;              break;     }   } return 0; } void push() {     if(top>=n-1)           // OVERFLOW i.e. if stack top goes beyond the size of the stack     {       cout<<"STACK IS OVERFLOW"<<endl;   }   else   {     cout<<"Enter the value to be added :";   cin>>x;   top=top+1;   stack[top]=x;     } } v

Linked List Implementation using C++ Program data structure cpp

Image
  #include <iostream> using namespace std; //Declare Node struct Node{     int num;     Node *next; }; //Declare starting (Head) node struct Node *head=NULL; //Insert node at start void insertNode(int n){     struct Node *newNode=new Node;     newNode->num=n;     newNode->next=head;     head=newNode; } //Traverse/ display all nodes (print items) void display(){     struct Node *temp=head;     while(temp!=NULL){         cout<<temp->num<<" ";         temp=temp->next;     }     cout<<endl; } //delete node from start void deleteItem(){     if(head==NULL){         cout<<"List is empty!"<<endl;         return;     }     cout<<head->num<<" is removed."<<endl;     head=head->next; } int main(){     display();     insertNode(1);     insertNode(2);     insertNode(3);     display();     deleteItem();     deleteItem();     deleteItem();     display();     return 0; }

select * from mysql database table using php

 <?php $servername="localhost"; $username="root"; $password=""; $dbname="shrisha"; $conn=mysqli_connect($servername, $username,$password,$dbname); $sql="SELECT * FROM tbl"; $data=mysqli_query($conn,$sql); $show=mysqli_fetch_array($data); echo $show['id'].$show['name']; ?>

delete mysql database table using php

 <?php $servername="localhost"; $username="root"; $password=""; $dbname="shrisha"; $conn=mysqli_connect($servername, $username,$password,$dbname); $sql="DELETE FROM tbl WHERE id=02"; mysqli_query($conn,$sql); mysqli_close($conn); ?>

update mysql database table using php

 <?php $servername="localhost"; $username="root"; $password=""; $dbname="shrisha"; $conn=mysqli_connect($servername, $username,$password,$dbname); $sql="UPDATE tbl SET name='Shri Ram' WHERE id=01"; mysqli_query($conn,$sql); mysqli_close($conn); ?>

insert into mysql database table using php

 <?php $servername="localhost"; $username="root"; $password=""; $dbname="shrisha"; $conn=mysqli_connect($servername, $username,$password,$dbname); $sql="INSERT INTO tbl(id,name)VALUES (02,'sham')"; mysqli_query($conn,$sql); mysqli_close($conn); ?>

create table in mysql using php

 <?php $servername="localhost"; $username="root"; $password=""; $dbname="shrisha"; $conn=mysqli_connect($servername, $username,$password,$dbname); $sql="CREATE TABLE tbl(id INT(2) PRIMARY KEY,name VARCHAR(10))"; mysqli_query($conn,$sql); mysqli_close($conn); ?>

create mysql database using php

 <?php $servername="localhost"; $username="root"; $password=""; $conn=mysqli_connect($servername,$username, $password); $sql="CREATE DATABASE shrisha"; mysqli_query($conn,$sql); mysqli_close($conn); ?>

insertion sort programm in cpp c++ data structure

 #include<iostream> using namespace std; int main() {     int i,j,n,temp,a[30];     cout<<"Enter the number of elements:";     cin>>n;     cout<<"\nEnter the elements\n";     for(i=0;i<n;i++)     {         cin>>a[i];     }     for(i=1;i<n;i++)     {         for(j=1;j<n;j++)         {             if(a[j]<a[j-1])             {                 temp=a[j-1];                 a[j-1]=a[j];                 a[j]=temp;             }         }     }     cout<<"\nSorted list is as follows\n";     for(i=0;i<n;i++)     {         cout<<a[i]<<" ";     }     return 0; }

selction sort programm in cpp

#include<iostream> using namespace std; int main() {     int i,j,n,temp,a[30];     cout<<"Enter the number of elements:";     cin>>n;     cout<<"\nEnter the elements\n";     for(i=0;i<n;i++)     {         cin>>a[i];     }     for(i=0;i<n-1;i++)     {         for(j=i+1;j<n;j++)         {             if(a[i]>a[j])             {                 temp=a[j];                 a[j]=a[i];                 a[i]=temp;             }         }     }     cout<<"\nSorted list is as follows\n";     for(i=0;i<n;i++)     {         cout<<a[i]<<" ";     }     return 0; }