Sei sulla pagina 1di 11

Q1.

consider the given 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 this series form a Fibonacci series and all
the even terms are the prime numbers in ascending order. Now write a program to find the Nth
term in this series.

case 1: input: 16

output: 2187

Q2. Consider the following series: 0,0,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8

This series is a mixture of 2 series all the odd terms in this series form even numbers in
ascending order and every even term is derived from the previous term using the formula (x/2).

Write a program to find the nth term in this series.

The value n is 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 the nth term no other
characters /strings or message should be written to STDOUT.

For example, if n=10, the 10 th term in the series is to be derived from the 9th term in the series.
The 9th term is 8 so the 10th term is (8/2)=4. Only the value 4 should be printed to STDOUT.

You can assume that the n will not exceed 20,000.

case 1: input: 10

output: 04

Q3. Consider the given input and output:

Input: Get 3 strings in 3 lines as input

Hello

Hi

Good Morning
Output:

In the 1st string, replace the vowels with “

In the 2nd string, replace the consonants with *

In the third string, convert the lowercase letters to upper case.

case 1: input: Hello

Good

Morning

output: H”ll”

*oo*

morning

Q4. 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 this 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 this series.

The value N is 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/strings or message should be written to STDOUT.

For example, when N = 14, the 14th term in the series is 17. So only the value 17 should be
printed to STDOUT.
CASE : Input: 14

Output: 17

Q5 Given a series whose even term creates a separate geometric series and odd term creates
another geometric series. Write a program to generate such series.

For example,

1, 1, 2, 2, 4, 4, 8, 8, 16, 16,……

CASE :

INPUT:

Enter the number of terms : 10

Enter the common ratio for G.P - 1 : 2

Enter the common ratio for G.P - 2 : 3

Output:

The series is

1 1 2 3 4 9 8 27 16 81

Q6. Eesha was in a wonderland where she saw a treasure trove of seven items of various items
(in lakhs) and weights (in kgs) as per the table given below.

Value

Weight
12 4 10 6 8 5 11 7 14 3 5 10 5 12

She wanted to bring back the maximum value of items but she was not able to carry more than
10 kgs. Using dynamic programming, what is the maximum value of the items that she could
carry back with her.

Answer: 26

Q7. wap to find the factorial of a number using recursion

case: input: 5

output: 120

Q8: Program to convert a number from decimal to binary

CASE :INPUT: 15

OUTPUT: 1111

Q9 WRITE A Program to find prime numbers in a given range . A number is said to be prime if it is
divisible by 1 and the number itself.

CASE : INPUT: START VALUE: 10

END VALUE: 50

OUTPUT: 11 13 17 19 23 29 31 37 41 43 47

Q10 WAP to check if a given number is a strong number or not. A strong number is a number in
which the sum of the factorial of the digits is equal to the number itself

CASE : INPUT: 123 CASE: INPUT: 145

OUTPUT: NO OUTPUT: YES

Q11 Find the nth term of the series.

1,1,2,3,4,9,8,27,16,81,32,243,….
Q12 Consider the following series: 1,1,2,3,4,9,8,27,16,81,32,243,64,729,128,2187…

This series is a mixture of 2 series – all the odd terms in this series form a geometric series and
all the even terms form yet another geometric series. 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 value of n th term,no other character /
string or message should be written to STDOUT. For example , if N=16, the 16th term in the
series is 2187, so only value 2187 should be printed to STDOUT.

You can assume that N will not exceed 30.

Q13 Given a series whose even term creates a separate geometric series and odd term creates
another geometric series . Prog in any language to find the nth term. Where u may consider that
n not greater dan 30.

1,1,2,2,4,4,8,8,16,16 also this code

Q14 Consider the below series :

0,0,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8

This series is a mixture of 2 series all the odd terms in this series form even numbers in
ascending order and every even terms is derived from the previous term using the formula (x/2)

Write a program to find the nth term in this 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 the nth term no other
characters /strings or message should be written to STDOUT.

For example if n=10,the 10 th term in the series is to be derived from the 9th term in the series.
The 9th term is 8 so the 10th term is (8/2)=4. Only the value 4 should be printed to STDOUT.

You can assume that the n will not exceed 20,000.

Q15 The program will recieve 3 English words inputs from STDIN

These three words will be read one at a time, in three separate line

The first word should be changed like all vowels should be replaced by $

The second word should be changed like all consonants should be replaced by #

The third word should be changed like all char should be converted to upper case

Then concatenate the three words and print them

Other than these concatenated word, no other characters/string should or message should be
written to STDOUT

For example if you print how are you then output should be h$wa#eYOU.

You can assume that input of each word will not exceed more than 5 chars

Q16 consider the given 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 this series form a Fibonacci series and all
the even terms are the prime numbers in ascending order. Now write a program to find the Nth
term in this series.
Input: 14

Output: 17

Q17 Consider the following series: 1,1,2,3,4,9,8,27,16,81,32,243,64,729,128,2187…

This series is a mixture of 2 series – all the odd terms in this series form a geometric series and
all the even terms form yet another geometric series. Write a program to find the Nth term in
the series.

The value N is 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 the nth term, no other
character/string or message should be written to STDOUT. For example, if N=16, the 16th term in
the series is 2187, so only value 2187 should be printed to STDOUT.

You can assume that N will not exceed 30.

Input: 16

Output: 2187

Q18 Program to check whether the given number is Armstrong or not . A number is an
Armstrong number when the sum of nth power of each digit is equal to the number itself. Here n
is the number of digits in the given number. For example,

An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is
equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 =
371.

Q19 Program to check whether the given number is a palindrome or not . Any number is said to
be a palindrome if the original number and the reverse of the original number are the same.
Q20 WRITE Prime number program You can check if a given number is prime or not

using for loop

using functions

using pointers and

using recursion

A number is said to be prime if it is divisible by 1 and itself. It should not have any other divisors.

Q21 WRITE A Program to find the GCD of two numbers. The HCF (Highest Common Factor or
GCD (Greatest Common Divisor) of two integers is nothing but the largest integer that can
exactly divide a given number without leaving a remainder.

Q22 Write a program, to check whether the given year is a leap year or not. A leap year is a
calendar year containing one additional day (Feb 29th) added to keep the calendar year
synchronized with the astronomical year.

Q23 Write a Program to find the area of a circle. Area of the circle can be found using the
formula, Area = πr², where r is the radius of the circle. When the radius of the circle is known,
the area of the circle can be calculated using the formula mentioned.

INPUT & OUTPUT FORMAT:

The input corresponds to the radius of the circle.

The output corresponds to the area of the circle and it should be a floating point variable with 2
point precision.

Q24 Program to check whether the given number is Armstrong or not. A number is an Armstrong
number when the sum of nth power of each digit is equal to the number itself. Here n is the
number of digits in the given number. For example,
An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is
equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 =
371.

Q25 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 this 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 this series.

The value N is 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/strings or message should be written to STDOUT.

For example, when N = 14, the 14th term in the series is 17. So only the value 17 should be
printed to STDOUT.

Input: 14

Output: 17

Q26 Given a series whose even term creates a separate geometric series and odd term creates
another geometric series. Write a program to generate such series.

For example,

1, 1, 2, 2, 4, 4, 8, 8, 16, 16,……

Input:
Enter the number of terms : 10

Enter the common ratio for G.P - 1 : 2

Enter the common ratio for G.P - 2 : 3

Output:

The series is

1 1 2 3 4 9 8 27 16 81

Q27 WRITE A PROGRAM FIBONACCI SERIES USING COMMAND LINE ARGUMENTS

Q28 WRITE A PROGRAM TO SWAP TWO NUMBERS USING COMMAND LINE PROGRAMMING

Q29 WRITE A PROGRAM OF STRING REVERSAL PROGRAM WITH COMMAND LINE


PROGRAMMING

Q30 WRITE A PROGRAM TO FIND GREATEST OF TWO NUMBER USING COMMAND LINE
PROGRAMMING?

Q31 WRITE A PROGRAM TO FIND THE LCM OF TWO NUMBERS USING COMMAND LINE
LANGUAGE

Q32 WRITE A PROGRAM TO FIND THE AVERAGE OF TWO NUMBERS USING COMMAND LINE
LANGUAGE

Q33 WRITE A PROGRAM TO FIND THE SUM OF THE DIGITS OF A NUMBER BY COMMAND LINE
ARGUMENTS

Q34 Write a C program to find the area of a triangle given the base and the corresponding
height. The values base and height are both positive integers passed to the program as the first
and second command line parameters respectively. Write the output to stdout formatted as a
floating point number rounded to EXACTLY 2 decimal precision WITHOUT any other 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.
Q35 WRITE A PROGRAM TO PRINT ALL INTEGERS USING COMMAND LINE ARGUMENTS

Q36 Write a C program to calculate the factorial of a non-negative integer N. The factorial of a
number N is defined as the product of all integers from 1 up to N. Factorial of 0 is defined to be
1. The number N is a non – negative integer that will be passed to the program as the first
command line parameter. Write the output to stdout formatted as an integer WITHOUT any
other additional text. You may assume that the input integer will be such that the output will not
exceed the largest possible integer that can be stored in an int type variable.

Q37 WRITE A PROGRAM TO CALCULATE LENGTH OF THE HYPOTENUSE OF RIGHT ANGLED


TRIANGLE

Q38 Write a C program that will find the sum of all prime numbers in a given range.The range will
be specified as command line parameters. The first command line parameter, N1 which is a
positive integer, will contain the lower bound of the range. The second command line parameter
N2, which is also a positive integer will the upper bound of the range. The program should
consider all the prime numbers within the range, excluding the upper and lower bound. Print the
output in integer format to stdout. Other than the integer number, no other extra information
should be printed to stdout

Q39 WRITE A PROGRAM TO SORT AN ARRAY INTO TWO HALVES, ONE HALF ASCENDING AND
SECOND HALF DESCENDING COMMAND LINE LANGUAGE

Q40 Write a C program that will find the sum of all prime numbers in a given range.The range will
be specified as command line parameters. The first command line parameter, N1 which is a
positive integer, will contain the lower bound of the range. The second command line parameter
N2, which is also a positive integer will the upper bound of the range. The program should
consider all the prime numbers within the range, excluding the upper and lower bound. Print the
output in integer format to stdout. Other than the integer number, no other extra information
should be printed to stdout.

Potrebbero piacerti anche