0% found this document useful (0 votes)
103 views

ZSGS Programming Question

The document contains 60 programming problems covering a variety of topics including loops, conditionals, arrays, strings, patterns, recursion, and more. The problems range from basic to more advanced and require writing Java code to solve them.

Uploaded by

Prabu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views

ZSGS Programming Question

The document contains 60 programming problems covering a variety of topics including loops, conditionals, arrays, strings, patterns, recursion, and more. The problems range from basic to more advanced and require writing Java code to solve them.

Uploaded by

Prabu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Zoho School for Graduate Studies

1) Write a single program to generate a multiplicaiton and subtraction table for a given
number.

2) Write a program to print a letters from the user input character to 'Z' without using
strings.
Example 1: input : X
Output : XYZ

Example 2: Input : M
Output : MNOPQRSTUWXYZ

3) write a program to find the difference between the given number and it's reverse
number.
Example 1: Input : 12345
Output : 12345 - 54321 = -41976

Example 2: Input : 543


Output : 543 - 345 = 198

4) Write a program to define the functionality of a Bitwise operators.

5) Write a program to print the following pattern based on the alphabet.


Example 1:
Input: E
Output:
EEEEE
DDDD
CCC
BB
A
Example 2:
Input:C
Output:
CCC
BB
A

6) Write a program for the following. Let consider 20 students in a class with the roll no
101-120. We are going to split them into four groups. Based on their roll number we are
going to split them with the following logics.
Example 1:
Input : Total Number of students : 20
Output:
Group 1:
101
105
109
113
117

Group 2:
102
106
110
114
118

Group 3:
103
107
111
115
119

Group 4:
104
108
112
116
120

7) Write a program to print the following output for the given input. You can assume the
string is of odd length
Eg 1: Input: 12345
Output:
1 1
2 2
3
4 4
5 5

8) Write a program to demonstrate the functionalities of static keyword.

9) Given two sorted arrays, merge them such that the elements are not repeated
Example 1:
Input: Array 1: 2,4,5,6,7,9,10,13
Array 2: 2,3,4,5,6,7,8,9,11,15
Output: Merged array: 2,3,4,5,6,7,8,9,10,11,13,15

10) Alternate sorting: Given an array of integers, rearrange the array in such a way that
the first element is first maximum and second element is first minimum.
Example: Input : {1, 2, 3, 4, 5, 6, 7}
Output: {7, 1, 6, 2, 5, 3, 4}

11) Java Program to left rotate the elements of a multidimensional array.


12) Write a program to print the number 7.50 without using String.
13) Write a program to find the area of the square
14) Write a program to find the area of the rectangle
15) Write a program to find the area of the cylinder
16) Write a program to evaluate the polynomial equation
17) Given the radius of two concentric circle, find the area of the space between the
circles.
18) Evaluate the following expression on paper and on program and understand the
difference
i) ++a-b– ii) a%b++ iii) a*=b+5 iv) x=69>>>2

19) Evaluate the following expression on paper and on program and understand the
difference
a+=a++ + ++a + –a + a–; when a=28

20) Evaluate the following expression on paper and on program and understand the
difference
x = x++ * 2 + 3 * –x;

21) Evaluate the following expression on paper and on program and understand the
difference
If int y = 10 then find int z = (++y * (y++ + 5));

22) Evaluate the following expression on paper and on program and understand the
difference
23) What is the value of x1 if x=5 ?
x1=++x – x++ + –x
24) Program to Find ASCII Value of a Character
25) Program to Compute Quotient and Remainder
26) Program to Demonstrate the Working of Keyword long
27) Program to Swap Two Numbers
28) Program to Check Whether a Number is Even or Odd
29) Program to Check Whether a Character is a Vowel or Consonant
30) Program to Find the Largest Number Among Three Numbers
31) Program to Find the Roots of a Quadratic Equation
32) Program to Check Whether a Number is Positive or Negative
33) Program to Check Whether a Character is an Alphabet or not
34) Program to Calculate the Sum of Natural Numbers and find the largest digit of the
sum.
35) Program to Find Factorial of a Number and the factorial number's sum of digits.
36) Java Program to print the elements of an array present on even position
37) Java Program to print the elements of an array present on odd position
38) Java Program to print the largest element in an array
39) Java Program to print the smallest element in an array
40) Java Program to print the number of elements present in an array
41) Java Program to copy all elements of one array into another array
42) Java Program to find the frequency of each element in the array
43) Java Program to left rotate the elements of an array
44) Java Program to print the duplicate elements of an array
45) Java Program to print the sum of all the items of the array
46) Java Program to rotate the elements of an array in the right direction
47 - 50) Write a programs to print following patterns
51) Write a program to display the number in reverse order without use of String
functions.
Eg 1: Input: 12345
Output :The number in reverse order is : 54321

52) Using Recursion reverse the string such as


Eg 1: Input: one two three
Output: three two one
Eg 2: Input: I love india
Output: india love I

53) Write a program to give the following output for the given input:
Eg 1: Input: a1b10
Output: abbbbbbbbbb
Eg: 2: Input: b3c6d15
Output: bbbccccccddddddddddddddd
The number varies from 1 to 99.

54) Write a program to sort the elements in odd positions in descending order and
elements in ascending order.
Eg 1: Input: 13,2 4,15,12,10,5
Output: 13,2,12,10,5,15,4
Eg 2: Input: 1,2,3,4,5,6,7,8,9
Output: 9,2,7,4,5,6,3,8,1
55) Write a program to print the alphabet 'C' with the stars based on the given numbers
Eg 1: Input: 4
Output:
****
*
*
****

56) Write a program to make such a pattern like a pyramid with numbers increased by 1.
Eg: Input : 10
Output:
1
23
456
7 8 9 10

57) Write a program to print the following output for the given input. You can assume
the string is of odd length
Eg 1: Input: 12345
Output:
1 5
2 4
3
2 4
1 5

58) Write a program to print the following pattern for the given input number.
Eg 1: Input: 4
Output:
********
***__***
**____**
*______*
**____**
***__***
********
59) Find if a String2 is substring of String1. If it is, return the index of the first
occurrence. else return -1.
Eg 1: Input: String 1: test123string
String 2: 123
Output: 4
Eg 2: Input: String 1: testing12
String 2: 1234
Output: -1

60) Write a program to find the sum of the series. The series will be like 1 +11 + 111 +
1111 +.. n terms.
Eg 1: Input: Input the number of terms : 5
Output :
1 + 11 + 111 + 1111 + 11111
The Sum is : 12345

Eg 2: Input: Input the number of terms : 3


Output :
1 + 11 + 111
The Sum is : 123

You might also like