//concatination of two single linked list
#include
#include
#include
#include
struct linkedlist
{
int info;
struct linkedlist *next;
};
typedef struct linkedlist NODE;

NODE * create(NODE *);
void display(NODE *);
NODE * concatinate(NODE *,NODE *);
NODE *head;
NODE * node1,* node2;
NODE start;
void main()
{
clrscr();
node1=(NODE *)malloc(sizeof(NODE));
printf("\n create first linked list \n");
node1=create(node1);
printf("\n first linked list is \n");
display(node1);
printf("\n create second linked list \n");
node2=(NODE*)malloc(sizeof(NODE));
node2=create(node2);
printf("\n second linked list is \n");
display(node2);
node1=concatinate(node1,node2);
printf("\n after concatination list is \n");
display(node1);
getch();
}

NODE *create(NODE * list)
{
int a;
printf("\n enter a number to add (at end press -0)-->");
scanf("%d",&a);
if(a==-0)
{
list->info=a;
list->next=NULL;
return (list);
}
else
{
list->info= a;
list->next=(NODE *)malloc(sizeof(NODE));
create(list->next);
}
return(list);
}

void display (NODE *node)
{
printf("\n ROOT->");
while(node->next!=NULL)
{
printf("%d->",node->info);
node=node->next;
}
printf("NULL");
}

NODE *concatinate(NODE * list1, NODE * list2)
{
NODE *temp=list1;
while(list1->next->next!=NULL)
{
list1=list1->next;
}
if(list1->next->next==NULL)
{
list1->next=list2;
}
list1=temp;
return(list1);
}

//quick sorting of integers
#include
#include
void sort(int a[],int first,int last)
{
int temp,low,high,mid;
low=first;
high=last;
mid=a[(first+last)/2];
do
{
while(a[low] < mid)
low++;
while(a[high] > mid)
high--;
if(low <=high)
{
temp=a[low];
a[low]=a[high];
a[high]=temp;
low++;
high--;
}
}
while(low <= high);

if(first < high)
{
sort(a,first,high);
}
if(low < last)
{
sort( a,low,last);
}
}

void main()
{
int a[10],i,n;
printf("\n enter the size of the array -->");
scanf("%d",&n);
printf("\n enter array elements one by one \n");
for(i=0;i
#include
#include
#include
#include
struct linked_list
{
int info;
struct linked_list *next;
};
typedef struct linked_list NODE;


NODE * create (NODE *);
void display(NODE *);
int count(NODE *);
NODE *insert(NODE *,int);
NODE *search(NODE *,int);
NODE start;


NODE *create(NODE * node)
{

char ans ='y';
start.next=NULL;
node =&start;
while(ans=='y')
{
node->next=(NODE*)malloc(sizeof(NODE));
node=node->next;
printf("\n enter a number to add->");
scanf("%d",&node->info);
node->next=NULL;
printf("\n do you want to ad more node(y/n)");
scanf(" %c",&ans);
}
return(node);
}

void display (NODE *node)
{
node= &start;
node=node->next;

printf("\n ROOT->");
while(node!=NULL)
{
printf("%d->",node->info);
node=node->next;
}
printf("NULL");
}

int count(NODE *node)
{
node=&start;
int c=0;
while(node->next!=NULL)
{
c++;
node=node->next;
}
return (c);
}
NODE *insert(NODE *node,int key)
{
node=&start;
NODE *newnode,*n1;
NODE *temp=node;
if(node->info==key)
{
newnode=(NODE *)malloc(sizeof(NODE));
printf("\n enter a number to add->");
scanf("%d",&newnode->info);
newnode->next=node;
node=newnode;
return(node);
}
else
{
n1=search(node,key);
if(n1==NULL)
{
printf("\n searching node not found");
exit(0);
}

newnode=(NODE*)malloc(sizeof(NODE));
printf("\n enter a number to add->");
scanf("%d",&newnode->info);
newnode->next=n1->next;
n1->next=newnode;
return(temp);


}
}

NODE *search(NODE *node,int key)
{
node=&start;
while(node!=NULL)
{
if(node->info==key)
{
return(node);
}
node=node->next;
}
return(NULL);
}

void main()
{

NODE *head;
int key;
head=create(head);
printf("\n after creation linked list is--->\n");
display(head);
printf("\n total number of nodes=%d",count(head));
printf("\n enter a searching number where new node will be inserted-->");
scanf("%d",&key);
head=insert(head,key);
printf("\n after insertion list is=\n");
display(head);
getch();
}
A constructor plays a vital role in initializing an object. An important note, while using constructors during inheritance, is that, as long as a base class constructor does not take any arguments, the derived class need not have a constructor function. However, if a base class contains a constructor with one or more arguments, then it is mandatory for the derived class to have a constructor and pass the arguments to the base class constructor. Remember, while applying inheritance, we usually create objects using derived class. Thus, it makes sense for the derived class to pass arguments to the base class constructor. When both the derived and base class contains constructors, the base constructor is executed first and then the constructor in the derived class is executed.

In case of multiple inheritance, the base class is constructed in the same order in which they appear in the declaration of the derived class. Similarly, in a multilevel inheritance, the constructor will be executed in the order of inheritance.

The derived class takes the responsibility of supplying the initial values to its base class. The constructor of the derived class receives the entire list of required values as its argument and passes them on to the base constructor in the order in which they are declared in the derived class. A base class constructor is called and executed before executing the statements in the body of the derived class.

The header line of the derived-constructor function contains two parts separated by a colon (:). The first part provides the declaration of the arguments that are passed to the derived class constructor and the second part lists the function calls to the base class.

Example:



A(a1, a2) invokes the base constructor A() and B(b1, b2) invokes another base class constructor B(). The constructor D() supply the values i.e. a1, a2, b1, b2 (to A() and B()) and to one of its own variables d1.

Hence, the assignment of the values will be as follows:

When an object of D is created, D object-name(5, 12, 7, 8, 30);

a1 <- 5 a2 <- 12 b1 <- 7 b2 <- 8 d1 <- 30

The constructors for a virtual base class are invoked before any non-virtual base classes. If there are multiple virtual base classes, then they are invoked in the order in which they are declared.
TYPES OF DERIVATION IN INHERITANCE USING C++
hi every one which follow dis link
void DeleteList(struct node** headRef)
{
struct node* current = *headRef; // deref headRef to get the real head
struct node* next;
while (current != NULL)
{
next = current->next; // note the next pointer
free(current); // delete the node
current = next; // advance to the next node
}
*headRef = NULL; // Again, deref headRef to affect the real head back
// in the caller.
}
int Count(struct node* head, int searchFor) {
struct node* current = head;
int count = 0;
while (current != NULL) {
if (current->data == searchFor) count++;
current = current->next;
{
return count;
}

#include
#include
#include
struct linkedlist
{
int data;
struct linkedlist *next;
};
typedef struct linkedlist node;
void main()
{
int count=0;
node *head,*ptr,*new1;
char ch;
clrscr();
head=(node *)malloc(sizeof(node));
ptr=head;
do
{
printf("\nEnter the data\n");
scanf("%d",&ptr->data);
count++;
printf("Do you want to continue(y/n):");
ch=getch();
if(ch=='y')
{
clrscr();
ptr->next=(node *)malloc(sizeof(node));
ptr->next=new1;
ptr=ptr->next;
}
else
ptr->next=NULL;
}
while(ch!='n');

printf("\nno of nodes inthe list %d",count);
getch();
}


#include
#include
#include
struct linkedlist
{
int data;
struct linkedlist *next;
};
typedef struct linkedlist node;
void main()
{
node *head,*ptr,*new1;
char ch;
int large;
clrscr();
head=(node *)malloc(sizeof(node));
ptr=head;
do
{
printf("\nEnter the data \n");
scanf("%d",&ptr->data);
printf("\nDo you want to continue(y/n):");
ch=getch();
if(ch=='y')
{
clrscr();
ptr->next=(node *)malloc(sizeof(node));
ptr->next=new1;
ptr=ptr->next;
}
else
ptr->next=NULL;
}
while(ch!='n');
ptr=head;
large=ptr->data;
// printf("\nLinklist elements are:\n");
while(ptr!=NULL)
{
ptr=ptr->next;
if(ptr->data>large)
large=ptr->data;
}
printf("\nLargest Number in linked list= %d\t",large);
getch();
}
#include
#include
char x;
int pin, repeat, menu;
int withdraw, deposit, transfer, amount;
main()


{ clrscr();
gotoxy(20,1);printf(":--------------------------------------:\n");
gotoxy(20,2);printf(": Welcome to ATM Banking System:\n");
gotoxy(20,3);printf(": Created by:\n");
gotoxy(20,4);printf(": ivan john Navasca:\n");
gotoxy(20,5);printf(": :\n");
gotoxy(20,6);printf(": Enter your PIN -->:\n");
gotoxy(20,7);printf(":--------------------------------------:\n");
gotoxy(40,6);
scanf(" %d",&pin);
if (pin==1234)
{printf("access granted");}
else
{exit();}
Loop:


{clrscr();
printf(":-------------------------------------------:\n");
printf(": Choose your Transaction :\n");
printf("::\n");
printf(": 1 Inquiry Balance :\n");
printf(": 2 Withdraw:\n");
printf(": 3 Deposit :\n");
printf(": 4 Transfer Fund:\n");
printf(": 5 Exit:\n");
printf(": -->:\n");
printf(":-------------------------------------------:\n");
gotoxy(6,9);
scanf(" %d",&menu);
printf("\n\n");
switch(menu)


{
case 1:{printf("Your balance %d\n\n",amount);
printf("Another transaction? y or n?: ");
scanf(" %c",&x);
if((x == 'y')||(x== 'Y'))


{
goto Loop;
}
else if((x =='n')||(x== 'N'))


{
printf("\nThank You for Banking");
getch();
exit();
}
break;}
case 2:{if(amount==0)
{printf("You have an Isuficient Fund\nPress Enter");
getch();
goto Loop;
}
else

{
printf("Your Balance %d\n\n",amount);
printf("Enter Amount to Withdraw: ");
scanf("%d",&withdraw);
amount = amount - withdraw;
printf("\nYour Current Balance %d\n\n",amount);
printf("Another Transaction? y or n : ");
scanf(" %c",&x);
if((x =='y')||(x=='Y'))


{
goto Loop;
}
else if ((x =='n')||(x=='N'))


{
printf("\nThank You for Banking");
getch();
exit();
} }
break;}
case 3:{printf("Your Balance %d\n",amount);
printf("\nEnter Amount to Deposit: ");
scanf("%d",&deposit);
amount= amount + deposit;
printf("\nYour Current Balance %d\n",amount);
printf("Another Transaction? y or n: ");
scanf(" %c",&x);
if ((x =='y')||(x=='Y'))


{
goto Loop;
}
else if ((x =='n')||(x=='N'))


{
printf("\n\nThank You for Banking");
getch();
exit();
}
break;}
case 4:{printf("Your Balance %d\n",amount);
printf("\nEnter Amount to Transfer: ");
scanf(" %d",&transfer);
amount = amount - transfer;
printf("\nYour Current Balance %d",amount);
printf("\n\nAnother Transaction? y or n: ");
scanf(" %c",&x);
if ((x =='y')||(x=='Y'))


{
goto Loop;
}
else if ((x =='n')||(x=='N'))


{
printf("Thank You for Banking");
getch();
exit();
}
break;}
case 5:{printf("You Want to Exit? y or n: ");
scanf(" %c",&x);
if ((x=='y')||(x=='Y'))


{
printf("\n\nThank You & Come Again");
getch();
exit();
}
else if ((x =='n')||(x=='N'))


{
goto Loop;
}
break;}
default:
exit();
}
}

while(repeat);
getch();
}
#include

main ()
{
int number, last_digit, first_digit, total;
printf ("Enter the number which is to be Work out: ");

scanf ("%d", &number);


last_digit = number % 10;

total = last_digit;

first_digit = (number / 1000) % 10;

total = total + first_digit;

printf ("The total of the first and the last digit of the entered number is: %d", total);

}

CSS Menu Samples