Pages

Sunday, May 1, 2011

CS201 Assignment No. 2 solution


Assignment No. 02

Semester: Spring 2011

CS201: Introduction to Programming

Total Marks: 20
Due Date:02/05/2011

Assignment:


Problem Statement: Sorting two matrices  

You are required to write a program which takes two 3x3 matrix A and B containing 09 elements each and sort all these 18 elements in descending order and put it in one dimensional array and then display it.

Follow the following steps to code this program
1. Take two two-dimensional arrays as A[3][3]and B[3][3] and  one-dimensional array C[] to keep the result.
2. Prompt the user to enter the elements of first matrix
3. Prompt the user to enter the elements of second matrix

1. Now take first element of first matrix and check in both matrix weather it is greatest or any other number is the greatest and put the greatest number at the first index of the one dimensional array. Follow this procedure for other elements and at the end one dimensional array would be in descending order

2. Display this one-Dimensional sorted array on the screen










Following is the sample program structure


   2 3 5               2 8 7
A= 6 5 9             B= 0 1 1
   1 0 2                4 7 9


Output should be like this

Please enter the Elements of First Matrix:

Please enter the Elements of second Matrix:

 Sorted Values from Both the Matrices are:             
    -------------------------------------------
     9 9 8 7 7 6 5 5 4 3 2 2 2 1 1 1 0 0

    ------------------------------------------
::::::::::::::::::::::::::::::::
Solution:
::::::::::::::::::::::::::::::::


#include
#include
main()
{
int ary1[3][3],ary2[3][3],ary[18],index,temp,max;
cout<<"Please enter the Elements of First Matrix: ";
for(int n=0;n<3;n++)
{
for(int m=0;m<3;m++)
{
cin>>ary1[n][m];
}
}
cout<<"Please enter the Elements of second Matrix: ";
for(int n=0;n<3;n++)
{
for(int m=0;m<3;m++)
{
cin>>ary2[n][m];
}
}
//Copying first array into single dimenional array
index=0;
for(int n=0;n<3;n++)
{
for(int m=0;m<3;m++)
{
ary[index]=ary1[n][m];
index++;
}
}
//Copying second array into single dimenional array
index=9;
for(int n=0;n<3;n++)
{
for(int m=0;m<3;m++)
{
ary[index]=ary2[n][m];
index++;
}
}
// Here sorting the third array in which ary1 and ary2 are copped....
// This sorting method is bubble sorting method in decending order.



for(int n=0;n<18;n++)
{
for(int m=n;m<18;m++)
{
if(ary[n]
{
temp=ary[n];
ary[n]=ary[m];
ary[m]=temp;
}
}
}
//Show arranged array in decending order
cout<<"Sorted Values from Both the Matrices are: "<
for(int n=0;n<18;n++)
{
cout<
}
getch();
}


::::::::::::::
Another
::::::::::::::



#include
#include
main()
{
int ary1[3][3],ary2[3][3],ary[18],index,temp,max;
cout<<"Please enter the Elements of First Matrix: ";
for(int n=0;n<3;n++)
{
for(int m=0;m<3;m++)
{
cin>>ary1[n][m];
}
}
cout<<"Please enter the Elements of second Matrix: ";
for(int n=0;n<3;n++)
{
for(int m=0;m<3;m++)
{
cin>>ary2[n][m];
}
}
//Copying first array into single dimenional array
index=0;
for(int n=0;n<3;n++)
{
for(int m=0;m<3;m++)
{
ary[index]=ary1[n][m];
index++;
}
}
//Copying second array into single dimenional array
index=9;
for(int n=0;n<3;n++)
{
for(int m=0;m<3;m++)
{
ary[index]=ary2[n][m];
index++;
}
}
// Here sorting the third array in which ary1 and ary2 are copped....
// This sorting method is bubble sorting method in decending order.
for(int n=0;n<18;n++)
{
for(int m=n;m<18;m++)
{
if(ary[n]
{
temp=ary[n];
ary[n]=ary[m];
ary[m]=temp;
}
}
}
//Show arranged array in decending order
cout<<"Sorted Values from Both the Matrices are: "<
for(int n=0;n<18;n++)
{

cout<
}
getch();
}

Mth401 Assignment No. 2 solution


ASSIGNMENT 02(MTH401)
(Differential Equation)
Maximum Marks: 30

Due Date: May 02, 2011


Please read the following instructions before attempting to solve this assignment
In order to attempt this assignment you should have full command on Lecture # 08 to Lecture # 14

Try to get the concepts, consolidate your concepts and ideas from these questions which you learn in Lecture # 08 to Lecture # 14.

You should concern recommended books for clarify your concepts as handouts are not sufficient.

Try to make solution by yourself and protect your work from other students. If we found the solution files of some students are same then we will reward zero marks to all those students.

You are supposed to submit your assignment in Word format any other formats like scan images, PDF format etc will not be accepted and we will give zero marks to these assignments.

Assignments through e-mail are not acceptable after due date (If there is any problem in submitting your assignment through LMS, you can send your solution file through email with in due date). You are advised to upload your assignment at least two days before Due date.


Q 1: Solve the given differential equation by using an appropriate substitution.


Q 2: Find the orthogonal trajectory of the following family of curves.

Q 3: Show that the given functions are linearly independent on the indicated interval.


Solution:



here are orthogonal trajactories of above DE


Is this blog is useful for you?

Powered by Blogger.