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

5 Array

Uploaded by

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

5 Array

Uploaded by

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

Array:-

---------------------------------------------------------------------------------------------------------------

1) Write a C program to input 10 numbers through the keyboard into an array and
display the results of addition of even numbers and product of odd numbers.

2) Write a C program to input 10 numbers through the keyboard into an array and find the
biggest and smallest number in an Unsorted array without using any Sorting Technique.

3) Write a C program to input 10 numbers through the keyboard and find the number
of prime numbers count, store them into a separate array and display it.

4) Write a C program to find out second largest and second smallest elements of an
unsorted array without using any Sorting Technique.

5) Write a C program to reverse the elements of a given array (not just reverse printing) .
Ex:
int a[] = {1, 3 , 5 , 4 , 2};
output = {2 , 4 , 5 , 3 , 1};

6) Write a C program to delete an element at desired position from an array.


Ex:
int a[] = {14 , 50 , 73 , 9 , 24 , 3 , 92 , -3};
if desired position is 4th then.
output = {14 , 50 , 73 , 9 , 3 , 92 , -3};

7) Write a C program to insert an element at desired position in an array.


Ex:
char a[6] = {‘B’,’C’,’D’,’E’,’F’}
if 'A' is to be stored at 0th position then.
output = {‘A’,‘B’,’C’,’D’,’E’,’F’}

8) Write a C program which deletes the duplicate elements of an array.


Ex:
char a[] = {‘A’,’C’,’B’,’D’,’A’,’B’,’E’,’D’,’B’,’C’}
output: {‘A’,’C’,’B’,’D’,’E’}

9) Write a C program to find the duplicate elements of a given array and find the count of
duplicated elements.
Ex:
int a[] = {0 , 3 , 1 , 0 , 5 , 1 , 2 , 0 , 4 , 5}
output:
The duplicate elements are existed in an array
0 -- 3 times
1 -- 2 times
5 -- 2 times
10) Write a program to print the non repeated numbers of a given array.
Ex :
int a[] = {0 , 3 , 1 , 0 , 5 , 1 , 2 , 0 , 4 , 5}
Output = 3 , 2 , 4

11) Write a program to copy the elements of one array into another array without duplicate
items as a first slot, and store duplicate elements as a second slot.

Ex:
source array {10 , 2 , 4 , 5 , 2 , 1 , 3 , 4 , 6 , 5 , 8 , 9 , 2}

destination arrays {10 , 2 , 4 , 5 , 1 , 3 , 6 , 8 , 9} , {2 , 2 , 4 , 5}


first slot second slot

Take two different arrays for first and second slots.

12) Write a C program to evaluate the following series. The series contains sum of
square of numbers from 1 to 'n'. Strore result of each term in an array. Calculate
value of ' S ' using array.

S = 1^2 + 2^2 + 3^2 + 4^2 + ------ n^2


= [ 1, 4, 9, 16, -------- n^2 ]

Suppose n = 4,

then S = 1^2+2^2+3^2+4^2;
S = 1+4+9+16;
S = 30.

13) There are 48 bits are stored in an array of character buffer and store them into 2
integer variables.
Ex:
char a[6] = {‘a’,’b’,’c’,’d’,’e’,’f’};
int num1=first 32 bits
int num2=last 16 bits
output:
num1= 1684234849
num2= 25956
14) Write a C program to implement the stack using arrays.

STACK

-------------------------------------------------------- END --------------------------------------------------------

You might also like