Sie sind auf Seite 1von 37

#include <stdio.

h>
#include <stdlib.h>
#include "1.h"
/*Function to create an empty List*/
node_ptr create(void)
{
node_ptr list=(node_ptr)malloc(sizeof(struct node));
list->data_item = 0;/*The first node*/
list->next = NULL; /*the last node*/
return list;
}
/*Function to return dynamically allocated memory in list*/
void destroy(node_ptr list)
{
node_ptr current = list;
while(current)
{
node_ptr to_free = current;
current = current -> next;
free(to_free);
}
}
/*Function to insert n at front of list*/
void insert_at_front(int n, node_ptr list)
{
node_ptr new_node= (node_ptr)malloc(sizeof(struct node));
new_node -> data_item = n;
new_node -> next = list-> next;
list -> next = new_node;
}
/*Function to print list*/
void print(node_ptr list)
{
node_ptr current = list -> next;
printf("The list is: ");
while(current)
{
printf("%d ", current->data_item);
current = current->next;
}
printf("\n");
}
/*Function to insert n in ( non decreasing ) order in list - assuming list
items are already in ( non decreasing ) order. */
void insert_in_order(int n, node_ptr list)
{
node_ptr before = list;
node_ptr new_node = (node_ptr) malloc(sizeof(struct node));
new_node-> data_item = n;
while(before-> next && (before->next->data_item < n))

{
before = before->next;
}
new_node->next = before-> next;
before->next = new_node;
}
/*Function to find the number of items in the list*/
int length(node_ptr list)
{
node_ptr current = list->next;
int r = 0;
while(current)
{
r++;
current = current->next;
}
printf("\n%d items were entered to the list", r);
return r;
}
/*Function to sum the integer values in the list*/
int sum(node_ptr list)
{
node_ptr current = list->next;
int t = 0;
while(current)
{
t = t + current->data_item;
current = current->next;
}
printf("\nSum of the items are: %d\n", t);
return t;
}
/*Function to find a specific number in the list*/
node_ptr find(int n, node_ptr list)
{
node_ptr current = list->next;
int number=0;
printf("Enter a integer to check is it in the list:");
scanf("\n%d",&number);
while(current != NULL)
{
if(current->data_item == number)
{
printf("%d is in the list\n", number);
break;
}
else
{
current = current->next;
}
}
if(current == NULL)

{
printf("%d is not in the list\n", number);
}
return current;
}
/*Function to delete a specific number from the list*/
void delete(int n, node_ptr list)
{
node_ptr tmp;
node_ptr current = list->next;
int number;
printf("Enter a number to delete it from the list:");
scanf("\n%d",&number);
while(current != NULL)
{
if(current->data_item == number)
{
tmp = current->next;
free (current);
current = tmp;
printf("The list is modified\n");
break;
}
else
{
current = current->next;
}
}
if(current == NULL )
{
printf("%d is not in the list\n", number);
}
return;
}

#include<stdio.h>
#include<conio.h>
struct node
{
int data;
struct node *link;
}*start;
void create(int);
void disp();
void addlf();
void main()
{
int ch,n,i,m,a,pos;
clrscr();
start=NULL;
do
{
printf(\n\nMENU\n\n);
printf(\n1.CREATE\n);
printf(\n2.DISPLAY\n);
printf(\n3.ADDLF\n);
printf(\n4.EXIT\n);
printf(\nENTER UR CHOICE\n);
scanf(%d,&ch);
switch(ch)
{
case 1:
printf(\n\nHOW MANY NODES U WANT TO CREATE\n);
scanf(%d,&n);
for(i=0;i<n;i++)
{
printf(\nENTER THE DATA);
scanf(%d,&m);
create(m);
}
break;
case 3 :
addlf();
break;
case 2:
disp();
break;

case 4:
exit(0);
}
}
while(ch!=7);
getch();
}
void addlf()
{
struct node *q,*tmp;
q=start;
while(q->link->link!=NULL)
{
q=q->link;
}
tmp=q->link;
q->link=NULL;
tmp->link=start;
start=tmp;
}
void create(int data)
{
struct node *q,*tmp;
tmp=(struct node *)malloc(sizeof(struct node));
tmp->data=data;
tmp->link=NULL;
if(start==NULL)
{
start=tmp;
}
else
{
q=start;
while(q->link!=NULL)
q=q->link;
q->link=tmp;
}
}
void disp()
{
struct node *q;
if(start==NULL)

{
printf(\n\nLIST IS EMPTY);
}
else
{
q=start;
while(q!=NULL)
{
printf(%d->,q->data);
q=q->link;
}
printf(NULL);
}
}
LINKLIST
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

class list
{
struct node
{
int data;
node *link;
}*p;
public:
void inslast(int);
void insbeg(int);
void insnext(int,int);

void delelement(int);
void delbeg();
void dellast();
void disp();
int seek(int);
list(){p=NULL;}
~list();
};

void list::inslast(int x)
{
node *q,*t;
if(p==NULL)
{
p=new node;
p->data=x;
p->link=NULL;
}
else
{
q=p;
while(q->link!=NULL)
q=q->link;
t=new node;
t->data=x;

t->link=NULL;
q->link=t;
}
cout<<"
Inserted successfully at the end..
";
disp();
}

void list:: insbeg(int x)


{
node *q;
q=p;
p=new node;
p->data=x;
p->link=q;
cout<<"
Inserted successfully at the begining..
";
disp();
}

void list::delelement(int x)
{

node *q,*r;
q=p;
if(q->data==x)
{
p=q->link;
delete q;
return;
}
r=q;
while(q!=NULL)
{
if(q->data==x)
{
r->link=q->link;
delete q;
return;
}
r=q;
q=q->link;
}
cout<<"
Element u entered "<<x<<" is not found..
";
}

void list:: delbeg()


{
cout<<"
The list before deletion:
";
disp();
node *q;
q=p;
if(q==NULL)
{
cout<<"
No data is present..
";
return;
}
p=q->link;
delete q;
return;
}

void list:: dellast()


{
cout<<"
The list before deletion:

";
disp();
node *q,*t;
q=p;
if(q==NULL)
{
cout<<"
There is no data in the list..
";
return;
}
if(q->link==NULL)
{
p=q->link;
delete q;
return;
}

while(q->link->link!=NULL)
q=q->link;
q->link=NULL;
return;
}

list::~list()

{
node *q;
if(p==NULL) return;
while(p!=NULL)
{
q=p->link;
delete p;
p=q;
}
}

void list::disp()
{
node *q;
q=p;
if(q==NULL)
{
cout<<"
No data is in the list..
";
return;
}
cout<<"
The items present in the list are :
";

while(q!=NULL)
{
cout<<" "<<q->data;
q=q->link;
}
}

void list :: insnext(int value,int position)


{
node *temp,*temp1;
temp=p;
if(temp1==NULL)
{
temp1= new node;
temp1->data=value;
temp1->link=NULL;
p=temp1;
return;
}
for(int i=0;((i<position)&&(temp->link!=NULL)) ;i++)
{
if(i==(position-1))
{
temp1= new node;
temp1->data= value;

temp1->link=temp->link;
temp->link=temp1;
}
temp=temp->link;
}
//cout<<"
Inserted successfully at the position.."<<position;
disp();
}

int list::seek(int value)


{
node *temp;
temp=p;
int position=0;
while(temp!=NULL)
{
if(temp->data==value)
return position+1;
else
{
temp=temp->link;
position=position+1;
}

}
cout<<"

Element "<<value<<" not found";


return 0;
}

void main()
{
list l;
int ch,v,p,ps;
do
{
clrscr();
cout<<"
Operations on List..
";
cout<<"
1.Insertion
2.Deletion
3.Display
4.Seek
5.Exit";
cout<<"

Enter ur choice:";
cin>>ch;

switch(ch)
{
case 1:
cout<<"
1.Insertion at begining
2.Insertion at the end
";
cout<<"3.Insertion after the mentioned position
";
cout<<"
Enter ur choice:";
cin>>ps;
cout<<"
Enter the value to insert:";
cin>>v;
switch(ps)
{
case 1:
l.insbeg(v);
break;
case 2:
l.inslast(v);

break;
case 3:
cout<<"
Enter the position to insert the value:";
cin>>p;
l.insnext(v,p);
break;

default:
cout<<"
The choice is invalid
";
return;
}
break;

case 2:
cout<<"
1.Delete the first element
2.Delete the last element";
cout<<"
3.Enter the element to delete from the list";
cout<<"
Enter ur choice:";
cin>>ps;

switch(ps)
{
case 1:
l.delbeg();
cout<<"
The list after deletion:
";l.disp();
break;
case 2:
l.dellast();
cout<<"
The list after deletion:
";l.disp();
break;
case 3:
l.disp();
cout<<"
Enter the element to delete :

";
cin>>v;
l.delelement(v);
cout<<"

The list after deletion:


";l.disp();
break;

default:
cout<<"
The option is invalid...
";
break;
}
break;

case 3:
l.disp();
break;

case 4:
l.disp();
cout<<"
Enter the element to search:";
cin>>v;
cout<<"
The position of the element "<< v<<" is "<<l.seek(v);
getch();
break;

case 5:
exit(1);

default:
cout<<"
The option is invalid...
";
return;
}
getch();
}while(ch!=5);
getch();
return;
}

MATRICES
# include <iostream.h>
# include
<stdlib.h>
# include
<conio.h>
/***********************************************************************///---------------------------- matrix -----------------------------///***********************************************************************/class
matrix
{
private:
int operation;
float matrix_a[3][3];
float matrix_b[3][3];
float matrix_c[3][3];
public:
matrix();
void get_matrix_a();
void get_matrix_b();
void get_operation();
void add_matrices();
void subtract_matrices();
void multiply_matrices();
void sort_matrix();
void find_element();
void transpose_matrix();
void merging_matrices();
void show_result_matrix();

};
/***********************************************************************///--------------------------- matrix() ----------------------------///***********************************************************************/
matrix::matrix()
{
textmode(BW80);
operation=1;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
matrix_a[i][j]=0;
matrix_b[i][j]=0;
matrix_c[i][j]=0;
}
}
}
/***********************************************************************///------------------------- get_matrix_a() ------------------------///***********************************************************************/void
matrix::get_matrix_a()
{
gotoxy(1,7);
cout<<" Enter the values of the matrix A row by row :\n "<<endl;
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t

"<<endl;
"<<endl;
"<<endl;
"<<endl;
"<<endl;

gotoxy(18,11);
cout<<" A = "<<endl;
int x=28;
int y=10;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
gotoxy(x,y);
cin>>matrix_a[i][j];
x+=5;
}
x=28;
y++;
}
}
/***********************************************************************///------------------------ get_matrix_b() --------------------------

///***********************************************************************/void
matrix::get_matrix_b()
{
gotoxy(1,17);
cout<<" Enter the values of the matrix B row by row :\n "<<endl;
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t

"<<endl;
"<<endl;
"<<endl;
"<<endl;
"<<endl;

gotoxy(18,21);
cout<<" B = "<<endl;
int x=28;
int y=20;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
gotoxy(x,y);
cin>>matrix_b[i][j];
x+=5;
}
x=28;
y++;
}
}
/***********************************************************************///--------------------- merging_matrices() ------------------------///***********************************************************************/void
matrix::merging_matrices()
{
float temp_matrix[3][6]={0};
gotoxy(1,12);
cout<<"\n The merging matrix_c of matrix_a & matrix_b is :\n"<<endl;
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t

gotoxy(13,17);
cout<<" ( A,B ) = "<<endl;
for(int a=0;a<3;a++)
{
for(int b=0;b<6;b++)
{
if(b<3)
temp_matrix[a][b]=matrix_a[a][b];
else
temp_matrix[a][b]=matrix_b[a][b-3];
}
}

"<<endl;
"<<endl;
"<<endl;
"<<endl;
"<<endl;

int x=28;
int y=16;
for(int i=0;i<3;i++)
{
for(int j=0;j<6;j++)
{
gotoxy(x,y);
cout<<temp_matrix[i][j];
x+=5;
}
x=28;
y++;
}
}
/***********************************************************************///--------------------- get_operation() ---------------------------///***********************************************************************/void
matrix::get_operation()
{
cout<<"\n
******************************************************************************"<<endl;
cout<<" * * * * * * Operations that can be performed on Matrices * * * * * *
* * * *"<<endl;
cout<<"
******************************************************************************"<<endl;
gotoxy(1,25);
cout<<"
******************************************************************************";
gotoxy(1,7);
cout<<" Select one of the following :\n "<<endl;
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t

1)2)3)4)5)6)7)8)9)0)-

Addition ( A + B )"<<endl;
Subtraction ( A - B )"<<endl;
Subtraction ( B - A )"<<endl;
Multiplication ( A * B )"<<endl;
Sorting ( in ascending order )"<<endl;
Sorting ( in decending order )"<<endl;
Finding an element "<<endl;
Transpose "<<endl;
Merging Metrices (A,B) "<<endl;
Exit"<<endl;

gotoxy(19,20);
cout<<"Enter your Choice = ";
do
{
gotoxy(39,20);
cin>>operation;
gotoxy(38,20);
cout<<" ";
}
while(operation<0 || operation>9);
if(operation==0)

exit(0);
clrscr();
cout<<"\n
******************************************************************************"<<endl;
cout<<" * * * * * * * * * * * * * * * Matrices * * * * * * * * * * * * * * *
* * *"<<endl;
cout<<"
******************************************************************************"<<endl;
gotoxy(1,25);
cout<<"
******************************************************************************";
switch(operation)
{
case 1 : get_matrix_a();
get_matrix_b();
break;
case 2 : get_matrix_a();
get_matrix_b();
break;
case 3 : get_matrix_a();
get_matrix_b();
break;
case 4 : get_matrix_a();
get_matrix_b();
break;
case 5 : get_matrix_a();
break;
case 6 : get_matrix_a();
break;
case 7 : get_matrix_a();
break;
case 8 : get_matrix_a();
break;
case 9 : get_matrix_a();
get_matrix_b();
break;
}
}
/***********************************************************************///--------------------- find_element() ----------------------------///***********************************************************************/void
matrix::find_element()
{
float number;
int flag=0;
int temp_array[3][3]={0};
gotoxy(1,13);

cout<<" Enter the number you want to find = ";


cin>>number;
int i=0;
int j=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(matrix_a[i][j]==number)
{
temp_array[i][j]=1;
flag=1;
}
}
}
gotoxy(5,15);
if(flag==0)
cout<<"The given number is not found"<<endl;
else
{
cout<<"The given number is at the positions : "<<endl;
int count=0;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
if(temp_array[i][j]==1)
cout<<"\t\t\t"<<++count<<")- Matrix["<<i<<"]["
<<j<<"] = "<<number<<endl;
}
}
}
}
/***********************************************************************///--------------------- transpose_matrix() ------------------------///***********************************************************************/void
matrix::transpose_matrix()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
matrix_c[j][i]=matrix_a[i][j];
}
}
/***********************************************************************///--------------------- sort_matrix() -----------------------------///***********************************************************************/void
matrix::sort_matrix()
{
if(operation==5)
//ascending
{
for(int i=0;i<3;i++)

{
for(int j=0;j<3;j++)
{
for(int k=0;k<2;k++)
{
if(matrix_a[j][k]>matrix_a[j][k+1])
{
float temp=0;
temp=matrix_a[j][k+1];
matrix_a[j][k+1]=matrix_a[j][k];
matrix_a[j][k]=temp;
}
}
}
}
}
elseif(operation==6)
//decending
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
for(int k=0;k<2;k++)
{
if(matrix_a[j][k]<matrix_a[j][k+1])
{
float temp=0;
temp=matrix_a[j][k];
matrix_a[j][k]=matrix_a[j][k+1];
matrix_a[j][k+1]=temp;
}
}
}
}
}
for(int m=0;m<3;m++)
{
for(int n=0;n<3;n++)
matrix_c[m][n]=matrix_a[m][n];
}
}
/***********************************************************************///--------------------- add_matrices() ----------------------------///***********************************************************************/void
matrix::add_matrices()
{
if(operation==1)
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
matrix_c[i][j]=matrix_a[i][j]+matrix_b[i][j];
}
}
}

/***********************************************************************///--------------------- subtract_matrices() -----------------------///***********************************************************************/void


matrix::subtract_matrices()
{
if(operation==2)
// a-b
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
matrix_c[i][j]=matrix_a[i][j]-matrix_b[i][j];
}
}
//b-aelseif(operation==3)
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
matrix_c[i][j]=matrix_b[i][j]-matrix_a[i][j];
}
}
}
/***********************************************************************///--------------------- multiply_matrices() -----------------------///***********************************************************************/void
matrix::multiply_matrices()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
floatvalue=0;
float sum=0;
for(int k=0;k<3;k++)
{
value=matrix_a[j][k]*matrix_b[k][j];
sum+=value;
}
matrix_c[i][j]=sum;
}
}
}
/***********************************************************************///--------------------- show_result_matrix() ----------------------///***********************************************************************/void
matrix::show_result_matrix()
{
cout<<"\n
******************************************************************************"<<endl;
cout<<" * * * * * * * * * * * Resulting Matrix * * * * * * * * * * * * * * *
* * * "<<endl;
cout<<"
******************************************************************************"<<endl;
if(operation==5 || operation==6 || operation==7 || operation==8)
{
gotoxy(1,6);

cout<<" The value of Matrix A are :"<<endl;


cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t

"<<endl;
"<<endl;
"<<endl;
"<<endl;
"<<endl;

}
elseif(operation!=5 || operation!=6 || operation!=7 || operation!=8)
{
gotoxy(1,6);
cout<<" The values of Matrix A and B are :"<<endl;
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t
cout<<"\t\t

"<<endl;
"<<endl;
"<<endl;
"<<endl;
"<<endl;

gotoxy(45,9);
cout<<" B = "<<endl;
}
gotoxy(10,9);
cout<<" A = "<<endl;
int x_1=20;
int y_1=8;
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
gotoxy(x_1,y_1);
cout<<matrix_a[i][j];
x_1+=5;
}
x_1=20;
y_1++;
}
if(operation!=5 && operation!=6 && operation!=7 && operation!=8)
{
int x_2=55;
int y_2=8;
for(int m=0;m<3;m++)
{
for(int n=0;n<3;n++)
{
gotoxy(x_2,y_2);
cout<<matrix_b[m][n];
x_2+=5;
}
x_2=55;

y_2++;
}
}
gotoxy(1,15);
if(operation==1)
cout<<" The Addition of matrix A and B is :\n "<<endl;
elseif(operation==2 || operation==3)
cout<<" The Subtraction of matrix A and B is :\n "<<endl;
elseif(operation==4)
cout<<" The Product of matrix A and B is :\n "<<endl;
elseif(operation==5)
cout<<" The matrix A in the ascending order is :\n"<<endl;
elseif(operation==6)
cout<<" The matrix A in the decending order is :\n"<<endl;
elseif(operation==8)
cout<<" The Transpose of matrix A is :\n"<<endl;
if(operation!=7
{
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t
cout<<"\t\t\t
}

&& operation!=9)

"<<endl;
"<<endl;
"<<endl;
"<<endl;
"<<endl;

gotoxy(13,19);
if(operation==1)
{
cout<<" A + B = "<<endl;
add_matrices( );
}
elseif(operation==2)
{
cout<<" A - B = "<<endl;
subtract_matrices( );
}
elseif(operation==3)
{
cout<<" B - A = "<<endl;
subtract_matrices( );
}
elseif(operation==4)
{
cout<<" A * B = "<<endl;
multiply_matrices( );
}
elseif(operation==5 || operation==6)
{
cout<<"Sorted A ="<<endl;
sort_matrix( );
}
elseif(operation==7)
find_element( );

elseif(operation==8)
{
cout<<" A+ ="<<endl;
transpose_matrix( );
}
elseif(operation==9)
{
cout<<" ( A,B ) = "<<endl;
merging_matrices( );
}
elseif(operation==0)
exit(0);
gotoxy(1,25);
cout<<"
******************************************************************************";
if(operation!=7 && operation!=9)
{
int x_3=28;
int y_3=18;
for(int p=0;p<3;p++)
{
for(int q=0;q<3;q++)
{
gotoxy(x_3,y_3);
cout<<matrix_c[p][q];
x_3+=5;
}
x_3=28;
y_3++;
}
}
}
main()
{
matrix obj;
do
{
clrscr( );
obj.get_operation( );
getch( );
clrscr( );
obj.show_result_matrix( );
getch( );
}
while(!0);
return 0;

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<iomanip.h>
struct rec
{char name[50];
int r_no;
int p_no;
double gpa;
int sem;
char lo_full;
char ba;
};
void main()
{rec d[10];
int a,b[10],s_no,hold1,hold2,hold3,hold5;
char hold6[50],get;
double hold4;
cout<<"Enter the total no of students : ";
cin>>s_no;
for(a=0;a<s_no;a++)
{

cout<<"
*****************************************************************
***************
";
cout<<"

Enter the Name : ";

cin>>d[a].name;
cout<<"
";

cout<<" --------------------------------------------------------------------------------";
cout<<"
|

Entering data of "<<d[a].name<<"

|";

cout<<"
--------------------------------------------------------------------------------";
cout<<"

Enter the Registration No :

";
cin>>d[a].r_no;
cout<<"

Enter the Phone No : ";

cin>>d[a].p_no;
cout<<"

Enter the Semister No : ";

cin>>d[a].sem;
cout<<"

Enter the Batch No : ";

cin>>d[a].ba;
cout<<"

Enter the G.P.A : ";

cin>>d[a].gpa;
if(d[a].sem>1)
{cout<<"May the student is with full load : ";
cin>>d[a].lo_full;
}
}
for(int p=0;p<s_no-1;p++)
for(int j=0;j<s_no-1;j++)
if(d[j].r_no>d[j+1].r_no)
{hold1=d[j].r_no;
d[j].r_no=d[j+1].r_no;
d[j+1].r_no=hold1;
hold2=d[j].p_no;
d[j].p_no=d[j+1].p_no;
d[j+1].p_no=hold2;
hold3=d[j].ba;
d[j].ba=d[j+1].ba;
d[j+1].ba=hold3;
hold4=d[j].gpa;
d[j].gpa=d[j+1].gpa;
d[j+1].gpa=hold4;

hold5=d[j].lo_full;
d[j].lo_full=d[j+1].lo_full;
d[j+1].lo_full=hold5;
for(a=0;a[d].name[50]!='

#include <stdio.h>
#include <conio.h>
#include <alloc.h>
/* structure containing a data part and link part */
struct node
{
int data ;
struct node *link ;
} ;
void append ( struct node **, int ) ;
int length ( struct node * ) ;
void main( )
{
struct node *p ;
p = NULL ; /* empty linked list */
append
append
append
append
append

(
(
(
(
(

&p,
&p,
&p,
&p,
&p,

1
2
3
4
5

)
)
)
)
)

;
;
;
;
;

clrscr( ) ;
printf ( "Length of linked list = %d", length ( p ) ) ;
}
/* adds a node at the end of a linked list */
void append ( struct node **q, int num )
{
struct node *temp ;
temp = *q ;
if ( *q == NULL )

/* if the list is empty, create first node */

{
*q = malloc ( sizeof ( struct node ) ) ;
temp = *q ;
}
else
{
/* go to last node */
while ( temp -> link != NULL )
temp = temp -> link ;

/* add node at the end */


temp -> link = malloc ( sizeof ( struct node ) ) ;
temp = temp -> link ;
}
/* assign data to the last node */
temp -> data = num ;
temp -> link = NULL ;
}
/* counts the number of nodes in a linked list */
int length ( struct node *q )
{
staticint l ;
/* if list is empty or if NULL is encountered */
if ( q == NULL )
return ( 0 ) ;
else
{
/* go to next node */
l = 1 + length ( q -> link ) ;
return ( l ) ;
}
}

#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include <process.h>
#include <iomanip.h>

void display();
//Declaration of the functions used as global type
void disppart();
void dispdes();

void dispasc();
void toppers();
void delrec();
void avgdisp();
void insert();
void modi();

int mm,m1,m2,m3,chh1;
//Declaration of the variables as global type
char mname[20];
char msem[20];

int id[20];
//declaration of the variables used as global type
char name[20][20];
char sem[20][10];
int marks1[20];
int marks2[20];
int marks3[20];
int total[20];
int avg[20];
int size,i,ch;

void main()
{
aa:
clrscr();
cout<<endl;
cout<<"

ST.XAVIER'S SCHOOL "<<endl<<endl<<endl;

int l;
//Accepting the password from the user
char ch1,pass[7];
cout<<"Please enter the password for forwarding: ";
l=0;

while (l<7)
{
ch1=getch();
cout<<"*";
pass[l]=ch1;
l++;
}
pass[l]='

Das könnte Ihnen auch gefallen