Lab Session 4
Lab Session 4
Lab Session – 4
Date:
Pre-Lab|4:
1. Write a C program to find second largest element in an array.
Program code:
Programming Using C Lab (24IT101) Register Number:
Program code:
Programming Using C Lab (24IT101) Register Number:
Program Code:
Programming Using C Lab (24IT101) Register Number:
Program Code:
Programming Using C Lab (24IT101) Register Number:
In–Lab|4:
1. Write a C program to delete all duplicate elements from an array.
Program code:
Computer Programming Lab Register Number:
Program code:
Programming Using C Lab (24IT101) Register Number:
Program code:
Computer Programming Lab Register Number:
Program code:
Programming Using C Lab (24IT101) Register Number:
Post–Lab|4:
1. Given an array of integers nums and an integer target, return indices of the two
numbers such that they add up to target. You may assume that each input would have exactly
one solution and you may not use the same element twice. You can return the answer in any
order.
Sample Input:
Enter the size of an array: 4
Enter array elements: 2 7 11 15
Enter target: 9
Output:
[0,1]
Program code:
Programming Using C Lab (24IT101) Register Number:
2. Given a number N denoted the elements in an array. He wants to arrange the elements of an
array such that the odd positions have sorted elements in the ascending order and even
positions have sorted elements in descending order. For example, if we have 1 2 3 4 5 then the
result will be 1 5 2 4 3.
Input Format: The first line of the input contains an integer T denoting the numberof test
cases. The description of each test case is given below.
First line of each test case contains N number of elements in an array.Second line contains N
space separated integers A1, A2, ….., AN.
Output Format : Print array in desired order.
Constraints : 1 <= T <= 10; 1 <= N <= 1000000; 1 <= Ai <= 100000000
Sample Input
:2
8
3 6 9 10 12 5 15 18
1 6 8 9 11 12
Sample Output :
3 18 5 15 6 12 9 10
1 12 6 11 8 9
Program code:
Programming Using C Lab (24IT101) Register Number: