Cs201 Assignment Solution
Cs201 Assignment Solution
com/
Best Website TO Help VU Students
Assignment No. 2 Total Marks: 20
Semester: Fall 2010
CS201: Introduction to Programming Due Date: 22nd
November, 2010
Instructions:
Please read the following instructions carefully before submitting your
assignment:
It should be clear that your assignment will not get any credit if:
Note: You have to upload only .cpp file. Assignment in any other format
(extension) will not be accepted. If you will submit code any other file
format like .doc or .txt etc. you will get zero marks.
Objective
The objective of this assignment is to provide hands on experience of using
Guidelines
Code should be properly aligned and well commented.
Follow C/C++ rules while writing variables names, function names
etc.
Use only Dev-C++ IDE for this assignment.
Assignment
You are required to write a program which will take input from user in two
integer arrays. The program should compare both arrays for checking if both
arrays are totally identical (Exactly same). If not, then program should
determine the matching indexes of both arrays. Matching indexes means that
http://vujannat.ning.com/
Best Website TO Help VU Students
http://vujannat.ning.com/
Best Website TO Help VU Students
first element of array1 should be equal to first element of array2 and so
on.
Array1 Array2
1 1
2 2
3 3
5 5
7 7
9 9
11 11
13 13
15 15
17 17
Array1 Array2
1 7
2 9
3 3
5 4
7 6
9 8
11 11
13 15
8 8
17 17
Detailed Description:
The program should take 10 integer inputs from user in arrray1 and array2.
• After taking inputs in both arrays, you should pass both arrays to a
function named match.
• If both arrays are exactly same, the program should display a message
“Both arrays are identical”.
http://vujannat.ning.com/
Best Website TO Help VU Students
http://vujannat.ning.com/
Best Website TO Help VU Students
• If both arrays are not exactly same, then program should match the
indexes which have same elements in both arrays and display the
matching indexes.
• If there is no element matching in both arrays, the program should
display a message
“There is no matching element in both arrays”.
• Implementation regarding comparison of arrays and displaying message
should be inside the function match.
http://vujannat.ning.com/
Best Website TO Help VU Students
http://vujannat.ning.com/
Best Website TO Help VU Students
Enter element 4 : 7
Enter element 5 : 9
Enter element 6 : 11
Enter element 7 : 13
Enter element 8 : 15
Enter element 9 : 17
Enter element 10 : 19
Deadline:
Your Assignment solution must be submitted on or before November 22, 2010.
Solution::
#include <iostream>
http://vujannat.ning.com/
Best Website TO Help VU Students
http://vujannat.ning.com/
Best Website TO Help VU Students
using namespace std;
voidmain()
while (i<=10)
startwhile:
cin>>grade;
http://vujannat.ning.com/
Best Website TO Help VU Students
http://vujannat.ning.com/
Best Website TO Help VU Students
if (grade=='A')
Acounter=Acounter+1;
else if (grade!='B')
goto startwhile;
i=i+1;
if (Acounter<=2)
http://vujannat.ning.com/
Best Website TO Help VU Students
http://vujannat.ning.com/
Best Website TO Help VU Students
{
else if (Acounter<=7)
else if (Acounter<=8)
coutendlendl;
} //bye bye
http://vujannat.ning.com/
Best Website TO Help VU Students
http://vujannat.ning.com/
Best Website TO Help VU Students
http://vujannat.ning.com/
Best Website TO Help VU Students