Wipro Coding Questions

Wipro Coding Questions : This section focuses on Wipro coding questions with Answers. These programming questions are asked in previous Wipro Exams and will help you to prepare for upcoming Wipro exam.


Wipro Coding Question - 1

Problem Statement: You are required to count the number of words in a sentence.
You are required to pass all the test cases

Test Cases : Input : welcome to the world
Output : 4

#include <stdio.h>
#include <string.h>
int main()
{
    char a[100];
    int i=0,count;
    printf("Enter the string : ");
    scanf("%[^\n]s",a);
    if(a[0]==' ')
    {
        count = 0;
    }
    else
    {
        count = 1;
    }
    while(a[i]!='\0')
    {
        if(a[i]==' ' && a[i+1]!=' ' && a[i+1]!='\0')
        {
            count = count + 1;
        }
        i++;
    }
    printf("%d",count);
}

Wipro Coding Question - 2

Problem Statement:
First of all you need to input a whole sentence in the string, then you need to enter the target word.
As an output you need to find the number of times that particular target word is repeated in the sentence.
Test Cases:
Input: welcome world to the new world
world
Expected Output: 2

#include <stdio.h>
#include <string.h>
int main()
{
    char str[100];
    char toSearch[100];
    int count;
    int i, j, found;
    int stringLen, searchLen;
    
    scanf("%[^\n]s",str);
    scanf("%s",toSearch);
    
    stringLen = strlen(str);      
    searchLen = strlen(toSearch); 
    count = 0;
    for(i=0; i <= stringLen-searchLen; i++)
    {
        found = 1;
        for(j=0; j<searchLen; j++)
        {
            if(str[i + j] != toSearch[j])
            {
                found = 0;
                break;
            }
        }
        if(found == 1)
        {
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

Wipro Coding Question - 3

Problem Statement: You are given a number, and you have to extract the key by finding the difference between the sum of the even and odd numbers of the input.

Test Case:
Input : 24319587
Output : 11
Explanation : odd terms : 3 + 1 + 9 + 5 + 7 = 25
even terms : 2 + 4 + 8 = 14
output : 11 (25-14)

#include <stdio.h>
int main()
{
    int n;
    int r, odd=0, even=0, key;
    scanf("%d",&n);
    while(n!=0)
    {
        r = n%10;
        if(r%2==0)
        {
            even = even + r;
        }
        else
        {
            odd = odd + r;
        }
        n =  n/10;
    }
    if(odd>even)
    {
        key = odd - even;
    }
    else
    {
        key = even - odd;
    }
    printf("%d",key);
}

Other Programming Questions


1. Program to reverse a string.
2. Program to check whether the given number is palindrome or not.
3. Program to check whether the given number is prime number or not.
4. Program to check whether the given year is leap year or not.
5. Program to print fibonacci series.
6. Program to find GCD of two numbers.
7. Program to find factorial of a number.
8. Program to check armstrong number.
9. Program to swap two numbers without using temporary variable.
10. Program to check whether the number is even or odd.