ID: 12229 Assignment: DSA (L) Q: No.1: Copy Arrays.: RD ND TH RD TH
ID: 12229 Assignment: DSA (L) Q: No.1: Copy Arrays.: RD ND TH RD TH
Assignment: DSA(L)
Note: Used Visual Studio Code for Writing the Code.
Q: No.1:
Copy Arrays.
Ans:
Description:
i. Declared 4 arrays of size 11.
ii. Then assign the custom values to first and second array provided
through for loop asking for user input.
iii. Then used a single loop for copying the first array to 3 rd and 2nd
array to 4th.
iv. Then displayed the both the arrays 3rd and 4th using for loop.
Source Code:
Output:
Q: No.2:
Search in Arrays.
Ans:
Description:
i. Declared an array and initialized it with the custom number
provided.
ii. Then declared a int variable, that has to be found in the array.
iii. Then declared a bool variable and initialized it as false.
iv. Then asked for the user input for that specific number.
v. Then used a for loop for traversing through array up to end.
vi. And used if condition for comparing that specific number with
each element of array.
vii. If the condition held true the specific output will be displayed on
the screen and the bool variable will assigned the value true
viii. Then outside the loop used another if statement, if the bool
variable is still false then that specific out will be displayed incase
if number is not found.
Source Code:
Output: