92
COMPUTER SCIENCE CLASS XII SCIENCE (2011-2012) 1:- WAP to read the context from a text file “student.txt”, count and display the number of alphabates presents in it. 2:- WAP take 2 string arguments and return the concatenated string. 3:- Write a menu driven program to add , delete & modify records from a file using class student with data members. Assuming the proper data types and functions. 4:- WAP to sort elements in an array with the technique depending on the user’s choice (Insertion, Bubble & Selection sort). 5:- Write a menu driven program to do operations of matrices (Addition, Subtraction, multiplication). 6:- Given an array of Pointers names[] shown below: Char *names[]={“Ajay”, “Rahul”, “Joe”, “Ali”}; Write a program to reverse the order of these names. 7:- WAP to insert or delete an element from the linked Queue dependent on the user’s choice. 8:- Write a menu driven program to insert, delete, modify an element in a linear linked list.

Computer Science Project for class 12th

  • Upload
    mohsin

  • View
    139

  • Download
    3

Embed Size (px)

DESCRIPTION

COMPUTER SCIENCE CLASS XII SCIENCE (2011-2012)1:- WAP to read the context from a text file student.txt , count and display the number of alphabates presents in it. 2:- WAP take 2 string concatenated string. arguments and return the3:- Write a menu driven program to add , delete & modify records from a file using class student with data members. Assuming the proper data types and functions. 4:- WAP to sort elements in an array with the technique depending on the user s choice (Insertion, Bubb

Citation preview

Page 1: Computer Science Project for class 12th

COMPUTER SCIENCE

CLASS XII SCIENCE

(2011-2012)

1:- WAP to read the context from a text file “student.txt”, count and display the number of alphabates presents in it.

2:- WAP take 2 string arguments and return the concatenated string.

3:- Write a menu driven program to add , delete & modify records from a file using class student with data members. Assuming the proper data types and functions.

4:- WAP to sort elements in an array with the technique depending on the user’s choice (Insertion, Bubble & Selection sort).

5:- Write a menu driven program to do operations of matrices (Addition, Subtraction, multiplication).

6:- Given an array of Pointers names[] shown below:

Char *names[]={“Ajay”, “Rahul”, “Joe”, “Ali”};

Write a program to reverse the order of these names.

7:- WAP to insert or delete an element from the linked Queue dependent on the user’s choice.

8:- Write a menu driven program to insert, delete, modify an element in a linear linked list.

9:- WAP depending upon user’s choice either push or pop an element in a stack array.

Page 2: Computer Science Project for class 12th

10:-WAP depending upon user’s choice stackpush() to isert nodes and stackpop() to delete nodes for a linked list implemented stack.

11:-WAP to search an element in an array with the techniques depending upon user’s choice (Linear search and Binary search).

12:-Write a function that passess the address of time structure and set the total time of two time variable.

13:-Write a c++ program that uses the following path:

Person(name, age)-------student(rno, grade)------ graduate student(enrollno, subject)

with the data members as possible.

14:-WAP to show the working of function overloading. Calculate interest amount.

15:-WAP to illustrate the working of function returning an object.

16:- WAP to calculate the two distance passed as reference arguments to a function.

17:-Define a class named HOUSING with the given data members:

Private members:

reg_no, name, type, cost.

Public members:

Read_data() to read an object of housing.

Display() to show details of an object.

Draw_no() to calculate the cost depending on the type of house(2 room flat, 3 room flat or 4 room flat).

18:-WAP to calculate the sum of the following series

1+x/2+x^2/4+…………………x^n/2n

Page 3: Computer Science Project for class 12th

19:-WAP to calculate the sum of the following series

1+x+x^2/2!+x^3/3!+…………………x^n/n!

20:-WAP to read and display information aboutemployees and managers.

21:-WAP with a help of functions to encode a string that is passed to it. The string should get converted into an unrecognizable form.

22:-WAP using function that takes a string and return a reversed string.

23:-WAP to illustrate the use of object pointer.

24:-WAP that invokes a function to increase the basic salary of an employee if the employee has experience of 10 or more years.

25:-WAP to search the name and address of person having age more than 30 years in the data list of person.

26:-WAP to implement searching in a file that has records maintained through structures.

27:-WAP in which function transfer() in c++, that would copy all those records which are having area code as “MUB” from phone.txt to phonebook.txt.

28:-WAP to search for a given character inside a string and print the string from the point of match showing the function with the concept of function returning pointers.

29:- WAP in c++ to print the product of each row of a 2-D integer array passed as argument of the function.

30:-WAP in c++ using a function swaparray() to swap the first row elements with the last row elements,

Page 4: Computer Science Project for class 12th

for a 2-D integer array passed as the argument of the function.

1:- WAP to read the context from a text file “student.txt”, count and display the number of alphabates presents in it.

#include<fstream.h>#include<iostream.h>#include<conio.h>#include<ctype.h>void main(){clrscr();char ch;int count = 0;ifstream object("student.txt");while(!eof());{object.get(ch);if(isalpha(ch))count = count+1;}object. close();cout<<"\n Number of alphabets in this file is :-\t";cout<<count;getch();}

Page 5: Computer Science Project for class 12th

/* Output

Example: File containsthis is my first project of computer in C++.Number of alphabets present in this file is :- 35*/

Page 6: Computer Science Project for class 12th

2:- WAP to take 2 string arguments and return the concatenated string.

#include<iostream.h>#include<string.h>#include<conio.h>void main(){clrscr();char str1[50], str2[50];cout<<"\n Enter first sentence:"<<endl;cin.getline(str1,101);cout<<"\n Enter second sentence:"<<endl;cin.getline(str2,101);cout<<"\n Now the sentence is:"<<"\n";cout.write(str1,50).write(str2,50);getch();}

Page 7: Computer Science Project for class 12th

/*

Output

Enter first sentence:my name is

Enter second sentence:muhammad mohsin

Now the sentence is:my name is muhammad mohsin

*/

Page 8: Computer Science Project for class 12th

3:- Write a menu driven program to add , delete & modify records from a file using class student with data members. Assuming the proper data types and functions.

#include<stdio.h>#include<iostream.h>#include<conio.h>class student{private:int stud_id;char stud_name[20], stud_fname[20], stud_add[50], stud_g[1];public:void read_data(){cout<<"Enter student ID number:\t";cin>>stud_id;cout<<"Enter student name: \t";gets(stud_name);cout<<"Enter student's father name:\t";gets(stud_fname);cout<<"Enter student's grade:\t ";gets(stud_g);cout<<"Enter student's address:\t";gets(stud_add);}void modify_data(){cout<<"Enter students correct name:\t";gets(stud_name);cout<<"Enter sudent's father name:\t";gets(stud_fname);cout<<"Enter student's grade:\t";cin>>stud_g;cout<<"Enter student's address:\t";gets(stud_add);}void display_data(){cout<<"\n Sudent ID No. :-\t"<<stud_id;cout<<"\n Student name:-\t"<<stud_name;cout<<"\n Father name:-\t"<<stud_fname;cout<<"\n Grade:-\t"<<stud_g;cout<<"\n Students address:-\t"<<stud_add;}

Page 9: Computer Science Project for class 12th

int getstud_id(){return stud_id;}};void main(){clrscr();student s[50];int choice, i, p, id;char ch[2];cout<<"\n What do you want to do?";cout<<"\n1. Add Data";cout<<"\n2. Modify Data";cout<<"\n3. Delete Data";cout<<"\n Enter your choice(1-3): ";cin>>choice;if(choice==1){for(i=0; i<=50; i++){s[i].read_data();s[i].display_data();}while(ch==y || ch==Y)cout<<"\n Do you want to enter more data. Enter 'y' for yes \t\t";gets(ch);}if(choice==2){cout<<"\n Enetr student's ID No. whose data to be modified:\t";cin>>id;{for(i=1; i<=50; i++)if(s[i].getstud_id()==id)s[i].modify_data();elsecout<<"\n SORRY entered ID No. did not found.";}}if(choice==3){cout<<"\n Enter student's ID No. whose data to be deleted:\t\t";cin>>id;{for(i=0; i<=50; i++)if(s[i].getstud_id()==id)p=i;elsecout<<"\n SORRY entered ID No. did not found.";

Page 10: Computer Science Project for class 12th

}for(i=0; i<=50; i++){if(i==p)cout<<"\nDetails of entered ID No. deleted. ";elses[i].display_data();}}cout<<"\n Wrong key pressed TRY again";getch();}

Page 11: Computer Science Project for class 12th

/*

Output

What do you want to do?1. Add Data2. Modify Data3. Delete DataEnter your choice(1-3): 1Enter student ID Number: 20081511Enter sudent's father name: muhammad mohsinEnter student's father name: muhammad sabirEnter student's grade: AEnter student's address: vill. sanpla bakkal,

p.o. sanpla khatri,p.st. deoband, distt.

saharanpur, u.p.

*/

Page 12: Computer Science Project for class 12th

4:- WAP to sort elements in an array with the technique depending on the user’s choice (Insertion, Bubble & Selection sort).

#include<iostream.h>#include<limits.h>#include<conio.h>#include<ctype.h>void selsort(int[], int);void bubblesort(int[], int);void inssort(int[], int);void main(){clrscr();int ar[50], n, ch;cout<<"\n How many elements do you want to create an array{max 50}: ";cin>>n;cout<<"\n enter element in the array\t";for(int i=0; i<=n; i++)cin>>ar[i];cout<<"\n Which type of sorting do you want to do?";cout<<"\n MENU";cout<<"\n1. SELECTION SORT";cout<<"\n2. BUBBLE SORT";cout<<"\n3. INSERTION SORT";cout<<"\n Enter your choice(1-3):\t";cin>>ch;cout<<"\n The sorted array is shown below";if(ch==1){selsort(ar,n);for(i=0; i<=n; i++)cout<<ar[i]<<"\t";cout<<endl;}if(ch==2){bubblesort(ar, n);for(i=0; i<=n; i++)cout<<ar[i]<<"\t";cout<<endl;}if(ch==3){inssort(ar, n);

Page 13: Computer Science Project for class 12th

for(i=1; i<=n; i++)cout<<ar[i]<<cout<<"\t";}elsecout<<"\n Wrong choice\t";}

void selsort(int ar[], int size){

int small, position, temporary;for(int i=1; i<=size; i++){

small= ar[i];for(int j=i+1; j<=i+1; j++)

{if(ar[j]<small)

{small=ar[j];position=j;

}}

temporary=ar[i];ar[i]=ar[position];ar[position]=temporary;for(j=1; j<=size; j++){

for(j=0; j<size; j++) cout<<ar[j]<<"\t";

}}

}

void bubblesort(int ar[], int size){

int temporary, ctr=0;for(int i=0; i<size; i++)

{for(int j=1; j<(size-1); j++)

{if(ar[j]>ar[j+1])

{temporary=ar[j];ar[j]=ar[j+1];ar[j+1]=temporary;

Page 14: Computer Science Project for class 12th

}}

cout<<"\n Array after isertion - "<<++ctr<<"-is:\t";

for(int k=0; k<size; k++)cout<<ar[k]<<"\t";cout<<endl;

}}

void inssort(int ar[], int size){

int temporary, j;ar[0]=INT_MIN;for(int i=1; i<=size; i++)

{temporary=ar[i];j=i-1;while(temporary<ar[j])

{ar[j+1]=ar[j];j--;

}ar[j+1]=temporary;for(int k=1; k<=size; k++)cout<<ar[k]<<"\t";cout<<endl;

}}

Page 15: Computer Science Project for class 12th

/*Output

How many elements do you want to create an array{max 50}: 5

enter element in the array 4251425436

Which type of sorting do you want to do?MENU1. SELECTION SORT2. BUBBLE SORT3. INSERTION SORTEnter your choice(1-3): 1

The sorted array is shown below4 14 25 2 54 414 2 25 54 4 14 2 25 54 414 2 25 36 4 14 2 25 36 414 2 25 36 54

*/

Page 16: Computer Science Project for class 12th

5:- Write a menu driven program to do operations of matrices (Addition, Subtraction, multiplication).

#include<iostream.h>#include<conio.h>#include<math.h>void main(){

clrscr();int a[2][2], b[2][2], c[2][2];int n, p, m, q;int ch;cout<<"\n Enter the order of first matrix.";cout<<"\nrow: ";cin>>m;cout<<"\ncolumn: ";cin>>n;cout<<"\n Enter the order of second matrix.";cout<<"\n row: ";cin>>p;cout<<"\ncolumn: ";cin>>q;cout<<"\n Enter the first matrix:\t";for(int i=1; i<=m; i++){

for(int j=1; j<=n; j++)cin>>a[i][j];

}cout<<"\n Enter the second matrix:\t";for(i=1; i<=p; i++){

for(int j=1; j<=q; j++)cin>>b[i][j];

}cout<<"\n What do you want to do with matrices?";cout<<"\nMATRIX MENU";cout<<"\n1. Add Matrices";cout<<"\n2. Subtract Matrices";cout<<"\n3. Mutiply Matrice";cout<<"\n Enter your choice(1-3): ";cin>>ch;{

if(ch==1 || ch==2){

if((m==p)&&(n==q)){

for(int i=1; 1<=m; i++)

Page 17: Computer Science Project for class 12th

{for(int j=1; j<=n; j++)if(ch==1)

c[i][j]=a[i][j]+b[i][j];elsec[i][j]=a[i][j]-b[i][j];

}cout<<"\n SORRY matrices can't be added";

}}if(ch==3){

for(int i=1; i<=m; i++)for(int j=1; j<=q; j++){

c[i][j]=0;for(int i=1; i<=p; i++)c[i][j]=a[i][j]*b[i][j];

}}

}for(int j=1; j<=q; j++)cout<<c[i][j];getch();}

Page 18: Computer Science Project for class 12th

/*Output

Enter the order of first matrix.row: 2

column: 2

Enter the order of second matrix.row: 2

column: 2

Enter the first matrix: 2468

Enter the second matrix: 4579

What do you want to do with matrices?MATRIX MENU1. Add Matrices2. Subtract Matrices3. Mutiply MatricesEnter your choice(1-3): 1 6 1113 17

*/

Page 19: Computer Science Project for class 12th

6:- Given an array of Pointers names[] shown below:

Char *names[]={“Ajay”, “Rahul”, “Joe”, “Ali”};

Write a program to reverse the order of these names.

#include<iostream.h>#include<conio.h>#include<string.h>void main(){char *names[]={"Ajay", "rahul","joe", "ali"};int len=0;cout<<"\n Original order of name is\t";for(int i=1; i<=4; i++){len= strlen(names[i]);cout.write(names[i], len).put('\n');}

for(i=4; i>=1; i--){len=strlen(names[i]);cout.write(names[i], len).put('\n');}getch();}

Page 20: Computer Science Project for class 12th

/*Output

Original orde of name isAjayrahuljoealithe reverse order of name isalijoerahulajay*/

Page 21: Computer Science Project for class 12th

7:- WAP to insert or delete an element from the linked Queue dependent on the user’s choice.

#include<iostream.h>#include<conio.h>#include<process.h>struct node {

int info;node *next; } *start, *newptr, *rear, *save, *ptr;

node *create_new_node(int);void insert(node*);void delnode();void display(node*);void main(){

clrscr();int choice;cout<<"what do you want to do?";cout<<"\ Linked List Menu ";cout<<"\n1. Insert element.";cout<<"\n2. Delete element.";cout<<"\n Enter your choice(1-2)....";cin>>choice;

if(choice==1){

start = NULL;int inf;char ch = 'y';while(ch=='y'||ch=='Y'){

clrscr();cout<<"\n Enter information for the new

node....";cin>>inf;cout<<"\n press enetr to create new

node...";getch();newptr = create_new_node(inf);if(newptr!=NULL){cout<<"\n New node created successfully.

press enter to continue...";exit(1);}else

{

Page 22: Computer Science Project for class 12th

cout<<"\n cannot create new node!!! aborting!!\n";getch();exit(1);

}cout<<"\n now iserting node..... ";cout<<"press enter to continue\n";getch();insert(newptr);cout<<"noe the list is:\n";display(start);cout<<"\n press y to enter more nodes, N to

exit...";}

}

if(choice==2){

start = rear = NULL;int inf; char ch='y';while(ch=='y'||ch=='y')

{clrscr();cout<<"Enter the information of new node";cin>>inf;newptr = create_new_node(inf);if(newptr == NULL){cout<<"cannot create new node!!! Abosrting!";getch();exit(1);}

insert(newptr);cout<<"\npress Y to enter more nodes, N to exit...;cin>>ch;}clrscr();do{

cout<<"\nthe list now is";display(start);getch();cout<<"want to delete first node?(y/n)...";cin>>ch;if(ch=='y'||ch=='Y')delnode();

} while(ch=='y'||ch=='Y');}

}

Page 23: Computer Science Project for class 12th

node *create_new_node( int n ){

ptr = new node;ptr -> info = n;ptr -> next = NULL;return ptr;

}void insert(node* np){

if(start == NULL)start = np;else{

save = start;start = np;np -> next = save;

}}void delnode(){

if(start == NULL)cout<<"underflow!!!\n";else{

ptr=start;start = start -> next;delete ptr;

}}void display(node* np){

while(np!= NULL){

cout<< np -> info <<"-> ";np= np -> next;

}cout<<"!!!\n";

}

Page 24: Computer Science Project for class 12th

/*Output

what do you want to do?LL MENU1. Insert element.2. Delete element. Enter your choice(1-2).... 1

Enter information for the new node....1

press enetr to create new node... New node created successfully. press enter to continue...

Linked List Menu1. Insert element.2. Delete element. Enter your choice(1-2).... 2

Enter the information of new node5

press Y to enter more nodes, N to exit... y

Enter the information of new node8

press Y to enter more nodes, N to exit... n

the list now is8-> 5-> !!!want to delete first node?(y/n)...y

the list now is5-> !!!want to delete first node?(y/n)...n

*/

Page 25: Computer Science Project for class 12th

8:- Write a menu driven program to insert, delete, modify an element in a linear linked list.

#include<iostream.h>#include<conio.h>#include<process.h>struct node {

int info;node *next;

} *start, *newptr, *rear, *save, *ptr;node *create_new_node(int);void insert(node*);void delnode();void modify();void display(node*);void main(){

clrscr();int a;cout<<"what do you want to do?";cout<<"\nLL MENU";cout<<"\n1. Insert element.";cout<<"\n2. Delete element.";cout<<"\n3. Modify element.";cout<<"\n Enter your choice(1-3)....";cin>>a;

if(a==1){

start = NULL;int inf;char ch = 'y';while(ch=='y'||ch=='Y'){

clrscr();cout<<"\n Enter information for the new

node....";cin>>inf;cout<<"\n press enetr to create new

node...";getch();newptr = create_new_node(inf);if(newptr!=NULL){

cout<<"\n New node created successfully. press enter to continue...";

exit(1);}

Page 26: Computer Science Project for class 12th

else{

cout<<"\n cannot create new node!!! aborting!!\n";

getch();exit(1);

}cout<<"\n now iserting node..... ";cout<<"press enter to continue\n";getch();insert(newptr);cout<<"noe the list is:\n";display(start);cout<<"\n press y to enter more nodes, N

to exit...";}

}

if(a==2){start = rear = NULL;int inf; char ch='y';while(ch=='y'||ch=='y'){clrscr();cout<<"Enter the information of new node: ";cin>>inf;newptr = create_new_node(inf);if(newptr == NULL)

{cout<<"cannot create new node!!! Abosrting!";getch();exit(1);

}insert(newptr);cout<<"\npress Y to enter more nodes, N to exit...\n";cin>>ch;

}clrscr();do{cout<<"\nthe list now is";display(start);getch();cout<<"want to delete first node?(y/n)...";cin>>ch;if(ch=='y'||ch=='Y')delnode();} while(ch=='y'||ch=='Y');}if(a==3)

Page 27: Computer Science Project for class 12th

{start = rear = NULL;int inf; char ch='y';while(ch=='y'||ch=='y'){clrscr();cout<<"enter the information of new node ";cin>>inf;cout<<"creating new node press enter to continue";getch();newptr = create_new_node(inf);if (newptr!=NULL)cout<<"node created successfully ";exit(1);}

cout<<"inserting the node";cout<<"press enter to continue";getch();{insert(newptr);cout<<"now the list is";display (start);cout<<"press y to enter more nodes";cin>>ch;}cout<<"the new list is now";modify();getch();{cout<<"wrong choice";}}}node *create_new_node( int n ){

ptr = new node;ptr -> info = n;ptr -> next = NULL;return ptr;

}void insert(node* np){

if(start == NULL)start = np;else{

save = start;start = np;np -> next = save;

}

Page 28: Computer Science Project for class 12th

}void delnode(){

if(start == NULL)cout<<"underflow!!!\n";else{

ptr=start;start = start -> next;delete ptr;

}}void modify(node* np)

{while(np!=NULL)cout<<np -> info;np = np -> next;

}void display(node* np){

while(np!= NULL){

cout<< np -> info <<"-> ";np= np -> next;

}cout<<"!!!\n";

}

Page 29: Computer Science Project for class 12th

Output

what do you want to do?LL MENU1. Insert element.2. Delete element.3. Modify element.Enter your choice(1-3).... 2

Enter the information of new node: 30 press Y to enter more nodes, N to exit... nThe list is now3 5 11 17 38Want to delete first node(y/n)...yThe list is now 5 11 17 38Want to delete first node(y/n)...n

Page 30: Computer Science Project for class 12th

9:- WAP depending upon user’s choice either push or pop an element in a stack array.

#include<iostream.h>#include<conio.h>#include<process.h>int pop(int[], int&);int push(int[], int&, int);void display(int[], int);void main(){

int stack[50], item, res, top=-1, choice;cout<<"\n ARRAY STACK MENU";cout<<"\n1. Insert.";cout<<"\n2. Delete.";cout<<"\n Enter your choice(1-2): ";cin>>choice;char ch = 'y';

if(choice==1){

clrscr();while(ch=='y'||ch=='Y'){

cout<<"\n Enter item for isertion: ";cin>>item;res=push(stack, top, item);if(res == -1){

cout<<"OVERFLOW!!! Aborting!!\n";exit(1);

}cout<<"\n The stack now is:\n";display(stack,top);cout<<"\n Want to insert more elements?(y/n)... ";cin>>ch;

}}if(choice==2){

clrscr();while(ch=='y'||ch=='Y'){

cout<<"\n Enter item for isertion: ";cin>>item;res=push(stack, top, item);if(res == -1){

Page 31: Computer Science Project for class 12th

cout<<"OVERFLOW!!! Aborting!!\n";exit(1);

}cout<<"\n The stack now is:\n";display(stack,top);cout<<"\n Want to insert more elements?(y/n)... ";cin>>ch;}

cout<<"\nNow deletion of elements begins...\n";ch='y';while(ch=='y'||ch=='Y'){

res=pop(stack,top);if(res== -1){

cout<<"\nUnderflow!!! Aborting!..\n" ;exit(1);cout<<"\nElement deleted is: "<<res<<endl;cout<<"\n The stack now is: \n";display(stack,top);

}cout<<"\nWant to delete more elements?(y/n): ";cin>>ch;

}cout<<"the stack now is\n ";display(stack, top);

}}

int push(int stack[], int& top, int ele){

if(top==50-1)return -1;else{

top++;stack[top]=ele;

}return 0;

}int pop(int stack[], int& top){

int ret;if(top== -1)return -1;else{

ret=stack[top];

Page 32: Computer Science Project for class 12th

top--;}return ret;

}

void display(int stack[], int top){

if(top== -1)return;cout<<stack[top]<<"\t"<<endl;for (int i=top-1; i>=0; i--)cout<<stack[i]<<endl;

}

/*

Page 33: Computer Science Project for class 12th

/*Output

ARRAY STACK MENU1. Insert.2. Delete. Enter your choice(1-2): 1

Enter item for isertion: 15

The stack now is:15

Want to insert more elements?(y/n)... y

Enter item for isertion: 38

The stack now is:3815

Want to insert more elements?(y/n)... y

Enter item for isertion: 42

The stack now is:423815

Want to insert more elements?(y/n)... y

Enter item for isertion: 89

The stack now is:89423815

Want to insert more elements?(y/n)... n

ARRAY STACK MENU1. Insert.2. Delete. Enter your choice(1-2): 2

Enter item for isertion: 47

Page 34: Computer Science Project for class 12th

The stack now is:47

Want to insert more elements?(y/n)... y

Enter item for isertion: 36

The stack now is:3647

Want to insert more elements?(y/n)... y

Enter item for isertion: 12

The stack now is:123647

Want to insert more elements?(y/n)... y

Enter item for isertion: 158

The stack now is:158123647

Want to insert more elements?(y/n)... n

Now deletion of elements begins...

Want to delete more elements?(y/n): nthe stack now is123647*/

Page 35: Computer Science Project for class 12th

10:-WAP depending upon user’s choice stackpush() to isert nodes and stackpop() to delete nodes for a linked list implemented stack.

#include<iostream.h>#include<conio.h>#include<process.h>struct node {

node *next; } *ptr, *save, *top, *newptr;

node *create_new_node(int);void push(node*);void pop();void display(node*);void main(){

clrscr();int m, a;char ch = 'y';top = NULL;while(ch=='y'||ch=='Y'){

cout<<"\n Enter information for the new node....";cin>>m;newptr = create_new_node(m);if(newptr == NULL){

cout<<"\n cannot create new node!!! aborting!!\n";

exit(1);}push(newptr);cout<<"press 'y' to enter more nodes...";cin>>ch;

}cout<<"\n What do you want to do?";cout<<"\nSTACK NODES MENU";cout<<"\n1. Insert element.";cout<<"\n2. Delete element.";cout<<"\n Enter your choice(1-2): ";cin>>a;if(a==1)display(top);exit(1);{

clrscr();do{

Page 36: Computer Science Project for class 12th

cout<<"\nNow the stack is";display(top);cout<<"want to delete more node?(y/n)...";cin>>ch;

}while(ch=='y'||ch=='Y');getch();

}getch();

}node *create_new_node(int n){

ptr = new node;ptr -> info = n;ptr -> next = NULL;return ptr;

}void push(node* np){

if(top == NULL)top = np;else{

save = top;top = np;np -> next = save;

}}void display(node* np){

while(np != NULL){

cout<< np -> info <<"-> ";np = np -> next;

}}

Page 37: Computer Science Project for class 12th

/*

Output

Enter information for the new node.... 5press 'y' to enter more nodes... yEnter information for the new node....8press 'y' to enter more nodes... n

What do you want to do?STACK NODES MENU1. Insert element.2. Delete element.Enter your choice(1-2): 2Now the stack is5want to delete more node?(y/n)... n

*/

Page 38: Computer Science Project for class 12th

11:-WAP to search an element in an array with the techniques depending upon user’s choice (Linear search and Binary search).

#include<iostream.h>#include<conio.h>int lsearch(int[], int, int);int bsearch(int[], int, int);void main(){

int ar[50], item, n, index, ch;cout<<"Enter desired array size(maximum 50)... ";cin>>n;cout<<"\nEnter Array elements: "<<endl;for(int i=0; i<n; i++)

cin>>ar[i];cout<<"\nWhat do you want to do;";cout<<"\nArray Search Menu.";cout<<"\n1. Linear search.";cout<<"\n2. Binary search.";cout<<"\nEnetr your choice(1-2)... ";cin>>ch;if(ch==1){

cout<<"\nEnter elements to be searched for: ";cin>>item;

index=lsearch(ar, n, item);if(index==-1)

cout<<"\nSorry!! given element could not be found.\n";

elsecout<<"\nElement found at index: "<<index<<",

position: ";cout<<(index+1);cout<<endl;

}

if(ch==2){cout<<"\nEnter elements to be searched for: ";cin>>item;index=bsearch(ar,n,item);if(index==-1)

cout<<"\nSorry!! given element could not be found.\n";

else

Page 39: Computer Science Project for class 12th

cout<<"\nElement found at index: "<<index<<", position: ";

cout<<(index+1);cout<<endl;

}elsecout<<"\wrong choice";

}int lsearch(int ar[], int size, int item){

for(int i=0; i<size; i++){

if (ar[i]==item)return i;

}return -1;

}

int bsearch(int ar[], int size, int item){

int beg, last, mid;beg=0;last=size-1;while(beg<=last){mid = (beg+last)/2;if(item == ar[mid])return mid;else if(item>ar[mid])beg = mid+1;elselast = mid - 1;}return -1;

}

Page 40: Computer Science Project for class 12th

/*Output

Enter desired array size(maximum 50)... 5

Enter Array elements:2654871354

What do you want to do;Array Search Menu.1. Linear search.2. Binary search.Enetr your choice(1-2)... 2

Enter elements to be searched for: 87

Element found at index: 2, position: 3

*/

Page 41: Computer Science Project for class 12th

12:-Write a function that passess the address of time structure and set the total time of two time variable.

#include<iostream.h>#include<conio.h>struct time

{int hr, min, sec;} t1={3,50,44}, t2={5,4,51};

time *ptr, *nptr;void main(){

clrscr();ptr=&t1;nptr=&t2;cout<<"Printin time:\t";cout<<"hour= "<<t1.hr<<" minute= "<<t1.min<<" second=

"<<t1.sec;cout<<"\nPrinting time:\t";cout<<"hour= "<<t2.hr<<" minute= "<<t2.min<<" second=

"<<t2.sec;getch();

}

Page 42: Computer Science Project for class 12th

/*

Output

Printin time: hour= 3 minute= 50 second= 44Printing time: hour= 5 minute= 4 second= 51

*/

Page 43: Computer Science Project for class 12th

13:-Write a c++ program that uses the following path:

Person(name, age)-------student(rno, grade)------ graduate student(enrollno, subject)

with the data members as possible.

#include<iostream.h>#include<conio.h>#include<stdio.h>class person

{char name[20];int age;

public:void read(){

cout<<"Enter name:\t";cin>>name;cout<<"Enter age:\t";cin>>age;

}void put(){

cout<<"\nName: "<<name;cout<<"\nAge: "<<age;

}};

class student:public person{

int rno;char g[1];

public:void read(){

person::read();cout<<"Enter roll noumber: ";cin>>rno;cout<<"Enter grade of the student: ";cin>>g;

}void put(){

person::put();cout<<"\nRoll number: "<<rno;cout<<"\nGrade: "<<g;

}};

class graduate_student:public student

Page 44: Computer Science Project for class 12th

{int eno;int sub[5];

public:void read(){

student::read();cout<<"Enter enrollment number:\t ";cin>>eno;cout<<"Subject choose by student:";cout<<"\nEnter subject code: "<<endl;for(int i=1; i<=5; i++) {

cin>>sub[i]; }

}void put(){

student::put();cout<<"\nErollment no.: "<<eno;{for(int i=1; i<=5; i++)cout<<"\nSubject code "<<(i+1)<<" :

"<<sub[i];}

}};

void main(){

clrscr();graduate_student g;g.read();g.put();getch();

}

Page 45: Computer Science Project for class 12th

/*Output

Enter name: Muhammad mohsinEnter age: 17Enter roll noumber: 325Enter grade of the student: Aenter enrollment number: 102444Subject choose by student:Enter subject code:325524625425864

Name: Muhammad mohsinAge: 10Roll number: 325Grade: AErollment no.: 102444Subject code: 325Subject code: 524Subject code: 625Subject code: 425Subject code: 864

*/

Page 46: Computer Science Project for class 12th

14:-WAP to show the working of function overloading. Calculate interest amount.

#include<iostream.h>#include<conio.h>void amount(float princ, int time, float rate){

cout<<"\nPrincipal amount: "<<princ;cout<<"\tTime: "<<time;cout<<"\tRate: "<<rate;cout<<"\nInterest Amount: "<<(princ*time*rate)<<"\n";

}void amount(float princ, int time){

cout<<"\nPrincipal amount: "<<princ;cout<<"\tTime: "<<time;cout<<"\tRate: 0.05";cout<<"\nInterest Amount: "<<(princ*time*0.08)<<"\n";

}void amount(float princ, float rate){

cout<<"\nPrincipal amount: "<<princ;cout<<"\tTime: 5 years";cout<<"\tRate: "<<rate;cout<<"\nInterest Amount: "<<(princ*5*rate)<<"\n";

}void amount(int time, float rate){

cout<<"\nPrincipal amount: 1500";cout<<"\tTime: "<<time;cout<<"\tRate: "<<rate;cout<<"\nInterest Amount: "<<(1500*time*rate)<<"\n";

}void amount(float princ){

cout<<"\nPrincipal amount: "<<princ;cout<<"\tTime: 3 years ";cout<<"\tRate: 0.12";cout<<"\nInterest Amount: "<<(princ*3*0.12)<<"\n";

}void main(){

clrscr();cout<<"Case1";

amount(1100.0);cout<<"Case2";

amount(3000.,2);cout<<"Case3";

Page 47: Computer Science Project for class 12th

amount(900,5,0.12);cout<<"Case4";

amount(8,0.5);cout<<"Case5";

amount(12,0.09);getch();

}

Page 48: Computer Science Project for class 12th

/*

Output

Case1Principal amount: 1100 Time: 3 years Rate: 0.12Interest Amount: 396Case2Principal amount: 3000 Time: 2 Rate: 0.05Interest Amount: 480Case3Principal amount: 900 Time: 5 Rate: 0.12Interest Amount: 540Case4Principal amount: 1500 Time: 8 Rate: 0.5Interest Amount: 6000Case5Principal amount: 1500 Time: 12 Rate: 0.09Interest Amount: 1620

*/

Page 49: Computer Science Project for class 12th

15:-WAP to illustrate the working of function returning an object.

#include<iostream.h>#include<conio.h>class distance

{int feet, inch;

public:void getdata(int f, int i){

feet=f; inch=i;}void printit(void){

cout<<"\n";cout<<feet<<" feet "<<inch<<"

inches"<<endl;}distance sum(distance d2);

};distance distance::sum(distance d2){distance d3;d3.feet=feet+d2.feet+(inch+d2.inch)/12;d3.inch=(inch+d2.inch)%12;return(d3);}void main(){

clrscr();distance length1, length2, total;length1.getdata(5,7);length2.getdata(5,8);total = length1.sum(length2);cout<<"\nMohsin gour's height:";length1.printit();cout<<"\nMajid Abul Rahman's height:";length2.printit();cout<<"\nSum of both height:";total.printit();getch();

}

Page 50: Computer Science Project for class 12th

/*Output

Mohsin gour's height:5 feet 7 inches

Majid Abul Rahman's height:5 feet 8 inches

Total length:11 feet 3 inches

*/

Page 51: Computer Science Project for class 12th

16:- WAP to calculate the two distance passed as reference

arguments to a function.

#include<iostream.h>#include<conio.h>class distance

{int feet, inch;

public:void getdata(int f, int i){

feet=f; inch=i;}void printit(void){

cout<<"\n";cout<<feet<<" feet "<<inch<<"

inches"<<endl;}distance sum(distance d2);

};distance distance::sum(distance d2){distance d3;d3.feet=feet+d2.feet+(inch+d2.inch)/12;d3.inch=(inch+d2.inch)%12;return(d3);}void main(){

clrscr();distance length1, length2, total;length1.getdata(5,7);length2.getdata(5,8);total = length1.sum(length2);cout<<"\nLength1 :";length1.printit();cout<<"\nLength2 :";length2.printit();cout<<"\nTotal length:\t";total.printit();getch();

}

Page 52: Computer Science Project for class 12th

/*Output

Length1 :5 feet 7 inches

Length2 :5 feet 8 inches

Total length:11 feet 3 inches

*/

Page 53: Computer Science Project for class 12th

17:-Define a class named HOUSING with the given data members.

Private members:

reg_no, name, type, cost.

Public members:

Read_data() to read an object of housing.

Display() to show details of an object.

Draw_no() to calculate the cost depending on the type of house(2 room flat, 3 room flat or 4 room flat).

#include<iostream.h>#include<conio.h>#include<stdio.h>class housing

{int reg_no,type;int cost;char name[50];

public:void readdata(){

cout<<"Enetr registration number:\t";cin>>reg_no;cout<<"Enter name fo the buyer:\t";cin>>name;cout<<"There are three types of flat.

Which one they want to purchase.";cout<<"\n1. 2 roomset flat.";cout<<"\n2. 3 roomset flat.";cout<<"\n3. 4 roomset flat.";cout<<"\nenter your choice(1-3)... ";cin>>type;

}void draw(){

if(type==1)cost=2000000;cout<<cost;if(type==2)cost=3000000;cout<<cost;if(type==3)cost=4000000;cout<<cost;

Page 54: Computer Science Project for class 12th

}void display(){

cout<<"\nRegistration Number:\t"<<reg_no;cout<<"\nName:\t"<<name;cout<<"\nYou have chosen to buy a flat of

type: "<<type;cout<<"\nCost of that flat is:"<<cost;draw();

}};

void main(){

clrscr();housing a;char ch='y';while(ch=='y'||ch=='Y'){

a.readdata();cout<<"\nDo you want to register more flats(y/n)...

";cin>>ch;

}a.display();getch();

}

Page 55: Computer Science Project for class 12th

/*Output

Enetr registration number: 101Enter name fo the buyer: muhammad mohsinThere are three types of flat. Which one they want to purchase.1. 2 roomset flat.2. 3 roomset flat.3. 4 roomset flat.enter your choice(1-3)... 3

Do you want to register more flats(y/n)... n

Registration Number: 101Name: muhammad mohsinYou have chosen to buy a flat of type: 3Cost of that flat is:4000000*/

Page 56: Computer Science Project for class 12th

18:-WAP to calculate the sum of the following series

1+x/2+x^2/4+…………………x^n/2n

#include<iostream.h>#include<conio.h>#include<math.h>void main(){

clrscr();int x=0, z=0;cout<<"enter x: ";cin>>x;cout<<"enter z: ";cin>>z;for(int i=1; i<=x; i++){

z=z+(pow(x,i))/(2*i) ;cout<<"\n Result of equation is: \t";cout<<(1+z);

}getch();

}

Page 57: Computer Science Project for class 12th

/*

Output

1+x/2+x^2/4+x^3/6…………………x^n/2n*/

Page 58: Computer Science Project for class 12th

19:-WAP to calculate the sum of the following series

1+x+x^2/2!+x^3/3!+…………………x^n/n!

#include<iostream.h>#include<conio.h>#include<math.h>void main(){

clrscr();int i, j, x=0, f=1, z=0;for(i=1; i<=x; i++){

for(j=1; j>=i; j++){

f=f*j;z=z+(pow(x,i))/f;

}cout<<"\n Result of equation is: \t";cout<<(1+z);

}getch();

}

Page 59: Computer Science Project for class 12th

/*

Output

1+x+x^2/2!+x^3/3!+x^4/4+…………………x^n/n!*/

Page 60: Computer Science Project for class 12th

20:-WAP to read and display information aboutemployees and managers.

#include<iostream.h>#include<conio.h>#include<stdio.h>class employee{private:

int eno;char name[10];char add[50];char dept[10];float sal;

public:void get_data(){

cout<<"Enter employer id number: ";cin>>eno;cout<<"Enter employer name: ";cin>>name;cout<<"Enter employer salary: ";cin>>sal;cout<<"Enter department: ";cin>>dept;cout<<"Enter employer's address: ";cin>>add;

}void read_data(){

cout<<"\nID NO.:\t"<<eno;cout<<"\nName:\t"<<name;cout<<"\nSalary:\t"<<sal;cout<<"\nDepartment:\t"<<dept;cout<<"\nAddress:\t"<<add;

}};class manager : public employee{private:

char name[10];public:

void get_data(){

cout<<"\nEnter name of manager:\t";gets(name);

Page 61: Computer Science Project for class 12th

employee::get_data();}void read_data(){

cout<<"Manager name:\t"<<name;employee::read_data();

}};void main(){

clrscr();manager m;m.get_data();cout<<"\nDetails of the employee working under

manager:"<<endl;m.read_data();getch();

}

Page 62: Computer Science Project for class 12th

/*

Output

Enter name of manager: mohsin gouriEnter employer id number: 20122Enter employer name: asadEnter employer salary: 10000Enter department: scinceEnter employer's address: jamia nagar

Details of the employee working under manager:Manager name: mohsin gouriID NO.: 20122Name: asadSalary: 10000Department: scinceAddress: jamia nagar

*/

Page 63: Computer Science Project for class 12th

21:-WAP with a help of functions to encode a string that is passed to it. The string should get converted into an unrecognizable form.

#include<iostream.h>#include<conio.h>#include<stdio.h>change(m);void main(){clrscr();long double d;char b[20];cout<<"Enter the sentence... ";gets(b);d=change(b);cout<<d;getch();}long double change(char m){for(int i=0; i<=20; i++){

int c;a[i]=char(m[i]);c=2*a[i];cout<<"the unrecognizable form is:"<<endl;cout<<c[i];

}return c;}

Page 64: Computer Science Project for class 12th

/*

Output

Enter the sentence... hi how are youthe unrecognizable form is:56413413213135634341

*/

Page 65: Computer Science Project for class 12th

22:-WAP using function that takes a string and return a reversed string.

#include<iostream.h>#include<conio.h>#include<string.h>#include<stdio.h>void main(){

clrscr();char string[50];int len, i;cout<<"Enter the sentence maximum 50 letters... ";cin.getline(string,100);len=strlen(string);for(i=len; i>=0; i--){

cout<<"\nNow the string is"<<endl;cout.write(string[i],len);

}getch();

}

Page 66: Computer Science Project for class 12th

/*

Output

Enter the sentenc maximum 50 letters... mohsin gouriNow the string isiroug nishom*/

Page 67: Computer Science Project for class 12th

23:-WAP to illustrate the use of object pointer.

#include<iostream.h>#include<conio.h>class date

{int dd,mm,yy;public:date(){ dd=mm=yy=1; }void getdata(int i, int j, int k){i=dd;j=mm;k=yy;}void putdata(void){

cout<<"\nDate is"<<endl;cout<<dd<<"/"<<mm<<"/"<<yy;

}};

void main(){clrscr();date *dp, d1;d1.getdata(12,1,2012);cout<<"\nDate:\t";d1.putdata();dp=d1;cout<<"\n Date:\t";dp->putdata();dp->getdata(13,1,2012);d1.putdata();dp->putdata();getch();}

Page 68: Computer Science Project for class 12th

/*

Output

Date: 12/1/2012

Date 13/1/2012*/

Page 69: Computer Science Project for class 12th

24:-WAP that invokes a function to increase the basic salary of an employee if the employee has

experience of 10 or more years.

#include<iostream.h>#include<conio.h>#include<stdio.h>#include<string.h>struct employee{

int emp_no;char name[15];float basic_sal;int exp;

} emp, mgr, *ptr;void display(employee *emp);void increase(employee *emp);void main(){

clrscr();cout<<"Enter employee number: ";cin>>emp.emp_no;cout<<"Enter name: ";cin>>emp.name;cout<<"Enter basic salary: ";cin>>emp.basic_sal;cout<<"Enter year of experience: ";cin>>mgr.exp;*ptr=mgr;cout<<"\n Employee details before increment in salary\n";display(ptr);increase(ptr);cout<<"\n Details of employee after increment in salary\

n";display(ptr);getch();

}void display(employee * age){int len=strlen(emp -> name);cout<<"\n Employee number: "<<emp->emp_no;cout<<"\nName: ";cout.write(age->name,len);cout<<"\nBasic salary: "<<emp->basic_sal;cout<<"\nExperience: "<<emp->exp;}void increase()

Page 70: Computer Science Project for class 12th

{if( emp-> exp > 10)emp->basic_sal +=500;

}

Page 71: Computer Science Project for class 12th

/*

OutputEnter employee number: 20081511Enter name: muhammad mohsinEnter basic salary: 10000Enter experience: 11

Employee details before increment in salaryEmployee number: 20081511Name: muhammad mohsinBasic salary: 10000Experience: 11

Details of employee after increment in salaryEmployee number: 20081511Name: muhammad mohsinBasic salary: 10500Experience: 11

*/

Page 72: Computer Science Project for class 12th

25:-WAP to search the name and address of person having age more than 30 years in the data list of person.

#include<iostream.h>#include<conio.h>#include<stdio.h>#include<string.h>struct person{

int age;char name[15];float basic_sal;char add[50];

} emp;void display(person *age);void increase(person *age);void main(){

clrscr();emp mgr *ptr ;cout<<"Enter name: ";cin>>emp.name;cout<<"Enter basic salary: ";cin>>emp.basic_sal;cout<<"Enter address: ";cin>>emp.add;cout<<"Enter age:";cin>>emp.mgr.age;ptr=mgr;cout<<"\n Person details";increase(ptr);display(ptr);getch();

}void display(person*age){{int len=strlen(emp->name);cout<<"\nName: ";cout.write(age->name,len);cout<<"\nBasic salary: "<<age->basic_sal;cout<<"\nAddress: "<<age->add;cout<<"\nAge: "<<age->age;}void increase(){

if(age->age=30)}

Page 73: Computer Science Project for class 12th

}

/*

Output

Enter age: 31Enter name: muhammad mohsinEnter basic salary: 10000Enter address: jasola jamia nagar new delhi

Person detailsAge: 31Name: muhammad mohsinBasic salary: 10000Adddress: jasola jamia nagar new delhi

*/

Page 74: Computer Science Project for class 12th

26:-WAP to implement searching in a file that has records maintained through structures.

#include<fstream.h>#include<conio.h>struct student

{int roll;char name[25];char cl[4];float marks;char grade;

} s1;void main(){

clrscr();int rn;char found='n';ifstream fin("student.dat", ios::in);cout<<"Enter roll number to be searched\t";cin>>rn;while(!eof()){

fin.read((char*)&s1, sizeof(s1));if(s1.roll==rn){

cout<<"details";cout<<s1.name<<s1.roll<<s1.marks<<s1.grade;found='y';break;

}if(found==rn)cout<<"roll no. not found in file.";fin.close();

}getch();

}

Page 75: Computer Science Project for class 12th

/*Output

Enter roll no. to be searched 325deataisMuhammad mohsin32525A

Enter roll no. to be searched 0roll no. not found in file.

*/

Page 76: Computer Science Project for class 12th

27:-WAP in which function transfer() in c++, that would copy all those records which are having area code as “MUB” from phone.txt to phonebook.txt.

#include<iostream.h>#include<conio.h>#include<fstream.h>class phonelist{

char name[30];int area_code;char add[100];int phone_no;

public:void register(){

cout<<"Enter name..\t";cin>>name;cout<<"Enter address..\t";cin>>add;cout<<"Enter area code..\t";cin>>area_code;cout<<"Enter phone number..\t";cin>>phone_no;

}void show(){

cout<<"\nName:\t"<<name;cout<<"\nAddress:\t"<<add;cout<<"\nArea code:\t"<<area_code;cout<<"\nPhone number:\t"<<phone_no;

}int checkcode(char ac[]){

return strcmp(area_code,ac);}void transfer(){

ifstrean fin;ofstream fout;phonelist ph;fin.open("phone.dat", ios::in|ios::binary)fout.open("phonebook.txt", ios::out|ios::binary)while(!fin.eof()){

fin.read((char*)&ph, sizeof(ph));if(ph.checkcode("mub")==o)

Page 77: Computer Science Project for class 12th

fout.write((char*)&ph, sizeof(ph));}fin.close();fout.close();

}};void main(){

clrscr();phonelist p;p.register();p.transfer();p.show();getch();

}

Page 78: Computer Science Project for class 12th

/*

Output

Enter name.. muhammad mohsinEnter address.. jasola jamia nagar new delhiEnter area code.. 110025Enter phone number.. 9871048306

Name: muhammad mohsinAddress: jasola jamia nagar new delhiArea code: 1100254Phone number: 9871048306

*/

Page 79: Computer Science Project for class 12th

28:-WAP to search for a given character inside a string and print the string from the point of match showing the function with the concept of function returning pointers.

#include<iostream.h>#include<conio.h>#include<string.h>char *match(char, char);void main(){

clrscr();char string[50], *cp, ch;cout<<"Enter a sentence of maximum 50 letters.\t ";cin.getline(string,50);cout<<"Enter a character to be searched.\t";cin>>ch;cp=NULL;cp = match(ch,string);if(*cp){

cout<<"\n";for(cp; cp!='\0'; cp++)cout<<cp;

}cout<<"\nno match found";getch();

}char *match(char c, char *s){

while((c!=*s)&&*s)s++;return (s);

}

Page 80: Computer Science Project for class 12th

/*Output

Enter a sentence maximum 50 letters.Hi, i am mohsin gouriEnter a character to be searched.ii am mohsin gouri

*/

Page 81: Computer Science Project for class 12th

29:- WAP in c++ to print the product of each row of a 2-D integer array passed as argument of the function.

#include<iostream.h>#include<conio.h>void rowproduct(a[][], b, c);void main(){clrscr();int m[3][4];cout<<"enter the array";for(int i=1; i<=3; i++)

{for(int j=1; j<=4; j++){

cin>>m[i][j];}

}d = rowproduct(m[][], 3, 4);cout<<"d";getch();

}void rowproduct(int a[3][4], int r, int f){

int prod[r];{

for(int i=1; i<=r; i++){

prod[i]=1;for(int j=0; j<=f; j++)prod[i]*=a[i][j];cout<<"prduct of row is";cout<<prod[i];

} }}

Page 82: Computer Science Project for class 12th

/*Output

Enter the array5 7 6 41 9 8 23 4 6 5

product of the array is

840144360

*/

Page 83: Computer Science Project for class 12th

30:-WAP in c++ using a function swaparray() to swap the first row elements with the last row elements, for a 2-D integer array passed as the argument of the function.

#include<iostream.h>#include<conio.h>void swaparr(int a);void main(){clrscr();int a,m,n, c[5][5];cout<<"enter the array";for(int i=1; i<=5; i++)

{for(int j=1; j<=5; j++)cin>>c[i][j];cout<<"the result is\n";

}a[m][n] = swaparr(c[m][n]);getch();}void swaparr(int a[5][5]){

for(int i=0; i<=o; i++){

for(int j=0; j<=p; j++)B[1][k]=a[1][n-1];A[1][n-1]=a[m-1][n-1];A[m-1][n-1]=B[1][k];cout<<a[i][j];

}}

Page 84: Computer Science Project for class 12th

/*Output

Enter the array5 7 6 41 9 8 23 4 6 5

product of the array is

840144360*/