Wipro Coding Questions Asked In Online Test.

Wipro Coding Questions Asked In Online Test.

Here is the list of most frequently asked Coding questions, You just need to practice these kinds of questions to crack Wipro coding test.

To prepare for the coding test of Wipro, please practice coding questions in hacker rank, leetcode, Code chef.

It will help you in other companies coding test too. So start practicing coding examples.

Wipro Coding Question

1) Find the distinct elements in a given array. (Assume size of an array n<=20)

Sample Input:

  • 9= Array Size.
  • 2 3 4 5 6 1 2 3 4 = Array Elements.

Sample Output:

  • 2 3 4 5 6 1

Code:

// C program to print all distinct elements in a given array
#include
void distict_elements(int a[], int n);
int main()
{
int size_array, i, arr[20];
// Get the array size
scanf(“%d”, &size_array)
// Get the array elements
for(i=0; i<size_array; i++)
{
scanf(“%d”, &arr[i]);
}
// Function call to print the distinct elements in an array
distict_elements(arr, size_array);
return 0;
}
void distict_elements(int a[], int n)
{
int i, j;
// Pick all elements one by one
for (i=0; i<n; i++)
{
// Check if the picked element is already printed
for (j=0; j<i; j++)
{
if (a[i] == a[j])
break;
}
// If not printed earlier, then print it
if (i == j)
printf(“%d “, a[i]);
} }

2. Parenthesis checker: Check whether the given expression is valid or not(only parenthesis symbol).

Test Case: 1 
Input: “(( ))”
Output: Valid 
Test Case: 2 
Input: “()(“ 
Output: Invalid
int top = -1; char stack[100]; void push(char);
void pop(); void find_top(); void main()
{
int i;
char a[100];
scanf(“%s”, &a);
for (i = 0; a[i] != ‘\0’; i++)
{
if (a[i] == ‘(‘)
push(a[i]);
else if (a[i] == ‘)’)
pop();
}
find_top();
}
// to push elements in stack void push(char a)
{
top++; stack[top] = a;
}
// to pop elements from stack void pop()
{
if (top == -1)
{
printf(“Invalid”);
exit(0);
}
else
top–;
}
// to find top element of stack

void find_top()
{
if (top == -1) printf(“Valid”); else

printf(“Invalid”);
}

3. Program to sort array in ascending & descending order.

Input:
5
8 6 2 9 7

2 6 7 8 9
9 8 7 6 2

// C program to sort the given array elements in ascending and descending order #include
int main(void)
{
int arr[10], i=0, j=0, size, temp;
// Get the size of an array
scanf (“%d”, &size);
// Get the array elements as an input for (i = 0; i <size; i++)
{
scanf (“%d”, &arr[i]);
}
// Sorting elements in ascending order for (j=0 ; j<(size-1) ; j++)
{
for (i=0 ; i<(size-1) ; i++)
{
if (arr[i+1] < arr[i])
{
temp = arr[i]; arr[i] = arr[i + 1]; arr[i + 1] = temp;
}

}
}
// Print the elements from index value 0 to (size-1) –> ascending order for (i=0 ; i	{
printf (“%d “, arr[i]);
}
printf(“\n”);
order
// Print the elements from the index value (size-1) to 0 –> descending

for (i=size-1; i>=0 ; i–)
{
printf (“%d “, arr[i]);
}
return 0;
}

4. Sort first half in ascending and second half in descending order.

Input:
8
8 1 7 4 6 2 3 5
1 2 3 5 8 7 6 5

Algorithm:

  • Sort the given array. 
  • Run a loop up to half the length of the array and print the elements of the sorted array.
  • Run a loop from the last index of the array to the middle of the array and print the elements in reverse order

#include  
void sorting_elements(int arr[], int n); void display(int arr[], int n);
int main()
{
int size, arr[20], i; scanf(“%d”, &size); for(i=0; i<size; i++)
{
scanf(“%d”, &arr[i]);
}
display(arr, size); return 0;
}
// Sort the elements in the ascending order void sorting_elements(int arr[], int n)
{
int i,j,temp;
for (j=0 ; j<(n-1) ; j++)
{
for (i=0 ; i<(n-1) ; i++)
{
if (arr[i+1] < arr[i])
{
temp = arr[i]; arr[i] = arr[i + 1]; arr[i + 1] = temp;
}
}
}
}
// Display the sorted elements void display(int arr[], int n)
{
sorting_elements(arr, n); int i, j

// Print the first half as such (i.e. from index 0 to midlle) for (i=0; i<n/2; i++)
{
printf(“%d “, arr[i]);
}

// Print the second half in the reverse order (i.e. from n-1 to midlle) for (j=n-1; j>=n/2; j–)
{
printf(“%d “, arr[j]);
}
}


5.  Print the following pattern

Input
3 4

3
44
555
6666
555
44
3
#include int main()
{
int i,j,s,N,count=0;
 scanf(“%d%d”,&s,&N); 
for(i=s;count<4;count++)
{
for(j=0;j<count+1;j++)

printf(“%d”,i);
printf(“\n”);
i=i+1;
}
for(i=s+N-2;count>0;count–)
{
for(j=0;j<count-1;j++)
printf(“%d”,i);
printf(“\n”);
i=i-1;
}
return 0;
}

6. Print the following Pattern.

Input:
4

1
2*3
4*5*6
7*8*9*10
7*8*9*10
4*5*6
2*3
1

#include int main() {
int i,j,count=1,n; 
printf(“Enter a number\n”);
scanf(“%d”,&n); 
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
if(j<i) {
printf(“%d*”,count++); 
}
else printf(“%d”,count++);
{
printf(“\n”);
}	
}
count=count-n; for(i=n;i>=1;i–)
{	
for(j=1;j<=i;j++)
{
if(j<i) printf(“%d*”,count++); else printf(“%d”,count++);
}
count=(count+1)-2*i;
printf(“\n”);
}
return 0;
}

Wipro Test Preparation Materials

Leave a Comment