Vous êtes sur la page 1sur 22

Question

Write a program that concatenates two strings

Detailed Description
Your program takes two arguments on the command line. The first argument in the command line is a string 's1'. The second argument is another string 's2'. Your program should concatenate the string 's1' with 's2' and print out the result. For example, if the string s1 is 'Monday' and the string s2 is 'Holiday', then your program should print out 'MondayHoliday'

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog Wipro Technologies executed WiproTechnologies # This is the way your code will be

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program that reverses an integer.

Detailed Description
Your program takes one argument on the command line. This command line argument is an integer 'n'.Your program should reverse the integer 'n' and print it out. For example, if the integer 'n' is 12345, then your program should print out 54321. The given integer 'n' will not exceed 50000.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog 1234 4321 # This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program that computes an expression

Detailed Description
Your program takes four arguments on the command line. The first argument in the command line is an integer which specifies the value of a variable 'a'. The second argument is another integer that specifies the value of a variable 'b'. The third argument is another integer that specifies the value of a variable 'c'. The fourth argument is another integer specifying the value of a variable 'd'. Your program should compute the value of the expression 2a*5b+c-6d*5c given the values of a,b,c,d and print out the result.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog 2 3 1 0 61 # This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program that prints out the first 'n' numbers in the Fibonacci sequence.

Detailed Description
Your program takes one argument on the command line. This command line argument is a number 'n'.Your program should print the first 'n' numbers in the Fibonacci sequence. In a Fibonacci sequence the first two numbers are both 1, and from then on each following number is equal to the sum of the previous two.The numbers 1,1,2,3,5,8,13,21,34.......and so on form a Fibonacci Sequence.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog 5 1 1 2 3 5 # This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program that accepts two numbers as command-line arguments, compute their L.C.M(Least Common Multiple) and print it.

Detailed Description
Your program takes two arguments on the command line. The first argument in the command line is a number 'n1'. The second argument is another number 'n2'. Your program should compute the L.C.M of the numbers 'n1' and 'n2' and print out the result. For example, if the number n1 is '12' and the number n2 is '15', then your program should print out 60.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog 15 6 30 # This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program that prints the transpose of a matrix

Detailed Description
Your program takes one argument on the command line. This command line argument is the name of a text file containing integers.Each line in the text file corresponds to a row in a matrix. Your program should read all the elements of the matrix and print the transpose of the matrix. A transpose T of a matrix M is a matrix where T[j,i]=M[i,j].

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in 12 34 45 56 13 24 35 46 14 25 36 47 11 13 14 10 % your_prog 1.in 12 13 14 11 34 24 25 13 45 35 36 14 56 46 47 10 # This shows the contents of a sample input file

# This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to find the sum of series 1+x+x2+x3+x4+....+xn.

Detailed Description
Your program takes two arguments on the command line. The first argument in the command line is a number 'x'. The second argument is another number 'n'. Your program should compute the sum of the given series and print out the result. For example, if the number x is '3' and the number n is '5', then your program should compute 1+3+32+33+34+35 = 364 and print out 364

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog 3 6 1093 # This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to print the even numbers.

Detailed Description
Your program takes one argument on the command line. The argument in the command line is a number 'n'. Your program should print all the even numbers less than 'n'. For example, if the given number is '20' then the even numbers less than 20 are 2 4 6 8 10 12 14 16 18

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog 50 # This is the way your code will be executed 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to compute the sum of natural numbers.

Detailed Description
Your program takes one argument on the command line. The argument in the command line is a number 'n'. Your program should print the sum of the 'n' Natural numbers. In mathematics, a natural number is any positive integer. For example, if the given number is '20' then sum of the 20 natural numbers are 1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20= 210. then print out the result as 210.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog 21 231 # This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a Program that prints out the sum of the integers in the file.

Detailed Description
Your Program takes One argument on the command line. This command line argument is the name of a text file containing integers.Each line in the text file contains one integer only. Your program should read all the lines in the file, sum up the integers and print out the result.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in 9 10 15 % your_prog 1.in 34 # This shows the contents of a sample input file

# This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program that reverses the content of each line in a file

Detailed Description
Your program takes one argument on the command line. This command line argument is the name of the text file .Your program should reverse the content of each line and print it out. For example, the reverse of a line 'This is India' is 'aidnI si sihT'.The reverse of the first line is printed out first, the reverse of the second line next and so on.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in # This shows the contents of a sample input file I could have profitably rented out the little room in front of my press. On Market Road, with a view of the fountain, it was coveted by every would-be shopkeeper in our town; I was considered a fool for not getting my money's worth out of it, while all the space I needed for my press and its personnel was at the back, beyond the blue curtain. % your_prog 1.in # This is the way your code will be executed nO .sserp ym fo tnorf ni moor elttil eht tuo detner ylbatiforp evah dluoc I eb-dluow yreve yb detevoc saw ti ,niatnuof eht fo weiv a htiw ,daoR tekraM s'yenom ym gnitteg ton rof loof a deredisnoc saw I ;nwot ruo ni repeekpohs saw lennosrep sti dna sserp ym rof dedeen I ecaps eht lla elihw ,ti fo tuo htrow .niatruc eulb eht dnoyeb ,kcab eht ta

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program that sorts out the words in a file lexicographically

Detailed Description
Your program takes one argument on the command line. This command line argument is the name of a text file containing some english sentences. Your program should read all the words in the file, sort them out lexicographically, as in a dictionary and print them out.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in # This shows the contents of a sample input file I could have profitably rented out the little room in front of my press On at the back beyond the blue curtain % your_prog 1.in at back beyond blue could curtain front have I in little my of On out press profitably rented room the the the # This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program that will print all possible combination of letters in a word lexicographically.

Detailed Description
Your program takes one argument on the command line. This command line argument is an english word. Your program should print all the possible words using the letters of the given word. The words need to be printed out in the same order as they would appear in a dictionary. Note: Use only lower case letters.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog pet ept etp pet pte tep tpe # This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to print a field spanning from 5th to 14th bit positions.

Detailed Description
Your program takes one argument on the command line. The argument in the command line is a hexadecimal number 'n'. The field spanning from 5th to 14th gives the value of a field. Your program should extract the value of the field and print it . Note: The bits are numbered from 1 to 16 with least significant bit as the bit number 1 For Example: If the given number is '0xABCD' . Binary equivalent of '0xABCD' is 1010 1011 1100 1101. Your program should extract 5th to 14th bits which is '101011110011' and print it in decimal which is '2BC'.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% your_prog 0xABCD 2BC # This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to display the given file contents in rank order.

Detailed Description
Your program takes one argument on the command line. This command line argument is the name of a text file containing names, age and marks of students. Each line in the file gives information about one student. The information is stored in the format : 'Name Age Marks'. Your program should sort the file contents rank-wise in the given order which is 'Name Age Marks'.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in Saifan 24 96 Aathif 27 98 Harish 26 60 Pradip 30 75 Atheeq 26 85 Monica 28 82 % your_prog 1.in Aathif 27 98 Saifan 24 96 Atheeq 26 85 Monica 28 82 Pradip 30 75 Harish 26 60 # This shows the contents of a sample input file

# This is the way your code will be executed

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to print the name of all the students who have passed the PRP exam from a unix batch.

Detailed Description
Your program takes two arguments on the command line. The first argument is the name of a text file containing the name and marks of the students. The second argument is the name of a text file containing name and batch of the students. Your program should print the name of the students from unix batch who have cleared their PRP exam. The students who score 70 or more marks in the PRP exam are declared pass in the examination.
For example: If the file 1 contains: Saifan 85 Naveen 75 Atheef 90 Meenal 65 Preeti 67 Sarita 72 Yaseer 76 Pradip 68 If the file 2 contains: Saifan unix Naveen java Atheef unix Meenal java Preeti unix Sarita java Yaseer unix Pradip unix

Then Saifan, Atheef and Yaseer are the students from unix batch who have cleared their PRP examination. Your program should print
Saifan Atheef Yaseer

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type Saifan Naveen Atheef Meenal Preeti Sarita Yaseer Pradip 1.in1 85 75 90 65 67 72 76 68 # This shows the contents of a sample input file

% type 1.in2 # This shows the contents of a sample input file Saifan unix Naveen java Atheef unix Meenal java Preeti Unix Sarita java Yaseer unix Pradip unix % your_prog 1.in1 1.in2 # This is the way your code will be executed Saifan Atheef Yaseer

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to create a binary search tree.

Detailed Description
Your program takes one argument on the command line. This command line argument is the name of the file which contains the data. Your program needs to read the content of the file and create the binary search tree. The first data of the file will be the root node.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in # This shows the contents of a sample input file 12 32 34 87 123 13 89 % your_prog 1.in # This is the way your code will be executed Inorder traversal of the Binary search tree is 12 13 32 34 87 89 123

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to create a linked list.

Detailed Description
Your program takes one argument on the command line. This command line argument is the file name which contains the data to be inserted in the list. Your program should read the contents of the file and create a linked list.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in # This shows the contents of a sample input file 20 30 10 80 40 50 60 90 70 % your_prog 1.in # This is the way your code will be executed Created linked list is 20 30 10 80 40 50 60 90 70

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to create a stack using linked list.

Detailed Description
Your program takes one argument on the command line. This command line argument is the name of the file which contains the data. Your program needs to read the content of the file and store it in a stack and display it.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in # This shows the contents of a sample input file 12 23 45 56 11 78 43 % your_prog 1.in # This is the way your code will be executed Stack contents are 43 78 11 56 45 23 12

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to create a queue using linked list

Detailed Description
Your program takes one argument on the command line. This command line argument is the name of the file which contains the data. Your program needs to read the content of the file and store it in a queue and display it.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in # This shows the contents of a sample input file 12 32 34 87 123 13 89 % your_prog 1.in # This is the way your code will be executed Created queue is 12 32 34 87 123 13 89

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Question
Write a program to create a doubly linked list and display it.

Detailed Description
Your program takes one argument on the command line. This command line argument is the name of the text file containing data. Your program should read the contents of the file, create a doubly linked list and display it.

Program Usage
The following dialog shows the way your program is expected to behave for a sample input.
% type 1.in # This shows the contents of a sample input file 12 32 34 87 123 13 89 % your_prog 1.in # This is the way your code will be executed Created doubly linked list is 12 32 34 87 123 13 89

Note : The input shown above is only a sample.There could be other inputs apart from this for which your program is evaluated .

Vous aimerez peut-être aussi