0% found this document useful (0 votes)
1 views1 page

TOUGH

The document outlines a series of programming tasks involving arrays and integers. Tasks include calculating sums, copying elements based on conditions, finding prime numbers, determining frequency, calculating mean and mode, and comparing names lexicographically. Each task requires separate programs with a common initial reading of input values.

Uploaded by

s36347032
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)
1 views1 page

TOUGH

The document outlines a series of programming tasks involving arrays and integers. Tasks include calculating sums, copying elements based on conditions, finding prime numbers, determining frequency, calculating mean and mode, and comparing names lexicographically. Each task requires separate programs with a common initial reading of input values.

Uploaded by

s36347032
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/ 1

1. Read in an integer n (n < 25). Read n integers in an array A.

Then do the
following (write separate programs for each, only the reading part is common).

a) Find the sum of the absolute values of the integers.


b) Copy the positive and negative integers in the array into two additional arrays
B and C respectively. Print A, B, and C.
c) Exchange the values of every pair of values from the start (so exchange
A[0] and A[1], A[2] and A[3] and so on). If the number of elements is odd,
the last value should stay the same.

2. Read in two integers n and m (n, m < 50). Read n integers in an array A. Read
m integers in an array B. Then do the following (write separate programs for
each part, only the reading part is common).

a) Find if there are any two elements x, y in A and an element z in B, such that
x+y=z
b) Copy in another array C all elements that are in both A and B (intersection)
c) Copy in another array C all elements that are in either A and B (union)
d) Copy in another array C all elements that are in A but not in B (difference)

3. Write a C program that reads an integer n and uses an array to efficiently find out
the first n prime numbers.

4. Read in an integer n, read in n integers and print the integer with the highest
frequency.

5. Read in an integer n, read in n numbers and find out the mean and mode.

6. Read in two names and compare them and print them in lexicographic (dictionary)
order.

You might also like