Sei sulla pagina 1di 11

BONAM VENKATA CHALAMAYYA INSTITUTE OF TECHNOLOGY AND SCIENCE

TRAINING & PLACEMENTS AND CAREER GUIDANCE CELL


DAY 1 CODING
Program 1
Count number of days between two giving dates for e.g. start date 01/01/2015 and end date
01/01/2019.
Test Cases:
-----------
1. VALID INPUT:
a) Only two arguments will be given as input. (e.g.01/01/2015 and 01/01/2019)
2. INVALID inputs:
a) One argument and More than two arguments.
b) Negative Date.
c) Day greater than 31 or less than 1.
d) Month greater than 12 or less than 1.
3. You should generate output as follows:
a) Print number of days to the STDOUT without any additional text.
c) If error print 'ERROR' to the STDOUT without any additional text.
Program 2
C program to remove characters from the first string which are present in the second string.
Two string will be given as input from command line as first and second argument. You need to
remove characters from the first string which are present in the second string print it.
For ex : [./a.out morzilla mzi] =>orzlla
[./a.out morzilla123 la] =>morzi123
Test Cases:
-----------
1. VALID INPUTS:
a) Only two string will be given as input through command line argument. For Ex:- [./a.out
mozilla mzi] => orzlla
2. INVALID INPUTS:
a) no command line argument. [./a.out] => ERROR
b) More than two command line argument [./a.out Cat123 abc axr] =>
ERROR
3. OUTPUT:
a) Write the output to stdout WITHOUT any other additional text. For example [./a.out
mozilla123 la] => morzi123
b) In case of invalid input print 'ERROR' to the STDOUT without any other additional text and
terminate
Problem 3 C program to convert a number belonging to one base into its corresponding
equivalent belonging to any other base. For e.g. binary number (Base 2) to Decimal (Base 10)
Test Cases:
----------
1. VALID INPUT:
a) Three positive integers will be given as input. First input is the given number second input is
its current base and third input is the base of the converted number.
2. INVALID INPUTS:
a) 0
PREPARED BY
A P V D L KUMAR
TPO,BVCITS
b) -5
c) Fraction
d) String
e) Two or less command line arguments
3. You should generate output as follows:
a) For valid input print only the output to the STDOUT without any other additional text.
b) If any error: print ERROR to the STDOUT without any other additional text.
Input:
17 10 2
Output:
10001
Problem 4
C program to display Armstrong numbers between two intervals.
Test Cases:
-----------
1. Valid Input:
a) Only two positive Integer will be given as input.
2. Invalid Inputs:
a) Only one argument.
b) -5
c) fraction
d) string
3. You should generate output as follows:
a) Print all the armstrong number between the given range seperated by a single space to the
STDOUT without any additional text.
b) If error print 'ERROR' to the STDOUT with out any additional text.
Problem 5
C program to display Fibonacci sequence up to N terms. Test Cases:
-----------
1. VALID INPUT:
a) Only one positive Integer (greater than 0) will be given as input.
2. INVALID INPUTS:
a) -5
b) no command line argument
c) string
d) two or more command line arguments
3. OUTPUT:
a) Print only the terms separated by a space to the STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additional text and
terminate.
Input:
7
Output:
0112358

DAY 2 CODING

PREPARED BY
A P V D L KUMAR
TPO,BVCITS
Problem 1:
C program to convert a binary number to octal number.
Input:
101
Output:
5
Input:
11010
Output:
32
Test Case:
-------------
1. Valid Input:
a) Only number consisting of 0s and 1s will be given as input
2. Invalid inputs:
a) Decimal
b) Fraction
c) String
d) Two or more command line arguments
e) Negative number
3. You should generate output as follows:
a) For right output print just the actual Octal Value to STDOUT without any other text.
b) If any error: print 'ERROR' to the STDOUT without any other text.
Program 2:
Given an array of integers, sort the first half of the array in ascending order and second
half in descending order. Take input from STDIN by scanf().
Examples:
Input : arr[] = {5, 2, 4, 7, 9, 3, 1, 6, 8}
Output : arr[] = {1, 2, 3, 4, 9, 8, 7, 6, 5}
Input : arr[] = {1, 2, 3, 4, 5, 6}
Output : arr[] = {1, 2, 3, 6, 5, 4}
Test Case:
-------------
1. Valid Input:
a) Only integer will be given as input.
2. Invalid inputs:
b) Fraction
c) String
3. You should generate output as follows:
a) For right output print just the array to STDOUT without any other text.
b) If any error: print 'ERROR' to the STDOUT without any other text.
Program 3:
A prime number is a whole number greater than 1, whose only two whole-number factors
are 1 and itself. The first few prime numbers are 2, 3, 5, 7, 11 and 13.
Given two integers, print the sum of all prime numbers between n1 and n2 (both inclusive).
Input
The first line of the input contains an integer t, number of test cases next t lines follow with
each

PREPARED BY
A P V D L KUMAR
TPO,BVCITS
line containing two integers n1 and n2
Output
For each test case print the answer in a new line.
Example
Input:
2
16
66
Output:
10
0
Test Cases:
---------------
1. Valid Input:
a) Only integer will be given as input.
Constraints:
1 < t <= 10
0 < n1 <= n2 <= 100
2. Invalid inputs:
a) Negative number (t, n1, or n2)
b) Fraction
c) String
3. You should generate output as follows:
a) For right output print just the sum to STDOUT without any other text.
b) If any error: print 'ERROR' to the STDOUT without any other text.
Program 4:
Remove duplicates character from a given string.
Input String:
engineering
Output String:
engier
Test Cases:
---------------
1. Valid Input:
a) Only string of character will be given as input.
2. Invalid inputs:
a) No command line arguments
b) Two or more command line arguments
c) Integer
d) Fraction
3. You should generate output as follows:
a) For right output print just the string to STDOUT without any other text.
b) If any error: print 'ERROR' to the STDOUT without any other text.
Program 5
C Program to find sum of series 1 + 1/2 + 1/3 + 1/4 +... + 1/n. The value n is positive integer
passed to the program as the first command line parameter. Write the output to stdout
formatted
as a floating point number rounded to EXACTLY 2 decimal precision WITHOUT any other

PREPARED BY
A P V D L KUMAR
TPO,BVCITS
additional text. Scientific format (such as 1.00E+5) should NOT be used while printing the
output. You may assume that the inputs will be such that the output will not exceed the largest
possible real number that can be stored in a float type variable.
Example
Input
1
Output
1
Input
2
Output
1.5
Test Cases:
--------------
1. VALID INPUTS:
a) Only positive integer will be given as input through command line argument.
2. INVALID INPUTS:
a) No command line argument.
b) More than 1 command line arguments
c) String
d) Fraction
e) Negative number as input argument
3. OUTPUT:
a) Write the output to stdout formatted as a floating point number rounded to
EXACTLY 2 decimal precision WITHOUT any other additional text.
For example
[./a.out 7] => 2.59
b) In case of invalid input print 'ERROR' to the STDOUT without any other additional
text and terminate.
DAY 3 CODING
Program 1:
The problem is quite simple. You're given a number N and a positive integer K. Tell if N can be
represented as a sum of K prime numbers (not necessarily distinct).
Input Format
The first line contains a single integer T, denoting the number of test cases.
Each of the next T lines contains two positive integers, N & K, separated by a single space.
Output Format
For every test case, output "Yes" or "No".
Input
2
10 2
16
Output
Yes
No
Test Cases:
-----------
1. VALID INPUTS:

PREPARED BY
A P V D L KUMAR
TPO,BVCITS
a) Only integer will be given as input from STDIN.
Constraints
1 <= T <= 5000
1 <= N <= 1000
1 <= K <= 1000
2. INVALID INPUTS:
a) String.
b) Fraction.
c) Negative number.
3. OUTPUT:
a) Write the output to STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additional text and
terminate.
Program 2
Given an array of integers, task is to print the array in the order – smallest number, Largest
number, 2nd smallest number, 2nd largest number, 3rd smallest number, 3rd largest number
and so
on…..
Examples:
Input:
arr[] = [5, 8, 1, 4, 2, 9, 3, 7, 6]
Output:
arr[] = {1, 9, 2, 8, 3, 7, 4, 6, 5}
Input:
arr[] = [1, 2, 3, 4]
Output:
arr[] = {1, 4, 2, 3}
Test Cases:
-----------
1. VALID INPUTS:
a) Only integer will be given as input through STDIN.
2. INVALID INPUTS:
a) String s
3. OUTPUT:
a) Write the output to STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additional text and
terminate.
Program 3
Consider the below series:
1, 2, 1, 3, 2, 5, 3, 7, 5, 11, 8, 13, 13, 17, …
This series is a mixture of 2 series – all the odd terms in the series form a Fibonacci series and
all
the even terms are the prime numbers in ascending order.
Write a program to find the Nth term in the series.
The value N in a positive integer that should be read from STDIN. The Nth term that is
calculated by the program should be written to STDOUT. Other than the value of Nth term, no
other characters/string or message should be written to STDOUT.
For example when N=14, the 14th term in the series is 17.

PREPARED BY
A P V D L KUMAR
TPO,BVCITS
Test Cases:
-----------
1. VALID INPUTS:
a) Only integer will be given as input through STDIN.
2. INVALID INPUTS:
a) String.
b) Fraction.
c) Negative number as input argument.
3. OUTPUT:
a) Write the output to STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additional text and
terminate.
Program 4
C program to reverse a String Using Recursion
Input String:
margorp emosewa
Output String:
awesome program
Test Cases:
-----------
1. VALID INPUTS:
a) Only String will be given as input through STDIN.
2. INVALID INPUTS:
a) Characters other than alphabet.
3. OUTPUT:
a) Write the output to STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additional text and
terminate.
Program 5
C Program to Remove all Characters in a String except Alphabet and store the resultant string
within the same string. Change all upper case letters to lower case and then check whether the
string is palindrome is not without using library function.
Input String:
In.form,atio1n Tec?hnol-og=y
Output String:
Information Technology
INFORMATION TECHNOLOGY
NO
Test Cases:
-----------
1. VALID INPUTS:
a) Only String will be given as input through command line argument.
2. INVALID INPUTS:
a) No command line argument.
b) More than 1 command line arguments.
3. OUTPUT:
a) Write the output to STDOUT without any other additional text.
b) In case of invalid input print 'ERROR' to the STDOUT without any other additional text and

PREPARED BY
A P V D L KUMAR
TPO,BVCITS
terminate.
DAY 4 CODING

Program 1
Given two arrays of n numbers each, form a pair of numbers taking one number from array1
and the other from array2 such that the sum of the pair of this numbers is the maximum
possible for the given arrays. Take input from STDIN. Don’t use any sorting technique.
Input:
2 1 5 7 10
36812
Output:
18
Program 2
Display Pascal Triangle pattern. Pascal’s triangle is a triangular array of the binomial
coefficients. Write a function that takes an integer value n as input from command line
argument and prints first n lines of the Pascal’s triangle. Optimize the time and space
complexity.
Test Cases:
-----------
1. VALID INPUT:
a) Only one argument will be given as input.
2. INVALID inputs:
a) Two or more than two arguments.
b) Negative argument.
c) Fraction.
d) String.
3. You should generate output as follows:
a) Display pattern to the STDOUT without any additional text.
b) If error print 'ERROR' to the STDOUT without any additional text
Program 3
Given an array of elements of length N, ranging from 1 to N. All elements may not be present in
the array. If element is not present then there will be -1 present in the array. Rearrange the
array such that A[i] = i and if i is not present, display -1 at that place. Take input from STDIN.
Examples:
Input : arr = {-1, -1, 6, 1, 9, 3, 2, -1, 4, -1}
Output : [-1, 1, 2, 3, 4, -1, 6, -1, -1, 9]
Input : arr = {19, 7, 0, 3, 18, 15, 12, 6, 1, 8, 11, 10, 9, 5, 13, 16, 2, 14, 17, 4}
Output : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Program 4
Write a program count the number of vowels from the string. Convert it from lower case to
upper case and then reverse the string.
Examples:
Input:
Information
Output:
5
INFORMATION
NOITAMROFNI

PREPARED BY
A P V D L KUMAR
TPO,BVCITS
Test Cases:
-----------
1. VALID INPUT:
a) Only one argument will be given as input.
2. INVALID inputs:
a) No argument
b) Two or more than two arguments.
c) Characters other than alphabet.
3. You should generate output as follows:
a) Print to the STDOUT without any additional text.
b) If error print 'ERROR' to the STDOUT without any additional text
Program 5
C Program to Copy File into another File. Take file name from command line argument.
Test Cases:
-----------
1. VALID INPUT:
a) Only two argument will be given as input.
2. INVALID inputs:
a) No argument
b) More than two arguments.
DAY 5 CODING
Program 1:
Given a 2D array, print it in spiral form. Take input from STDIN.
Examples:
Input:
1234
5678
9 10 11 12
13 14 15 16
Output:
1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10
Program 2:
Given three arrays sorted in non-decreasing order, print all common elements in these arrays.
Take input from STDIN.
Examples:
Input:
ar1[] = {1, 5, 10, 20, 40, 80}
ar2[] = {6, 7, 20, 80, 100}
ar3[] = {3, 4, 15, 20, 30, 70, 80, 120}
Output: 20, 80
Program 3:
Write a C program that, given an array A[] of n numbers and another number K, find the pair of
all elements in A whose sum is exactly K. Take input from STDIN.
Example:
Input:
A[]={1, 4, 15, 6, 10, 2}, K=16
Output:
(1, 15)

PREPARED BY
A P V D L KUMAR
TPO,BVCITS
(6, 10)
Program 4:
Given a string, find the second most frequent character in it. Take input from STDIN.
Examples:
Input: str = "aabababa";
Output: Second most frequent character is 'b'
Program 5:
Find the GCD and LCM of Two number. Take input from command line argument.
Example:
Input:
30
40
Output:
10
120
Test Cases:
-----------
1. VALID INPUT:
a) Only two arguments will be given as input.
2. INVALID inputs:
a) No argument
b) One argument
c) More than two arguments.
d) String
3. You should generate output as follows:
a) Print to the STDOUT without any additional text.
b) If error print 'ERROR' to the STDOUT without any additional text.
DAY 6 CODING
Program1:
Given a number n, write an efficient function to print all prime factors of n.
For example, if the input number is 12, then output should be “2 2 3”. And if the input number
is
315, then output should be “3 3 5 7”. Take input from command line argument.
Test Cases:
-----------
1. VALID INPUT:
a) Only one argument will be given as input.
2. INVALID inputs:
a) No argument
b) Two or more than two arguments.
c) Characters other than integer
3. You should generate output as follows:
a) Print to the STDOUT without any additional text.
b) If error print 'ERROR' to the STDOUT without any additional text.
Program2:
Write a c program to rotate an array arr[] of size n by d elements. Take input from STDIN.
Example:
Input: arr[] = [1, 2, 3, 4, 5, 6, 7]

PREPARED BY
A P V D L KUMAR
TPO,BVCITS
d=2
Output: arr[] = [3, 4, 5, 6, 7, 1, 2]
Program3:
Given an array, find the most frequent element in it. If there are multiple elements that appear
maximum number of times, print any one of them. Take input from STDIN.
Examples:
Input: arr[] = {1, 3, 2, 1, 4, 1}
Output: 1
1 appears three times in array which is maximum frequency.
Input: arr[] = {10, 10, 20, 10, 20, 30, 20}
Output: 20
Both 10 and 20 appears three times which is maximum. So display either 10 or 20.
Program4:
Write a c program to replace a given character in a String to other provided characters, for
example if you are asked to replace each blank in a String with %20, similar to URL encoding
done by the browser, so that Server can read all request parameters.
For example if the input is "Java is Great" and asked to replace space with %20 then it should be
"Java%20is%20Great". Take input from STDIN.
Program5:
Given a 2D square matrix, find sum of elements in Principal and Secondary diagonals. Take
input from STDIN.
Example:
Input:
4
1234
4321
7896
6543
Output:
Principal Diagonal: 16
Secondary Diagonal: 20

PREPARED BY
A P V D L KUMAR
TPO,BVCITS

Potrebbero piacerti anche