free geoip

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS201 Introduction to Programming Fall 2010 second assignment solution
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support
#1
[FONT=&quot]Problem Statement: Comparing two arrays for equality or matching indexes[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]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 first element of array1 should be equal to first element of array2 and so on.[/FONT]

[FONT=&quot]Example of two identical (Exactly same) arrays:[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Array1 Array2[/FONT]
[FONT=&quot]1 1[/FONT]
[FONT=&quot]2 2[/FONT]
[FONT=&quot]3 3[/FONT]
[FONT=&quot]5 5[/FONT]
[FONT=&quot]7 7[/FONT]
[FONT=&quot]9 9[/FONT]
[FONT=&quot]11 11[/FONT]
[FONT=&quot]13 13[/FONT]
[FONT=&quot]15 15[/FONT]
[FONT=&quot]17 17[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Example of two arrays with some matching elements:[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Array1 Array2[/FONT]
[FONT=&quot]1 7[/FONT]
[FONT=&quot]2 9[/FONT]
[FONT=&quot]3 3[/FONT][FONT=&quot][/FONT]
[FONT=&quot]5 4[/FONT]
[FONT=&quot]7 6[/FONT]
[FONT=&quot]9 8[/FONT]
[FONT=&quot]11 11[/FONT][FONT=&quot][/FONT]
[FONT=&quot]13 15[/FONT]
[FONT=&quot]8 8[/FONT][FONT=&quot][/FONT]
[FONT=&quot]17 17[/FONT][FONT=&quot][/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Here elements on index 3, 7, 9, and 10 of both arrays are same.[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Detailed Description:[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] The program should take 10 integer inputs from user in arrray1 and array2.[/FONT]
  • [FONT=&quot]After taking inputs in both arrays, you should pass both arrays to a function named match.[/FONT]
  • [FONT=&quot]If both arrays are exactly same, the program should display a message “Both arrays are identical”. [/FONT]
  • [FONT=&quot]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.[/FONT]
  • [FONT=&quot]If there is no element matching in both arrays, the program should display a message[/FONT]
  • [FONT=&quot]“There is no matching element in both arrays”.[/FONT]
  • [FONT=&quot]Implementation regarding comparison of arrays and displaying message should be inside the function match.[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Sample Output for two exactly same arrays[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Please enter 10 integers for array1:[/FONT]
[FONT=&quot]Enter element 1 : 1 [/FONT]
[FONT=&quot]Enter element 2 : 3 [/FONT]
[FONT=&quot]Enter element 3 : 5 [/FONT]
[FONT=&quot]Enter element 4 : 7 [/FONT]
[FONT=&quot]Enter element 5 : 9 [/FONT]
[FONT=&quot]Enter element 6 : 11 [/FONT]
[FONT=&quot]Enter element 7 : 13[/FONT]
[FONT=&quot]Enter element 8 : 15[/FONT]
[FONT=&quot]Enter element 9 : 17[/FONT]
[FONT=&quot]Enter element 10 : 19[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Please enter 10 integers for array2:[/FONT]
[FONT=&quot]Enter element 1 : 1 [/FONT]
[FONT=&quot]Enter element 2 : 3 [/FONT]
[FONT=&quot]Enter element 3 : 5 [/FONT]
[FONT=&quot]Enter element 4 : 7 [/FONT]
[FONT=&quot]Enter element 5 : 9 [/FONT]
[FONT=&quot]Enter element 6 : 11 [/FONT]
[FONT=&quot]Enter element 7 : 13[/FONT]
[FONT=&quot]Enter element 8 : 15[/FONT]
[FONT=&quot]Enter element 9 : 17[/FONT]
[FONT=&quot]Enter element 10 : 19[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Both arrays are identical[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Sample Output for arrays with some matching indexes[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Please enter 10 integers for array1:[/FONT]
[FONT=&quot]Enter element 1 : 1 [/FONT]
[FONT=&quot]Enter element 2 : 3 [/FONT]
[FONT=&quot]Enter element 3 : 5 [/FONT]
[FONT=&quot]Enter element 4 : 7 [/FONT]
[FONT=&quot]Enter element 5 : 9 [/FONT]
[FONT=&quot]Enter element 6 : 11 [/FONT]
[FONT=&quot]Enter element 7 : 13[/FONT]
[FONT=&quot]Enter element 8 : 15[/FONT]
[FONT=&quot]Enter element 9 : 17[/FONT]
[FONT=&quot]Enter element 10 : 19[/FONT]
[FONT=&quot]Please enter 10 integers for array2:[/FONT]
[FONT=&quot]Enter element 1 : 2 [/FONT]
[FONT=&quot]Enter element 2 : 4 [/FONT]
[FONT=&quot]Enter element 3 : 5 [/FONT]
[FONT=&quot]Enter element 4 : 6 [/FONT]
[FONT=&quot]Enter element 5 : 9 [/FONT]
[FONT=&quot]Enter element 6 : 12 [/FONT]
[FONT=&quot]Enter element 7 : 14[/FONT]
[FONT=&quot]Enter element 8 : 16[/FONT]
[FONT=&quot]Enter element 9 : 17[/FONT]
[FONT=&quot]Enter element 10 : 20[/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot] [/FONT]
[FONT=&quot]Both arrays have same elements on[/FONT]
[FONT=&quot]Index 3[/FONT]
[FONT=&quot]Index 5[/FONT]
[FONT=&quot]Index 9[/FONT]


Solution will be update soon.[Image: bill+gates+copy+intro+to+programming.jpg]
[FONT=&quot][/FONT][FONT=&quot][/FONT]
[FONT=&quot] [/FONT]
Reply
#2
#include<iostream.h>
#include<stdio.h>
#include<conio.h>

int main()
{

clrscr();
int IndexA[10] = {0,0,0,0,0,0,0,0,0,0};
int IndexB[10] = {0,0,0,0,0,0,0,0,0,0};

cout<<"You Are Requested To Enter Values in Arrays "<<endl;
cout<<"you should enter values between 1 & 20 "<<endl;
cout<<"Enter Value In First Array"<<endl;
for(int x=0 ; x<10 ; x++)
{
cout<<"Enter Value at - "<<x+1<<" - location - ";
cin>>IndexA[x];
if(IndexA[x] < 0 )
{
cout<<"please eneter the value between 1 & 20";
cin>>IndexA[x];
}
else if(IndexA[x] >20)
{
cout<<"please eneter the value between 1 & 20";
cin>>IndexA[x];
}
}
clrscr();
cout<<"enter Value In Second Array"<<endl;
for(x=0 ; x<10 ; x++)
{
cout<<"Enter Value at - "<<x<<" - location - ";
cin>>IndexB[x];
if(IndexB[x] < 0 )
{
cout<<"please eneter the value between 1 & 20";
cin>>IndexB[x];
}
else if(IndexB[x] >20)
{
cout<<"please eneter the value between 1 & 20";
cin>>IndexB[x];
}
}
clrscr();
cout<<"You have enter these values in Array"<<endl;
for(x =0 ; x<10 ; x++)
{
cout<<"Ist Array at - "<<x+1<<" - " <<IndexA[x]<<"| 2nd Array - " <<IndexB[x]<<endl;
}

//int IndexC[10] = {0,0,0,0,0,0,0,0,0,0};
for(x =0 ; x <10 ;x++)
{
if(IndexA[x] == IndexB[x])
{
cout<<"Values Are Same At Index - "<<x+1<<"Where Value Is = "<<IndexA[x]<<endl;
}
}

return 0;
}



Solovd By Aatish...
Reply
#3
Good job. Confusedmileys72:
Reply
#4
Xpert why it does not compile..........when i click RUN it gives message that "source file not compile"
Reply
#5
After compiling, I found 4 errors. How can I rectify them?
Reply
#6
well this should be completed by you. i just can offer help. i guess a person who is studying cs201 should remove the errors by him/her self. so i hope you will try and remove the errors and will post the correct error free code down this post.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CS301 Assignment # 4 Due Date: 02-Feb-2016 Vuhelper 0 2,358 02-03-2016, 05:38 PM
Last Post: Vuhelper
  CS703 – Advanced Operating Systems Assignment No.3 solution January 2016 Vuhelper 0 5,946 01-23-2016, 09:58 PM
Last Post: Vuhelper
  CS601 Data Communication Assignment No. 03 Solution 23rd January 2016 Vuhelper 1 1,973 01-23-2016, 06:09 PM
Last Post: Vuhelper
  CS403 Assignment No. 03 Solution 23rd January 2016 Vuhelper 2 1,217 01-23-2016, 03:18 PM
Last Post: Vuhelper
  CS506 Web Design and Development Assignment no 3 Solution 3rd January 2016 Vuhelper 0 2,282 01-23-2016, 03:16 PM
Last Post: Vuhelper
  CS724 Software Process Improvement Assignment No 01 Solution 20th January 2016 Vuhelper 0 2,014 01-20-2016, 06:26 PM
Last Post: Vuhelper
  CS711 Software Design Assignment No 01 Solution Due Date Feb 12, 2016 Vuhelper 0 1,706 01-20-2016, 06:24 PM
Last Post: Vuhelper
  CS709 Formal Methods for Software Engineering Assignment No 01 Solution January 2016 Vuhelper 0 1,842 01-20-2016, 06:22 PM
Last Post: Vuhelper
  cs703 assignment no 3 Solution 20th January 2016 Vuhelper 0 1,742 01-20-2016, 06:20 PM
Last Post: Vuhelper
  CS704 Assignment No. 01 Solution January 2016 Vuhelper 0 4,840 01-20-2016, 06:19 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)
VU Help • House Banner VU Help Virtual University Students - Assignments, Solved Papers, GDB & Exam Help Student Help Forum • Collaborative • Free Support