//Merging At Last of A Tabular Array
#include<iostream.h>
#include<conio.h>
int main()
{
int a[10],d[10];
float b[10],e[10];
char c[10][10],f[10][10];
int m,n,i,j;
cout<<"Enter no of elements in List 1 & List 2";
cin>>m>>n;
cout<<"Enter Roll no, Marks & Name of List 1"<<endl;
for(i=0;i<m;i++)
{
cin>>a[i]>>b[i];
cin>>c[i];
}
cout<<"Enter Roll no, Marks & Name of List 2"<<endl;
for(j=0;j<n;j++)
{
cin>>d[j]>>e[j];
cin>>f[j];
}
//merging
for(i=0;i<n;i++)
{
a[m+i]=d[i];
b[m+i]=e[i];
strcpy(c[m+i],f[i]);
}
//printing Table
cout<<"Roll No"<<"\t"<<"Marks"<<"\t"<<"Name"<<endl;
for(i=0;i<m+n;i++)
{
cout<<a[i]<<"\t"<<b[i]<<"\t";
cout<<c[i]<<endl;
}
getch();
return 0;
}
#include<iostream.h>
#include<conio.h>
int main()
{
int a[10],d[10];
float b[10],e[10];
char c[10][10],f[10][10];
int m,n,i,j;
cout<<"Enter no of elements in List 1 & List 2";
cin>>m>>n;
cout<<"Enter Roll no, Marks & Name of List 1"<<endl;
for(i=0;i<m;i++)
{
cin>>a[i]>>b[i];
cin>>c[i];
}
cout<<"Enter Roll no, Marks & Name of List 2"<<endl;
for(j=0;j<n;j++)
{
cin>>d[j]>>e[j];
cin>>f[j];
}
//merging
for(i=0;i<n;i++)
{
a[m+i]=d[i];
b[m+i]=e[i];
strcpy(c[m+i],f[i]);
}
//printing Table
cout<<"Roll No"<<"\t"<<"Marks"<<"\t"<<"Name"<<endl;
for(i=0;i<m+n;i++)
{
cout<<a[i]<<"\t"<<b[i]<<"\t";
cout<<c[i]<<endl;
}
getch();
return 0;
}
No comments:
Post a Comment