Join Regular Classroom : Visit ClassroomTech

Deloitte Overall Interview Questions + Coding Solutions – codewindow.in

Hot Topics

Deloitte Solution

Technical Round

#include<stdio.h>
 
void reverseArray(int arr[], int n)
{
    int i, temp;
    for (i = 0; i < n/2; i++)
    {
        temp = arr[i];
        arr[i] = arr[n-i-1];
        arr[n-i-1] = temp;
    }
}
 
void printArray(int arr[], int size)
{
    int i;
    for (i=0; i < size; i++)
        printf("%d ", arr[i]);
    printf("\n");
}
 
int main()
{
    int arr[] = {1, 2, 3, 4, 5, 6};
    int n = 4;
 
    printf("Original array: \n");
    printArray(arr, n);
 
    reverseArray(arr, n);
 
    printf("Reversed array up to %d: \n", n);
    printArray(arr, n);
 
    return 0;
}
/*
OUTPUT - 

Original array: 
1 2 3 4 
Reversed array up to 4: 
4 3 2 1 
*/
#include<iostream> 
using namespace std;

int maxSum(int arr[],int n){
    int MAX=INT_MIN;
    int sum=0;
    
    for(int i=0;i&lt;n;i++){
        sum+=arr[i];
        MAX=max(sum,MAX);
        if(sum&lt;0){
            sum=0;
        }
    }
    return MAX;
}

int main() {
    int n;
    cout&lt;&lt;&quot;Enter the length of array:&quot;&lt;&gt;n;
    int arr[n];
    
    cout&lt;&lt;&quot;Enter the values in the array&quot;&lt;&lt;endl;
    for(int i=0;i&gt;arr[i];
    }
    
    int s=maxSum(arr,n);
    cout&lt;&lt;&quot;Maximum contiguous sum is: &quot;&lt;&lt;s;

    return 0;
}

/*
INPUT:
Enter the length of array:
8
Enter the values in the array
-2 -3 4 -1 -2 1 5 -3

OUTPUT:
Maximum contiguous sum is: 7
*/
#include<stdio.h>
 
void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
 
void bubbleSort(int arr[], int n)
{
   int i, j;
   for (i = 0; i < n-1; i++)      
       for (j = 0; j < n-i-1; j++) 
           if (arr[j] > arr[j+1])
              swap(&arr[j], &arr[j+1]);
}
 
void printArray(int arr[], int size)
{
    int i;
    for (i=0; i < size; i++)
        printf("%d ", arr[i]);
    printf("\n");
}
 
int main()
{
    int arr[] = {64, 34, 25, 12, 22, 11, 90};
    int n = sizeof(arr)/sizeof(arr[0]);
    bubbleSort(arr, n);
    printf("Sorted array: \n");
    printArray(arr, n);
    return 0;
}
/*
OUTPUT - 
Sorted array: 
11 12 22 25 34 64 90
*/
#include<iostream>
int fact(int);

int main()
{
    int n=5;
    printf("%d",fact(n));

    return 0;
}

int fact(int n){
    if(n==1){
        return 1;
    }
    
    return n*fact(n-1);
}

/*
OUTPUT:
120
*/
#include<stdio.h> 

int main() {
    int a,b;
    printf("Enter the value of a: ");
    scanf("%d",&amp;a);
    printf("Enter the value of b: ");
    scanf("%d",&amp;b);
    a=a-b;
    b=a+b;
    a=b-a;
    
    printf("After swapping the value of a is:%d\n",a);
    printf("After swapping the value of b is:%d",b);

    return 0;
}

/*
INPUT:
Enter the value of a: 5
Enter the value of b: 4

OUTPUT:
After swapping the value of a is:4
After swapping the value of b is:5
*/

      

Go through our study material. Your Job is awaiting.

Recent Posts
Categories