0% found this document useful (0 votes)
380 views2 pages

C Hackathon 2019: Assignment 1

The document provides instructions and questions for a C hackathon assignment. Students are instructed to write modular programs using functions, apply proper coding standards and documentation formats, and submit their work in a folder named with their student ID number. It then lists 11 practice questions covering topics like printing patterns, string manipulation, array operations, prime numbers, calculators, binary conversion, XOR, Fibonacci sequences and more. It concludes with 11 additional questions for submission covering topics such as converting numbers to words, printing patterns, finding maximum subarrays, counting pairs with divisible sums, finding largest elements/substrings, and problems involving bits.

Uploaded by

Nandini
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)
380 views2 pages

C Hackathon 2019: Assignment 1

The document provides instructions and questions for a C hackathon assignment. Students are instructed to write modular programs using functions, apply proper coding standards and documentation formats, and submit their work in a folder named with their student ID number. It then lists 11 practice questions covering topics like printing patterns, string manipulation, array operations, prime numbers, calculators, binary conversion, XOR, Fibonacci sequences and more. It concludes with 11 additional questions for submission covering topics such as converting numbers to words, printing patterns, finding maximum subarrays, counting pairs with divisible sums, finding largest elements/substrings, and problems involving bits.

Uploaded by

Nandini
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/ 2

KLE Technological University

School of Electronics and Communication Engineering

C Hackathon 2019

Assignment 1
Instructions:
• Students are suggested to write modular programs (using Functions).
• Use proper coding standards and documentation formats
• Submission Questions to be submitted by all students in a folder named
their USN.

Questions for Practice:

1. Print pattern with following order:


*
**
***
****
****
***
**
*

2. Program to display all substrings of a string


3. Given a string consisting of alphabets and digits, print the frequency of each digit in
the given string. (ex: input: a11472o5t6 , output: 0 2 1 0 1 1 1 1 0 0)
4. Write a program to reverse a given array
5. Write a program to reverse a given string without inbuilt function.
6. Write a program to display prime number between the given range of numbers.
7. Write a program to implement a calculator.
8. With following operations
a. Addition d. Division
b. Subtraction e. Modulus
c. Multiplication f. Power
9. Write a program to display the binary form of a number.
10. Given a number n, the task is to find the XOR from 1 to n.
Examples :
Input : n = 6
Output : 7 (1 ^ 2 ^ 3 ^ 4 ^ 5 ^ 6 = 7)

Input : n = 7
Output : 0 (1 ^ 2 ^ 3 ^ 4 ^ 5 ^ 6 ^ 7 = 0)
11. Find the nth Fibonacci number.

Questions for Submission

1. Given a positive integer denoting n, do the following:


• If 1<n<9, then print the lowercase English word corresponding to the number (e.g.,
one for, two for, etc.).
• If n>9, print Greater than 9.
• Input Format: The first line contains a single integer denoting n
Output Format: If 1<= n <=9, then print the lowercase English word corresponding
to the number (e.g., one for 1, two for 2, etc.); otherwise, print Greater than 9
instead.
KLE Technological University
School of Electronics and Communication Engineering

C Hackathon 2019

2. Print the following pattern


Input : n=4 Input : n=5
Output : Output :
1234 1234
9 10 11 12 9 10 11 12
13 14 15 16 17 18 19 20
5678 13 14 15 16
5678

3. Printing the following pattern


Input : n=3 Input : n=4
Output : Output :
333 44444
313 44144
323 44244
333 44344
44444
4. Print the following pattern
Output : 1
22
333
4444
4444
333
22
1
5. Find the maximum a subsequence of an array which yields Maximum sum.
(https://en.wikipedia.org/wiki/Maximum_subarray_problem)
6. Given an array A[] and positive integer K, the task is to count total number of pairs in the
array whose sum is divisible by K.
Note : This question is generalised version of this
Examples: is divisible by '4' i.e., (2, 2),
Input : A[ ] = {2, 2, 1, 7, 5, 3}, K = 4 (1, 7), (7, 5), (1, 3) and (5, 3)
Output : 5 Input : A[ ] = {5, 9, 36, 74, 52, 31, 42},
Explanation : K=3
There are five pairs Output : 7
possible whose sum
7. Find the second largest element from an array.
8. Find the largest prefix and suffix in a given string.
Input: abcbcaaabcbc
Output: abcbc
9. Find the largest sub-string which is in alphabetical order.
10.find HCF and LCM of two numbers
11. Find element with the maximum set bits in an array
Given an array arr[ ]. The task is to find an element from arr[ ] which has the
maximum count of set bits.
Input: arr[ ] = {10, 100, 1000, 10000}
Output: 1000
Binary(10) = 1010 (2 set bits)
Binary(100) = 1100100 (3 set bits)
Binary(1000) = 1111101000 (6 set bits)
Binary(10000) = 10011100010000 (5 set bits)
Input: arr[ ] = {3, 2, 4, 7, 1, 10, 5, 8, 9, 6}
Output: 7

You might also like