Basic Queue Example

#include<iostream>
#include<conio.h>
#define MAX 5
using namespace std;

template <class t>
class queue
{
t data[5];
int rear,front;
public:
//Default constructor
queue()
{
rear=-1;
front=0;
}
//simple queue full
int full()
{

return(rear==4);
}
//simple queue empty
int empty()
{
  //  cout<<rear;
return(rear<front);
}
//simple queue add
void addqueue(t x)
{
if(!full())
{
rear ++;
data[rear]=x;
}
else
{
cout<<"full";
}
}
int removequeue()
{
int x=0;
if(!empty())
{
x=data[front];
front++;
}  
else
{
cout<<"empty";
}
return x;
}
int count()
{
return((rear-front)+1);
}
};
int main()
{
queue<int> q1;
int ch,cnt,x;

do{
    cout<<"enter \n1.add value\n2.remove value\n3.full\n4.empty\n";

cin>>ch;
if(ch==1)
{
     cout<<"Add Value ";
     cin>>x;      
q1.addqueue(x);

}
else if(ch==3)
{
   
if(q1.full())
{
 cout<<"full";     
 }
 else
 {
     cout<<"not full";
 }
}
else if(ch==2)
{
    
cout<<"remove "<<q1.removequeue()<<endl;

}
else if(ch==4)
{
if(q1.empty())
{
 cout<<"empty";           }else
{
    cout<<"not empty";
}
}

cout<<"do you want to continue then press 5\n";
cin>>cnt;
}

 while(cnt==5);
getch();
}
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-7462577112023113"
     data-ad-slot="1814817697"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

Queue example for remove value with front fixed

#include<iostream>
#include<conio.h>
#define MAX 100
using namespace std;
class queue
{
int data[MAX];
int rear,front;

public:
//default constructor
queue()
{
rear=-1;
front=0;
}
int full()
{
return(rear==5-1);
}
int empty()
{
return(rear==-1 && front==0);
}
void addqueue(int x)
{
cout<<"rear= "<<rear<<"....front="<<front<<endl;
if(!full())
{
rear++;
data[rear]=x;
}
else
{
cout<<"full\n";
}
}

int removequeueFrontFixed()
{
int x=0;            
cout<<"front="<<front<<"....rear="<<rear<<endl;
if(!empty())
{
x=data[front];
for(int i=front;i<rear;i++)
{
data[i]=data[i+1];
}
rear--;
}
else
{
cout<<"empty\n";
}
return x;

}
int count()
{
return((rear-front)+1);
}

int removequeueRearFixed()
{
int x=0;
cout<<"rear="<<rear<<"....front="<<front<<endl;
if(!empty())
{
x=data[front];
front++;
}
else
{
cout<<"empty";
}
return x;

}
};


int main()
{
queue q1;
int ch,cnt,x;
do{
cout<<"enter\n1.add value in queue\n2.remove value with front fixed\n3.remove value with rear fixed\n4.count\n";
cin>>ch;
if(ch==1)
{
cout<<"add value\n";
for(int i=0;i<5;i++)
{
cin>>x;
q1.addqueue(x);
}
}
else if(ch==2)
{
cout<<"delete queue\n";
for(int i=0;i<5;i++)
{
cout<<q1.removequeueFrontFixed()<<endl;
}

}
else if(ch==3)
{
     cout<<"remove queue";
     for(int i=0;i<5;i++)
     {
     
cout<<q1.removequeueRearFixed()<<endl;
}
}
else if(ch==4)
{
cout<<q1.count()<<endl;
}
cout<<"do u want to continue then press 5\n";
cin>>cnt;}
while(cnt==5);

getch();
}

Queue Example in CPP

#include<iostream>
#include<conio.h>
#define MAX 100
using namespace std;
class queue
{
int data[MAX];
int rear,front,temp;

public:
//default constructor
queue()
{
rear=-1;
front=0;
}
int full()
{
return(rear==5-1);
}
int empty()
{
return(rear==-1 && front==0);
}
void addqueue(int x)
{
cout<<"rear= "<<rear<<"....front="<<front<<endl;
if(!full())
{
rear++;
data[rear]=x;
}
else
{
cout<<"full\n";
}
}
int sort()
{
//cout<<"rear="<<rear<<"front="<<front;
for(int i=front;i<rear;i++)
{
if(data[i]<data[i+1])
{
temp=data[i];
data[i]=data[i+1];
data[i+1]=temp;
}}
}
/*int sort2()
{
cout<<"rear="<<rear<<"front="<<front;
for(int i=rear;i>=front;i++)
{
if(data[i]<data[i+1])
{
temp=data[i];
data[i]=data[i+1];
data[i+1]=temp;
}}


}*/
void view()
{
  cout<<"view"<<endl;   
for(int i=0;i<5;i++ )
{
   cout<<"rear="<<rear<<"front="<<front<<endl;     
cout<<data[i]<<endl;
}
}                                                

int removequeueFrontFixed()
{
int x=0;            
cout<<"front="<<front<<"....rear="<<rear<<endl;
if(!empty())
{
x=data[front];
for(int i=front;i<rear;i++)
{
data[i]=data[i+1];
}
rear--;
}
else
{
cout<<"empty\n";
}
return x;

}
int count()
{
return((rear-front)+1);
}

int removequeueRearFixed()
{
int x=0;
cout<<"rear="<<rear<<"....front="<<front<<endl;
if(!empty())
{
x=data[front];
front++;
}
else
{
cout<<"empty";
}
return x;

}
};


int main()
{
queue q1;
int ch,cnt,x;
do{
cout<<"enter\n1.add value in queue\n2.remove value with front fixed\n3.remove value with rear fixed\n4.count\n5.sort\n";
cin>>ch;
if(ch==1)
{
cout<<"add value\n";
for(int i=0;i<5;i++)
{
cin>>x;
q1.addqueue(x);
}
}
else if(ch==2)
{
cout<<"delete queue\n";
for(int i=0;i<5;i++)
{
cout<<q1.removequeueFrontFixed()<<endl;
}

}
else if(ch==3)
{
cout<<"remove queue";
for(int i=0;i<5;i++)
{

cout<<q1.removequeueRearFixed()<<endl;
}
}
else if(ch==4)
{
cout<<q1.count()<<endl;
}
else if(ch==5)
{
for( int i=0;i<5;i++)
{
q1.sort();
}
q1.view();
}

cout<<"do u want to continue then press 6\n";
cin>>cnt;}
while(cnt==6);

getch();
}

Linked List In CPP

#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<ctype.h>
using namespace std;
class node
{
int data;
node*next;
public:
node *creatlist()
{
node*head,*tail, *temp;
int x;
head=NULL;
cout<<"Enter number(-99 to stop):";
cin>>x;
while(x!=-99)
{
temp=new node();
temp->data=x;
temp->next=NULL;
if(head==NULL)
{
head=tail=temp;
}
else
{
tail->next=temp;
tail=temp;
}
cout<<"enter value(-99 to stop)";
cin>>x;
}
return head;
}

void traverse(node*head)
{
node*p=head;
while(p!=NULL)
{
cout<<p->data<<"->";
p=p->next;
}
cout<<"\b"<<char(12)<<endl;
}

void searchnode(node*head,int srch)
{

node*p=head;
while(p!=NULL)
{

if(srch==p->data)
{

cout<<endl<<p->data<<" found\n";
{

break;
}
}
p=p->next;
}

if(p==NULL)
{
cout<<"\nnot found\n";
}

}



node *inserthead(node*head,int x)
{
node *tmp;
if(head==NULL)
{
cout<<"empty list";
}
else
{
tmp=new node();
tmp->data=x;
tmp->next=head;
head=tmp;
}
return head;
}
node *deletehead(node*head)
{
     
node*p=head;
if(head==NULL)
{
cout<<"empty list";
}
else
{
 head=p->next;
 delete(p);
 }
 return head;
}
node* inserttail(node*head,int x)
{
      node *tmp;
node*p=head;
if(head==NULL)
{
              cout<<"empty list";
              }
              else
              {
while(p->next!=NULL)
{
p=p->next;
}
tmp=new node();
tmp->data=x;
tmp->next=NULL;
p->next=tmp;
}

return head;
}
node*deletebefore(node*head,int srch)
{
node *p,*q;
p=head;
q=head->next;
while(q!=NULL)
{
if(q->next->data==srch)
{
break;
}
p=p->next; q=q->next;
}
if(q!=NULL)
{
p->next=q->next;
delete(q);
}
else
{
cout<<"Delete error";
}
return head;
}

};
int main()
{
int ch,srch,x;
char cnt;
node singly;
node*head;
do{
cout<<"1.for creatlist"<<endl<<"2.for traverse"<<endl<<"3.for search"<<endl<<"4. head insert"<<endl<<"5.delete head"<<endl<<"6.for insert tail"<<endl<<"7 for deletebefore"<<endl;
cout<<"enter your choice\n";
cin>>ch;

if(ch==1)
{
head=singly.creatlist();
}
else if(ch==2)
{
singly.traverse(head);
}
else if(ch==3)
{
cout<<"enter srch value";
cin>>srch;
singly.searchnode(head,srch);	
}
else if(ch==4)
{
cout<<"enter value for insert ";
cin>>x;
head=singly.inserthead(head,x);	
}
else if(ch==5)
{
cout<<"delete head";
head=singly.deletehead(head);

}
else if(ch==6)
{
     cout<<"insert new value for tail : ";
     cin>>x;
     head=singly.inserttail(head,x);
 }
 else if(ch==7)
 {
 cout<<"enter srch value";
 cin>>srch;

 head=singly.deletebefore(head,srch);
}
fflush(stdin);
cout<<"do you want to continue then press (y/n) : ";
cin>>cnt;
}
while(toupper(cnt)=='Y');


getch();
}

What is Linked List

List of Program of C language

  1. WAP to ADD, Sum, MUL, Divide of two numbers X, Y?
  2. WAP to enter five nos. and print sum and average?
  3. WAP to enter Principle, Rate, Time and calculate Simple Interest?
  4. WAP to enter basic and calculate hra 2% of basic, da 3%of basic and find gross salary?
  5. WAP to exchange value of two Variables of Two Values X, Y?
  6. WAP to print prime or not prime numbers?
  7. WAP to print even or odd numbers?
  8. WAP to reverse numbers?
  9. WAP of factorial numbers?
  10. WAP of Fibonacci series?
  11. WAP fine the largest numbers in array?
  12. WAP sum of two matrix?
  13. WAP Mul of two Matrix?
  14. WAP print reverse order of array?
  15. WAP of array implementation of queue?
  16. WAP array of pointer?
  17. WAP array of structure?
  18. WAP of automatic storage class?
  19. WAP of Binary Search?
  20. WAP of Bubble sort, insertion sort and selection sort?
  21. WAP of Call by value and Call by reference?
  22. WAP of stack using array?
  23. WAP of stack using linked list?
  24. WAP of Merging of two  D array?
  25. WAP of Transpose of Two D Array?
  26. WAP of recursive function?
  27. WAP of Singly linked list in C with using structure?
  28. WAP of smallest and largest number in 2 D Array?
  29. WAP of Negative and positive number ?
  30. WAP to display largest of from three inputs?
  31. WAP of Looping statement
  32. For Loop
  33. While loop
  34. Do while loop

Using these loop make a program of even and odd number, prime and not prime numbers, negative and positive numbers etc.

  • WAP of loop control statement

(a)Break

(b)continue

(c ) exit(0)

(d)goto

Using these loop control statement write a program of prime or not prime numbers and even and odd number etc.

  • WAP of Linear Search?
  • WAP of Binary search?
  • WAP of insert,search and delete in Array?
  • WAP of string create a string count the words of string and reverse the string?
  • WAP search the string?
  • WAP matrix add calculating with 2 D Array
  • Row major ording
  • Coolum Major ordering
  • WAP of file handling with file oprations

(a)Read

(b)Write

(c )append

(d)read/write

37. WAP enter two string copy one string to another string?

38. WAP to enter the string and count word and space in string?

39. WAP to convert decimal to binary number?

40. WAP to print their value in decreasing order?

41.WAP to enter string convert lower alpha to upper alpha?

42. WAP to sort the character in the string

Input-> COMPU

OUTPUT->CMOPU

43. WAP to remove space from string?

44.WAP of Sparse Matrix?

45.WAP display name, roll, marks, t.makrs, sub, hindi, eng, sci, math  using string in array?

46.WAP display name, desi, contact etc. in string?

47. WAP to compare to string equal or not?

48. WAP find the sum of prime numbers 2-100?

49. WAP to enter two numbers and swap their values

50. WAP to the enter the user want at the end it should display the count the positive, negative and zero

51.WAP to digit wise reverse

52. WAP to digit wise multiply

53 WAP to digit wise reverse and add 5 with it.

54. WAP to print count digit numbers

55. WAF create a factorial of number with return argument

56. WAF of prime and not prime numbers

57 WAF of stack

58 WAF to enter the n number print their sum of total numbers

59 WAP of deep copying and shallow coping

60 WAP array of pointer

61.WAP to show the contents of pointer an array of pointer

62. WAP of pointer with pointer

63 WAP of two point p1 and p2

 Int  i=10,j=20; compare tow pointers

64. WAP to exchange two integer values using function in pointer

65. WAP to find the sum of all element stored in array

Int *p, sum=0, I;

Int A[3]={4,5,6}

66. WAP to return largest value in pointer

67.  WAP 2D Array elements using pointer?

68. WAP of structure pointer

69. WAP of Nested Structure

70. WAP of Singly linked through structure in C

71. WAP of Doubly linked list through structure in C

72. WAP of Circular linked list through structure in C

73. WAP of implementation stack using linked list in C

74. WAP to store even values in another link list

75. WAP of recursive to display the nodes of linked list

76. WAP of stack using array and linked list.

Singly linked list in c language

#include<stdio.h>
#include<process.h>
struct node
{
	int data;
	struct node *next;
};
typedef struct node *singly;
singly createlist()
{
	int x;
	singly head,tail,tmp;
	head=NULL;
	printf("\n enter value(-99 to stop)");
	scanf("%d",&x);
	while(x!=-99)
	{
		tmp=(singly)malloc(sizeof(struct node));
		tmp->data=x;
		if(head==NULL)
		{
			head=tail=tmp;
		}
		else
		{
			tail->next=tmp;
			tail=tmp;
		}
		tail->next=NULL;
		printf("\n Enter value(-99 to stop)");
		scanf("%d", &x);
			}
			return(head);
}
void traverse(singly head)
{
	singly p=head;
	while(p!=NULL)
	{
		printf("%d --> ",p->data);
		p=p->next;
	}
}
singly inserthead(singly head,int ins)
	{
		singly tmp;
		tmp=(singly)malloc(sizeof(struct node));
		tmp->data=ins;
		if(head==NULL)
		{
			printf("\n error insert");
		}
		else
		{
			tmp->next=head;
			head=tmp;
		}
		return(head);
}
singly insertbefore(singly head, int srch,int ins)
{
	singly p=head,tmp;
	while(p!=NULL)
	{	if(p->next->data==srch)
		{
			break;
		}
		p=p->next;
	}
	if(p!=NULL)
	{
		tmp=(singly)malloc(sizeof(struct node));
	
		tmp->data=ins;
		tmp->next=p->next;
		p->next=tmp;
		
	}
	else
	{
		printf("\n error insert");
	}
	return(head);
}
singly deletetail(singly head)
{
	singly p=head,q=head->next;
	while(q->next!=NULL)
	{
		p=p->next;
		q=q->next;
	}
	p->next=NULL;
	free(q);
	return(head);
}
singly deleteafter(singly head,int srch)
{
	singly p=head,q=head->next;
	while(p->next!=NULL)
	{
		if(p->data==srch)
		{
			break;
		}
		p=p->next;q=q->next;
	}
	if(p->next==NULL)
	{
		printf("\n delete error");
	}
	else
	{
		p->next=q->next;
		free(q);
	}
	return(head);
}


int main()
{
	singly head;int ch,ins;char cnt;int srch;

	do{
		printf("\n1. create list\n2. traverse\n3. insert as head\n4. insert before\n5. Delete tail\n6. Delete after\nEnter your choice : ");
	scanf("%d",&ch);
	switch(ch){
		case 1:
	head=createlist();
		break;
		case 2:
	traverse(head);
		break;
		case 3:
		printf("\nenter value to insert : ");
		scanf("%d",&ins);
	head=inserthead(head,ins)	;
		break;
		case 4:
		printf("\n enter value to insert :");
		scanf("%d",&ins);
		printf("\n enter value to search :");
		scanf("%d",&srch);
	head=insertbefore(head,srch,ins)	;
		break;
		case 5:
	head=deletetail(head);
		break;
		case 6:
		printf("\n enter value to search");
		scanf("%d",&srch);
		head=deleteafter(head,srch) ;
		break;	
	}
	fflush(stdin);
	printf("\ndo you want to continue (y/n) : ");
	scanf("%c",&cnt);
	}while(cnt=='y');
}

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:block"
     data-ad-format="autorelaxed"
     data-ad-client="ca-pub-7462577112023113"
     data-ad-slot="1814817697"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>

open graph tags example

Open Graph tags is a protocol (i.e. a set of rules) that is used to integrate any web page into the social graph. For example, Facebook can be your social graph or social circle.

Using of Open Graph protocol, you can tell Facebook how to render your shared content to displayed on Facebook.

Open Graph Meta Tags Example

To enable your web page into a graph object, you need to use Open Graph meta tags.

Following are examples of such meta tags:

<meta property="og:title" content=""/>
<meta property="og:type" content=""/>
<meta property="og:url" content=""/>
<meta property="og:image" content=""/>
<meta property="fb:admins" content=""/>
<meta property="og:site_name" content=""/>
<meta property="og:description" content=""/>

datatable change show entries number | disable sort datatable

aLengthMenu : This parameter allows you to readily specify the entries in the length drop down menu that DataTables shows when pagination is enabled. It can be either a 1D array of options which will be used for both the displayed option and the value, or a 2D array which will use the array in the first position as the value, and the array in the second position as the displayed options (useful for language strings such as ‘All’).

$(document).ready(function() {
    $('#tbl_id').dataTable({
        "aLengthMenu": [[25, 50, 75, -1], [25, 50, 75, "All"]],
        "iDisplayLength": 25
    });
} );

iDisplayLength is now legacy. Use pageLength instead.

How to disable sort in datatable?

Note that this will disable sorting all around, so there is no need to disable it on individual columns.

$('#jTable').dataTable({ "bSort" : false } );

Sorting apply per field, is:

$('#id-of-my-table').DataTable({
    "columnDefs": [
        { "orderable": false, "targets": [0, 4, 5, 6] },
        { "orderable": true, "targets": [1, 2, 3] }
    ]
});

Table 1 to 10

12345678910
2468101214161820
36912151821242730
481216202428323640
5101520253035404550
6121824303642485460
7142128354249566370
8162432404856647280
9182736455463728190
102030405060708090100

Table 11 to 20

11121314151617181920
22242628303234363840
33363942454851545760
44485256606468727680
556065707580859095100
667278849096102108114120
77849198105112119126133140
8896104112120128136144152160
99108117126135144153162171180
110120130140150160170180190200