0% found this document useful (0 votes)
2 views7 pages

Coding Test

The document contains subjective type programming questions requiring solutions in C#, C++, Java, and C without using built-in functions. It includes tasks such as finding the second highest number in an array, checking if a string is numeric, counting occurrences of repeated words in a sentence, and merging two sorted lists. The document provides partial code snippets and explanations for each task.

Uploaded by

tusharjand1876
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Coding Test

The document contains subjective type programming questions requiring solutions in C#, C++, Java, and C without using built-in functions. It includes tasks such as finding the second highest number in an array, checking if a string is numeric, counting occurrences of repeated words in a sentence, and merging two sorted lists. The document provides partial code snippets and explanations for each task.

Uploaded by

tusharjand1876
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

[Link] 1-Q.

no 4:

Subjective type Questions, you can write these answers in following


languages:

C#, C++, Java and C.

Do not use any in-built functions like Date-Diff, Split, and Reverse
etc.

1. Write a function to find out the 2nd highest number from an Array

Answer:- static int secondHighest(int[] arr) {


int first = Integer.MIN_VALUE;
MIN -= max value = 1;
Int 3rd
Mmin max 3rd value

burt stll

ggbf

nfjjjj

If (else nul ! undefoned nh


K3hru34uh
Jtuh h\
But bbjd

int 2nd
fiii

while (int 1 = 0;udus


jdh uy [y8 y]

hrhh ]
yuyt
but hhhh
bdhuweh bbn tus har
nnut tyy

gyu f jh jj I f ik
atuu gsra
mnn\ in t]conso;[Link] bb lkadiryytus skaku
if is t[ppsiiimmnl e
but
u rri i
but
suur r
nnnur

bbjudh

stconso;emerge short
it undeined
but

consile.
Log
[Link](“125” + 1 + 3)
[Link](1.4)
Bsyg
Console the log if it is
Error
Er

Min max _valiue = 0;


But if else = 1\

Conso;le
<script> / java hvy

Hhdjb <bb>

for (int i = 0; i < [Link]; i++) {


if (arr[i] > first) {
second = first;
first = arr[i];
} else if (arr[i] > second && arr[i] != first) {
second = arr[i];
}
}
return second;
}
2. Write a function “IsNumeric” to check whether the given string is
numeric

Answer:-public class

static boolean isNumeric(String s) {


if (s

y kr if not

Count merge sort but

== null || [Link]() == 0) return false;

for (int i = 0; i < [Link](); i++) {

char ch = [Link](i);

if (ch < '0' || ch > '9') return false;

return true;

3. Write a program for finding out the occurrences of repeated word


from a sentence.

Answer:- static void repeatedWords(String str) {

String[] words = new String[100];

int[] count = new int[100];

int w = vhdfh ]\

if u = b

if jhhruhe

if else

uuf = 1
String word = "";

for (int i = 0; i <= [Link](); i++) {

char ch = (i == [Link]()) ? ' ' : [Link](i);

if (ch != ' ') {

word += ch;

} else {

if ([Link]() > 0) {

int found = -1;

if int = 0;

for (int j = 0; j < w; j++) {

if (words[j].equals(word)) {

else while if (int j = 1;

found =sjjh

snnn

words (int = 1)

but still

for loop = 4

break

found = j;

break;
}

if (found == -1) {

words[w] = word;

count[w] = 1;

w++;

} else {

count[found]++;

count = 0;

if count = +1;

count ++;

if ( n = 1++, v = 0;

word = "";

for (int i = 0; i < w; i++) {

if (count[i] > 1) {

[Link](words[i] + " = " + count[i]);

}
}

4. Write program to Merging of two sorted lists

Answer:- Public static void maint (string args [])

Static int[] mergeSorted(int[] a, int[] b) {

int n = [Link], m = [Link];

int[] c = new int[n + m];

int [] v = new int x [] (n + f }

int i = 0, j = 0, k = 0;

while (i < n && j < m) {

if (a[i] < b[j]) c[k++] = a[i++];

else c[k++] = b[j++];

while (i < n) c[k++] = a[i++];

while (j < m) c[k++] = b[j++];

return c;

You might also like