0% found this document useful (0 votes)
2 views3 pages

Array and Function Problems

The document presents a series of C programming practice problems focused on functions and arrays. It includes tasks such as determining if a number is lucky, calculating ticket prices based on age, counting numbers greater than the average in an array, and identifying missing numbers. Each problem is accompanied by sample inputs and outputs for clarity.
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)
2 views3 pages

Array and Function Problems

The document presents a series of C programming practice problems focused on functions and arrays. It includes tasks such as determining if a number is lucky, calculating ticket prices based on age, counting numbers greater than the average in an array, and identifying missing numbers. Each problem is accompanied by sample inputs and outputs for clarity.
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

C Programming Practice Problems

Functions & Arrays

Problem 1: Lucky Number


Write a function int lucky(int n) that returns 1 if the sum of the digits of the number
is exactly 7; otherwise return 0. Print Lucky or Not Lucky.

Sample Input
124

Sample Output
Lucky

Problem 2: Ticket Price Calculator


A movie ticket costs 300 taka. Write a function

int ticketPrice(int age)

Rules:

• Age below 12 : 50% discount

• Age above 60 : 30% discount

• Otherwise : Full price

Print the final ticket price.

Sample Input
10

Sample Output
150

1
Problem 3: Special Multiple
Write a function
int special(int n)
Return 1 if the number is divisible by both 3 and 5.
Otherwise return 0.
Print YES or NO based on 1 or 0.
Sample Input
45

Sample Output
YES

Problem 4: Count Numbers Greater Than Average


Read an array of N integers.
Find the average and count how many numbers are strictly greater than the average.
Sample Input
5
2 4 6 8 10

Sample Output
2

Problem 5: Replace Negative Numbers


Read an array. Replace every negative number with 0 and print the updated array.
Sample Input
6
3 -2 8 -5 1 -4

Sample Output
3 0 8 0 1 0

Problem 6: Longest Increasing Streak


Read an array. Find the length of the longest consecutive increasing sequence.
Sample Input
8
2 4 6 3 5 7 8 1

Sample Output
4

Explanation:
The longest increasing streak is:
3578

2
Problem 7: Mirror Array
Read an array. Print ”Mirror” if the first half and second half are exactly the same.
Otherwise print ”Not Mirror”. Where N is always even.

Sample Input
6
4 7 9 4 7 9

Sample Output
Mirror

Problem 8: Missing Number


The array contains numbers from 1 to N , but exactly one number is missing.
Find the missing number.
Sample Input
5
1 2 4 5

Sample Output
3

You might also like