0% found this document useful (0 votes)
22 views

ID: 12229 Assignment: DSA (L) Q: No.1: Copy Arrays.: RD ND TH RD TH

The document contains two programming questions and answers. The first question involves copying elements from one array to another. The second question involves searching an array for a specific number and outputting if it is found or not.

Uploaded by

Shah Fahad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

ID: 12229 Assignment: DSA (L) Q: No.1: Copy Arrays.: RD ND TH RD TH

The document contains two programming questions and answers. The first question involves copying elements from one array to another. The second question involves searching an array for a specific number and outputting if it is found or not.

Uploaded by

Shah Fahad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ID: 12229

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:

You might also like