### C++ Prog Difficulties urgent issue

Kindly tell the errors in the following program.I will be very grateful

Exams are nearing.
Here diificulties foloowed by pragrams are given.
I will be grateful for solving the problem.

Difficulties::

9.Merging in Array
To produce 3rd Array by merging array in ascending order
12 Errors in line no 7,26 45(Value or parameter never used)

10.Sum of Matrices
Find sum of 2 Matrix
No Error

11.Transpose of a matrix
To find Transpose of a matrix
No Error

12.Linked List-Insertion and deletion
Insert and delete a node in Link List
10 Errors

13.Pushing and popping as array
Enter an element in an array stack and show Pushing and popping of elements
Error in line 79

14. Multilevel Inheritance
Enter the details of students and display the details using multi level inheritance
Error in line 14

Program No.9:
#include<iostream.h>
#include<conio.h>
#include<process.h>
void merge(int A[],int M,int B[],int N[],int C[])
{
int a,b,c;
for(a=0,b=-1,c=0;a<M,b>=0)
{
if(A[a]<=B[b])
C[c++]=A[a++];
else
C[c++]=B[b--];
}
if(a<M)
{
while(a<N)
C[c++]=A[a++];
}
else
{
while(b>=0)
C[c++]=B[b--];
}
}
void main()
{
int A[50],B[50],C[50],MN=0,M,N;
cout<<"How many elements do not want to create 1st array?....";
cin>>M;
cout<<"\nEnter 1st array 1st elements[ascending]...\n";
for(int i=0;i<M;i++)
cin>>A[i];
MN=M+N;
cout<<"Enter 2nd ar ray's element descending....\n";
for(i=0;i<N;i++)
cin>>B[i];
merge(int A[],int M[],int B[],int N[],int C[]);
cout<<"\n\nThe merged array is as shown below...\n";
for(i=0;i<MN;i++)
cout<<C[i]<<" ";
cout<<endl;
getch();
}

Program No.10:
#include<iostream.h>
#include<process.h>
int main()
{
int a[10][10],b[10][10],c[10][10],i,j,m,n,p,q;
cout<<"\nInput row and column of matrix-A\n";
cin>>m>>n;
cout<<"\nInput row and column of matrix-B\n";
cin>>p>>q;
if((m==p)&&(n==q))
cout<<"Matrices can be added\n";
else
{
cout<<"Matrices cannot be added\n";
exit(0);
}
cout<<"\nInput matrix-A\n";
for(i=0;i<m;i++)
{
for(i=0;j<n;j++)
cin>>a[i][j];
}
cout<<"\nInput matrix-B\n";
for(i=0;i<p;i++)
{
for(j=0;j<p;j++)
cin>>b[i][j];
}
for(j=0;j<p;j++)
{
c[i][j]=a[i][j]+b[i][j];
}
cout<<"\n";
for(j=0;j<n;j++)
{
cout<<" "<<c[i][j];
}
return 0;
}

Program No.11:
#include<iostream.h>
#include<stdlib.h>
int main()
{
system("c\s");
int a[3][3],b[3][3],j,i;
cout<<"\nEnter the elements of a matrix\n";
for(i=0;j<3;i++)
for(j=0;j<3;j++)
cout<<"\nThe given matrix is";
for(i=0;i<3;i++)
{
cout<<"\n";
for(j=0;j<3;j++)
cout<<a[i][j]<<" ";
}
cout<<"\nTranspose of a given matrix is";
for(j=0;j<3;j++)
{
cout<<"\n";
for(j=0;j<3;j++)
{
b[i][j]=a[j][i];
cout<<b[i][j]<<" ";
}
}
return 0;
}

Program No.12:
#include<iostream.h>
#include<conio.h>
#include<process.h>
struct node
{
float data;
node*next;
}*newnode,*temp,*start,*rear;
node*create_new_node(int);
void insert_beg(node*);
void display_node(node*);
void del_node();
int main()
{
clrscr();
if(start==NULL);
char ch,ch1='Y';
int info;
do
{
clrscr();
cout<<"DELETION";
cout<<"\n1. Insert a node\n2. Delete a node";
cout<<"\n3. Display the list\n4. Exit";
cin>>ch;
switch(ch)
{
case '1':cout<<"Enter INFO to be inserted";
cin>>info;
new node=create_new_node(info);
cout<<"Node Created";
Insert_beg(new node);
cout<<"Info inserted";
getch();
break;
case'2':clrscr();
cout<<"Deleting 1st node";
del_node();
getch();
break;
case'3':clrscr();
display_node(start);
getch();
break;
case'4':exit(0);
default:cout<<"Wrong choice";
getch();
exit(0);
}
}
while(ch1=='Y');
getch();
return 0;
}
node*create_new_node(int info)
{
node= new node;
node*data=info;
node next=NULL;
return node;
}
void insert_beg(node*np)
{
if(start==NULL)
start=rear=np;
else
{
rear->next=np;
rear=np;
}
}
void display_node(node*np)
{
while(np==NULL)
{
cout<<np->data<<" ";
np=np->next;
node=start;
start=start->next;
delete start;
}
}

Program No.13:
#include<iostream.h>
#include<conio.h>
#include<process.h>
int push(int[],int&,int);
int pop(int[],int&);
void display(int[],int);
const int size=50;
int main()
{
clrscr();
int stack[size],elem,top=-1,res;
char ch='Y';
while(ch=='Y'||ch=='y')
{
clrscr();
cout<<"pushing and popping in an array";
cout<<"Enter element";
cin>>elem;
res=push(stack,top,elem);
if(res==-1)
{
cout<<"overflow";
getch();
exit(0);
}
cout<<"The stack is";
display(stack,top);
cout<<"Want to enter more(Y/N)";
cin>>ch;
}
cout<<"Popping of element";
do
{
clrscr();
cout<<"The stack is";
display(stack,top);
cout<<"Want to delete elements(Y/N)";
cin>>ch;
if(ch=='Y'||ch=='y')
{
res=pop(stack,top);
if(res==-1)
{
cout<<"Underflow";
getch();
exit(0);
}
else
{
cout<<"Element deleted is"<<res;
cout<<"stack is";
display(stack,top);
}
}
}while(ch=='Y'||ch=='y');
cout<<"Press any key to exit";
getch();
return(0);
}
int push(int stack[],int& top,int elem)
{
if(top==size-1)
return -1;
else
{
++top;
stack[top]=elem;
}
return 1;
}

struct student
{
int rno;
char name[20];
float mark;
}s[5];
int main()
{
clrscr();
cout<<"Enter the r no\nEnter the name\nEnterthe mark";
for(int i=1;i<=5;i++)
{
cin>>s[i].rno>>s[i].name>>s[i].mark;
}
cout<<"The no is\nThe name is\nThe mark is";
for(i=1;i<=5;i++)
{
cout<<s[i].rno<<s[i].name<<s[i].mark;
}
return(0);
}

Program No.14:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class Person
{
char name[20];
int age;
public:
void getinfo()
{
cout<<"\nEnter name";
gets(name);
cout<<"\nEnter the age";
cin>>age;
}
void displayinfo()
{
cout<<"\nName";
puts(name);
cout<<"\nage";
cout<<age;
}
};
class student:Public
{
int regno;
protected:
int m1,m2,m3;
public:
void getinfo2()
{
void getinfo();
cout<<"Enter register no";
cin>>regno;
cout<<"Enter the marks";
cin>>m1>>m2>>m3;
}
void displayinfo2()
{
void displayinfo();
cout<<regno;
cout<<m1<<m2<<m3;
}
};
{
float s;
char gr[10];
int m1,m2,m3;
public:
void getinfo()
{
void getinfo2();
}
void displayinfo3()
{
void displayinfo2();
s=(m1+m2+m3)/3;
if(s>=80)
strcpy(gr,"A");
else if(s>=70)
strcpy(gr,"B");
else if(s>=60)
strcpy(gr,"C");
else if(s>=40)
strcpy(gr,"D");
else
strcpy(gr,"Failed");
}
};
void main()
{
clrscr();
int i;
cout<<"Enter the details of the student\n";
for(i=0;i<3;++i)
{
cout<<"Enter the details of students"<<(i+1);
u[i].getinfo3();
}
cout<<"\nThe details of the student are\n";
for(i=0;i<3;++i)
{
cout<<"The details of the student"<<(i+1);
u[i].displayinfo3();
}
getch();
}

program 9:
 ``12345`` ``````for(int i=0;i>A[i]; MN=M+N; cout<<"Enter 2nd ar ray's element descending....\n"; for(i=0;i

Set M and N to a value before trying to use them

Program 10:
 ``12`` ``````for(i=0;j>a[i][j];``````

Same thing, j is not set to a value before you try accessing it.

Before I go ahead and actually find all these errors, you should just go ahead and make sure all other codes have their variables set to zero or any appropriate number before trying to use them.

After you do this, put each code in ["code"]["/code"] format then paste them here for further analysis if needed
Topic archived. No new replies allowed.