Vernalis Interview Questions  for  Freshers

This blog explains about Vernalis Interview Questions  for  Freshers . Some of the interview questions are discussed below .

______________________________________________________________________________

1. Create an array of integers having the numbers from 1 to 1000 .

int [] array = new int[100];

for (int a = 0; a < array.length; a++) {

array[a] = (a + 1) * 10;

}

Simple, if you have no other requirement.

Edit:

To make it almost sorted (like every 10th unsorted element), there are many ways. One, using BevynQ’s solution, can be:

Random r = new Random();

int [] array = new int[100];

for (int a = 0; a < array.length; a++) {

if ((a + 1) % 10 != 0) {

array[a] = (a + 1) * 10;

} else {

array[a] = r.nextInt(1000);

}

}

_______________________________________________________________________________________

2 . Write a program array of integers get input from 1 to 1000 .

Let’s move to our final program:-

1.  #include<stdio.h>

2.

3.  // For demonstration purpose I used extra variable ‘len’

4.  // but you can replace this variable with 1000

5.  const int len = 5;

6.

7.  void findSum(char str1[], char str2[])

8.  {

9.

10.

11.    int carry = 0, i;

12.

13.    // Adding 1 to len of sum array[], to

14.    // handle the last carry

15.

16.    int sum[len+1];

17.

18.    sum[0] = 0;

19.

20.    for (i=len-1; i >= 0; –i)

21.    {

22.

23.        sum[i+1] = (str1[i]-‘0’)+(str2[i]-‘0’) + carry;

24.

25.        // Calculate carry for next step

26.        carry = sum[i+1] / 10;

27.

28.        sum[i+1] %= 10;

29.    }

30.

31.    // If carry still there, Add it to sum[] array

32.    // and initialize i according to it

33.        if (carry)

34.        sum[0] = carry, i = 0;

35.    else

36.        i = 1;

37.

38.

39.

40.        for(; i <= len; ++i)

41.               printf(“%d”,sum[i]);

42.

43.   return;

44. }

45.

46.// Driver code

47.int main()

48.{

49.    char str1[] = “93234”;

50.    char str2[] = “28745”;

51.

52.    findSum(str1,str2);

53.

54.    return 0;

55. }

Output: 121979

_______________________________________________________________________________

3. Create two function having increment / decrement any operation with no return statement .

• Increment operators are used to increase the value of the variable by one and decrement operators are used to decrease the value of the variable by one in C programs.
• Syntax:
Increment operator: ++var_name; (or) var_name++;
Decrement operator: – -var_name; (or) var_name – -;
• Example:
Increment operator :  ++ i ;    i ++ ;
Decrement operator :  – – i ;   i – – ;

EXAMPLE PROGRAM FOR INCREMENT OPERATORS IN C:

In this program, value of “i” is incremented one by one from 1 up to 9 using “i++” operator and output is displayed as “1 2 3 4 5 6 7 8 9”.

//Example for increment operators

#include <stdio.h>

int main()

{

int i=1;

while(i<10)

{

printf(“%d “,i);

i++;

OUTPUT:

 1 2 3 4 5 6 7 8 9

_______________________________________________________________________________

EXAMPLE PROGRAM FOR DECREMENT OPERATORS IN C :

In this program, value of “I” is decremented one by one from 20 up to 11 using “i–” operator and output is displayed as “20 19 18 17 16 15 14 13 12 11”.

 //Example for decrement operators   #include int main() {     int i=20;     while(i>10)     {          printf(“%d “,i);          i–;     }     }

COMPILE & RUN

OUTPUT:

 20 19 18 17 16 15 14 13 12 11

_______________________________________________________________________________