The 26th practical question would be in following format:
See e.g. given below:
-----------------------------------------------------------Instructions-------------------------------------------------------------------
1) The paper contains 2 problems, 1st question is calls for logic and 2nd is for programming
2) Correct solution to the 1st problem carries relatively more marks / more preference for getting shortlisted
3) In the beginning, please print (using printf) your ID-rollno (given by instructor),name, college, Qno and first five and last five words of the problem statement (as to avoid any confusion at the evaluation.
4) Your program should work for the general input. However, execute it with the given i/p in TC editor
5) Print Screen o/p in Microsoft word file
6) Below the o/p, copy, paste your c program code in the same word file.
7) For double confirmation, write your name,college, Qno and first five and last five words of problem statement.
8) Save and Submit Microsoft word file to teacher to be copied in cd.
1.a Bacteria are known to multiply very rapidly. If a certain container contains just one bacterium on the first day and there are twice as many on the next day. In this manner the number of bacteria in the container doubles itself everyday. Assuming that the container would be full on the 10th day with 13,312 bacteria, find the number of bacteria that was initially in the container on the first day.
1.b Write two functions FibonacciRecurssively and FibonacciIteratively. Test your functions by calling them in your main.
I/p: n = 4
I/p: n = 4
There are problems of graded complexity. In the contest each of you will get a mix of easy and difficult problems to solve. Need not worry!
Need to practice following problems:
Wish you all the best
------------------------------------------------------------------------------------------------------------------------------------------------------
2.a Write a program to copy its input to its output replacing each tab by the string “Tab”, white space by “Blank” and backslash by “BackSlash”. In case of successive tabs or blanks or backslashes, the output should be appropriately designed. For example, occurrence \\\ should be replaced by “3 blackslashes”.
I/p: \\\If there is an instruction set that the human can perform unthinkingly
O/p: “3 backslashes”if”Blank”there”Blank”is”Blanl”an”Blank”instruction”Blank”set”Blank”that “Tab”the”Blank”human”Blank”can”Blank”perform unthinkingly
2.b. Write a program to compute difference between two dates.
I/p: 15th August 2012 and 26th January 2012; 5th September 2011 and 12th September 2011
I/p: 15th August 2012 and 26th January 2012; 5th September 2011 and 12th September 2011
-----------------------------------------------------------------------------------------------------------------------------------------------------
3.a Write a program that checks a C program for rudimentary syntax errors like mismatched brackets, parenthesis, braces, quotes and comments.
I/p: #include <stdio.h>
int main() /* Most important part of the program!
*/
{
int age; /* Need a variable... *//
printf( "Please enter your age" ); /* Asks for age */
scanf( "%d", &age ); /** The input is put in age **/
if ( age < 100 ) { } // /* If the age is less than 100 */
printf ("You are pretty young!\n" ); /* Just to show you it works... */
}
O/p: #include <stdio.h>
int main() /* Most important part of the program!
*/
{
int age; /* Need a variable... *//
printf( "Please enter your age"; /* Asks for age */
scanf( "%d", &age ); /** The input is put in age **/
if ( age < 100 ) { } // /* If the age is less than 100 */
printf ("You are pretty young!\n" ); /* Just to show you it works... */
}}
3.b. Rita has a money pouch containing Rs.700. There are equal number of 25 paise coins, 50 paise and one rupee coins. Write a C program to find how many of each are there in Rita’s pouch?
-----------------------------------------------------------Instructions-------------------------------------------------------------------
4.a Write a program that plots a graph of word-length vs. frequency of the words of the specific length in the given text.
for e.g.:
I/p: We can call this blank the operand
O/P: Histogram of {(2,1), (3,2), (4,2), (5,1), (7,1)}
Similarly find output for below mentioned test i/p:
Test i/p: she sells sea shells on the sea shore.
4.b Write a program to implement f(x) = f(x-1) + f(x-2) in C.
I/p: Test your output for x = 5
I/p: Test your output for x = 5
----------------------------------------------------------------------------------- ------------------------------------------------------------------
5.a Write a program to generate all strings of length upto k on a given set of symbols. (Hint: I/p:Take 6 symbols in the lower-case English alphabet {a, b, c, d, e, f} and k = 3; print the first 25 strings of your output sorted by length.)
O/p: a,b,c,d,e,f,aa,ab,ac,ad,ae,af, ba, bb...
5.b Write two functions namely SumDigitsRecurssively and SumDigitIteratively that calculate sum of the digits of a given number. Test your functions by calling them in main().
---------------------------------------------------------------------------------------------------------------------------------------------------
6.a Write a program to generate all strings of length upto k on a given set of symbols.
I/p: Take 6 symbols in English alphabet = {a, b, c, d, e, f} and k = 3; print first 25 strings of your output sorted in dictionary order
O/p: a, aa, aaa, aab...
6.b Observe the phenomenon: 45*45=2025; 20+25=45.Write a program to generate the numbers between 32 and 99 that demonstrates this property.
-----------------------------------------------------------------------------------------------------------------------------------------------------
7.a Write a program to compute the index of a given letter-string in a list that has all strings of length upto k generated over n symbols and sorted in dictionary order.
I/p: Take the 6 symbols in English alphabet {a, b, c, d, e, f} and k = 3; print the index of the strings aaa, aab, abb and bbb
O/p: 3, 5, ...
7.b Write two functions ReverseUsingPointers and ReverseString such that the former uses pointers to achieve the effect of reversing a given string and the later does not involve the pointers in making so.
----------------------------------------------------------------------------------------------------------------------------------------------
8.a Write a program to generate all strings of length upto k on a given set of symbols. No symbol should be repeated in any string.
I/p: Take the 6 lower-case symbols in the English alphabet {a, b, c, d, e, f} and k = 3; print the first 25 strings of your output sorted in dictionary order
O/p: a,ab, aba, ...
8.b. Write a program to accept a number and check if it is Palindrome. How would you make it using pointers and without using the pointers?
I/p: (i) palindrome (ii) Einstein (iii) radar
I/p: (i) palindrome (ii) Einstein (iii) radar
------------------------------------------------------------------------------------------------------------------------------------------------------
9.a (kamal, vimal, asmaa, aaditya, abdul, kshitij, mary, amrit, sanjeevan, pritha, kiran) is a list of names of my classmates. Write a program that reads a letter and displays all the names that are starting with that letter. Remember, if the original list has n elements and the last name starting with the given letter is at the i-th position, your look-up should not involve traversing the remaining n-i names.
I/p: a
O/p: asmaa, aaditya, abdul, amrit
O/p: asmaa, aaditya, abdul, amrit
9.b Write a program to compute sine of a given angle by using the following formula.
----------------------------------------------------------------------------------------------------------------------------------------------
10.a Write a program that computes b(n/d) where b, n and d are integers.
I/p: b = 3, n = 4 and d = 2
O/p: 9
O/p: 9
10.b Write a program, which scrolls “Hi” on the screen from left to right and “Hello” on the screen from right to left and when both meet in the centre it displays “Bye”
------------------------------------------------------------------------------------------------------------------------------------------------
11.a {kamal, vimal, asmaa, aaditya, abdul, kshitij, mary, amrit, sanjeevan, pritha, kiran} is a set of names of my classmates. Write a program that takes a name and tells if the person is my classmate or not. In any case, your search should not involve more than one comparison.
11.b Write a program to display sum of the first n terms of the series 1+1/32+1/52+ ...
I/p: n = 4
I/p: n = 4
----------------------------------------------------------------------------------------------------------------------------------------------
12.a Create an animation of stars falling from sky to ground and vanishing. Press any key to
terminate
terminate
12.b Some cats got together and decided to kill 999919 rats. Each of the cats killed equal number of rats. Write a program to find number of cats.
---------------------------------------------------------------------------------------------------------------------------------------------------
13.a Write a program that does the following: The letters of English alphabet are randomly generated and accumulated in a bin. If at any instance it is possible to form a word out of the letters in the bin, the word is formed and displayed. The program ends here. You can always terminate the program by pressing any key in between.
13.b There are some goats and ducks in a farm. There are 60 eyes and 86 foot in total. Write a program to find number of goats and ducks in the farm.
-----------------------------------------------------------------------------------------------------------------------------------------------
14.a Write a program that reads a line and aligns the text to both the right and left margins by adding spaces between the words as necessary.
I/p: like addition or multiplication, we consider the instruction as an operation to be performed
14.b You know 16 / 64 =1/4; Observe that you can obtain the result of the division by just cancelling one digit of denominator with the same that has occurred in the numerator. Generate all such pairs of numbers less than 100 that follow this characteristic.
--------------------------------------------------------------------------------------------------------------------------------------------------
15.a Given m different routes between n cities, 2 new cities that are connected with all n cities, write a program to find the shortest route that connects all n+2 cities. Assume that the adjacent cities are at unit distance.
I/p: Set of adjacent cities is given as {(1,4), (1,6), (2,3), (3,4), (5,7)}
15.b Write a program to compute the Armstrong numbers between 1 and 500. Note that the Armstrong number follows the property as follows: The sum of the cubes of the digits in the number is the number itself. For example, 153=(1*1*1)+(5*5*5)+(3*3*3) implies that 153 is an Armstrong number.
-----------------------------------------------------------------------------------------------------------------------------------------------
16.a Write a program for matchstick game between the computer and a user. Your program should ensure that computer always wins. Rules for the game are as follows:
R1: There are 21 matchsticks
R2: The computer asks the player to pick 1, 2, 3 or 4 matchsticks
R3: After the person picks, the computer plays by picking 1, 2, 3 or 4 sticks
R4: The one who is forced to pick up the last matchstick loses the game.
R2: The computer asks the player to pick 1, 2, 3 or 4 matchsticks
R3: After the person picks, the computer plays by picking 1, 2, 3 or 4 sticks
R4: The one who is forced to pick up the last matchstick loses the game.
16.b Write a C program to find a two digit number, the second digit of which is smaller than its first digit by 4, and if the number was divided by the digit’s sum, the quotient would be 7.
-----------------------------------------------------------------------------------------------------------------------------------------------
17.a Write a program that prints a histogram of frequencies of different characters in its input.
I/p: To know what is your username, type at the prompt who space am space I and press enter.
17.b Given center and the radius, a circle can be specified. Write a program that takes the specifications of two circles and answers the following 3 questions.
Q1. Does C1 intersect C2?
Q2. Does C1 touch C2, if so whether internally or externally?
Q3. Does circle C1 completely embed circle C2?
Q1. Does C1 intersect C2?
Q2. Does C1 touch C2, if so whether internally or externally?
Q3. Does circle C1 completely embed circle C2?
I/P: C1= ((0,0), 1); C2= ((-0.5, 0), 0.5); C3= ((2,0),1); C4=((2,0), 2)
--------------------------------------------------------------------------------------------------------------------------------------------
18.a Write an intelligent editor to simulate the following:
While typing if a new word starts with the same letters as that of some previously typed word, the choice of selecting the word instead of typing the whole should be given.
While typing if a new word starts with the same letters as that of some previously typed word, the choice of selecting the word instead of typing the whole should be given.
I/p: This in fact comes from the who command that enlists all the users currently logged into the system in case your system is a multiuser system.
18.b Write a C program to find a three digit number which is greater than the aggregate of its third, tenth and the twelfth parts by 58.
------------------------------------------------------------------------------------------------------------------------------------------------
19.a Write a program that generates a random number of length 25.
19.b Write functions ReadMatrix and MultiplyMatrix. Write a program to read two matrices and computer their multiplication and displays the output matrix in a two dimension table form.
I/p: Test your program with two 2X2 matrices written in row major order.
Mat1 = (1, 2, 3, 4) and Mat2 = (-1, -2, -3, -4)
I/p: Test your program with two 2X2 matrices written in row major order.
Mat1 = (1, 2, 3, 4) and Mat2 = (-1, -2, -3, -4)
---------------------------------------------------------------------------------------------------------------------------------------------
20.a Write a program called reverse_input for the following behaviour: (1) If the input is a single word, then the output has the word in reverse order, i.e., the last letter of the input word will become the first letter of the output string, the second-last input letter becomes the second output letter and so on. (2) If the input is a single line with several words, then the output has the words in reverse order (but the letters in the words are not reversed). (3) If the input has several lines, then the output has the lines in reverse order (without changing the order of the words in each line).
I/p: (i) word (ii) One line answer
O/p: (i) drow (ii) Answer line one
20.b.
Write a program to accept positive no. in main() and call a function to calculate sum of the digits of that no.
1) without using recursion
2) with recursion
i/p – 2345, 555
No comments:
Post a Comment