Interviews Questions, Algorithms, Aptitude, C Interview Program, C Theory Question, Aptitude Tricks, Test Series,

Sunday 30 June 2019

The Interview Question Today#128(01-7-19)


Aptitude Hack#128(1-7-19)

Question:

Two goods train each 500 m long, are running in opposite directions on parallel tracks. Their speeds are 45 km/hr and 30 km/hr respectively. Find the time taken by the slower train to pass the driver of the faster one.

A. 12 sec
B.    24 sec
C. 48 sec
D. 60 sec


Aptitude Hack#127(30-6-19)

Question:

On 8th Feb 2005, it was Tuesday. What was the day of the week on 8th Feb 2004?

A. Tuesday
B. Monday
C. Sunday
D. Wednesday


The Interview Question Today#127(30-6-19)


Saturday 29 June 2019

The Interview Question Today#126(29-6-19)


Aptitude Hack#126(29-6-19)

Question:



           A. 0

           B. 2

           C. 3

           D. 5


Friday 28 June 2019

The Interview Question Today#125(28-6-19)


Aptitude Hack#125(28-6-19)

Question:

How many of the following numbers are divisible by 132?

264, 396, 462, 792, 968, 2178, 5184, 6336

A. 4
B. 5
C. 6
D. 7


Monday 24 June 2019

Aptitude Hack#124(27-6-19)

Question:

How many seconds will a 500-metre long train take to cross a man walking with a speed of 3 km/hr in the direction of the moving train if the speed of the train is 63 km/hr?

A. 25
B. 30
C. 40
D. 45



Aptitude Hack#123(26-6-19)

Question:

A bag contains 6 black and 8 white balls. One ball is drawn at random. What is the probability that the ball drawn is white?

A.  3/4
B.  4/7
C.  1/8
D.  3/7


Aptitude Hack#122(25-6-19)

Question:


A.    2
   B.     4   
  C. 295
  D. 643



The Interview Question Today#124(27-6-19)


The Interview Question Today#123(26-6-19)


The Interview Question Today#122(25-6-19)


Aptitude Hack#121(24-6-19)

Question:

Free notebooks were distributed equally among children of a class. The number of notebooks each child got was one-eighth of the number of children. Had the number of children been half, each child would have got 16 notebooks. Total how many notebooks were distributed?

A. 256
B. 432
C. 512
D. 640
E. None of these


The Interview Question Today#121(24-6-19)


Sunday 23 June 2019

The Interview Question Today#120(23-6-19)


Aptitude Hack#120(23-6-19)

Question:
A bag contains 4 white, 5 red, and 6 blue balls. Three balls are drawn at random from the bag. The probability that all of them are red is:

A.1/22

B.3/22

C.2/91

D.2/77


Saturday 22 June 2019

Aptitude Hack#119(22-6-19)

Question:

A fires 5 shots to B's 3 but A kills only once in 3 shots while B kills once in 2 shots. When B has missed 27 times, A has killed:

A. 30 birds
B. 60 birds
C. 72 birds
D. 90 birds



Friday 21 June 2019

Aptitude Hack#118(21-6-19)

Question:

What will be the compound interest on a sum of Rs 25,000 after 3 years at the rate of 12 p.c.p.a.?

A. Rs. 9000.30
B. Rs. 9720
C. Rs. 10123.20
D. Rs. 10483.20
E. None of these



Thursday 20 June 2019

Aptitude Hack#117(20-6-19)

Question:

If A = x% of y and B = y% of x, then which of the following is true?

A)A is smaller than B.

B)A is greater than B

C)Relationship between A and B cannot be determined.

D)If x is smaller than y, then A is greater than B.

E)None of these


Wednesday 19 June 2019

Aptitude Hack#116(19-6-19)

Question:

Find the next term.

5, 10, 13, 26, 29, 58, 61,122, (....)

A.   120
B.   124
C.   125
D.   128

Anagram or not.

Question:

















Approach:


Step 1: Check Both the String For Equal Length.
if equal then continue, else print Not Anagram.

Step 2: Take A Array for All the Alphabets
And Calculate the no of times that  present in the both String

Step 3: Comparing the Array if equal then Anagram 
Else not Anagram.



Solution:

#include<stdio.h>
int main()
{
char a[10],b[10];
int i,j,k,m,n,z[26]={0},y[26]={0},flag,c,d;
printf("enter the 2 string");
scanf("%s %s",a,b);
if(strlen(a)!=strlen(b))
 printf("not an anagram");
else
{
    k=0;
while(k!=26)
{
n=1;
m=1;
for(i=0;i<strlen(a);i++)
{
c=(int)a[i]-97;
d=(int)b[i]-97;
if(k==d)
{
  y[k]=m++;

}

 if(k==c)
  {
           z[k]=n++;
}
}
k++;
}

for(j=0;j<26;j++)
{
if(z[j]!=y[j]){
printf("Not anagram");
return 0;
}
}
    printf("Anagram");
}
return 0;
}


//Credits Rakshita.

Tuesday 18 June 2019

Aptitude Hack#115(18-6-19)

Question:

Find the odd man out.

396, 462, 572, 427, 671, 264

A. 396
B. 427
C. 671
D. 264

Write a program print the pattern { 1,1,2,3,4,9,8,27,16,81,32,243.}

Question:









Credits: Swathi.

#include<stdio.h>
void main(){
     int n;
//As we are taking it in pair.
printf("Enter the limit in pairs:"); 
scanf("%d",&n);
     int even=1,odd=1;
   int i;
for(i=0;i<n;i++)
{
printf("%d,%d,",even,odd);
even*=2;
odd*=3;
}
}

The Interview Question Today#115( 18-6-19)


Monday 17 June 2019

Aptitude Hack#114(17-6-19)

Question:

In a 100 m race, A beats B by 10 m and C by 13 m. In a race of 180 m, B will beat C by:

A. 5.4 m
B. 4.5 m
C. 5 m
D. 6 m

Sunday 16 June 2019

Aptitude Hack#113(16-8-19)

Question:

Six bells commence tolling together and toll at intervals of 2, 4, 6, 8 10 and 12 seconds respectively. In 30 minutes, how many times do they toll together?

A. 4
B. 10
C. 15
D. 16

Saturday 15 June 2019

Aptitude Hack#112(15-6-19)

Question:

The cube root of .000216 is:

A) 0.6
B) 0.06
C) 0.77
D) 0.064


Friday 14 June 2019

Aptitude Hack#111(14-6-19)

Question:

Today is Monday. After 61 days, it will be:

A. Wednesday
B. Saturday
C. Tuesday
D. Thursday



Thursday 13 June 2019

Aptitude Hack#110(13-6-19)

Question:

Two pipes A and B together can fill a cistern in 4 hours. Had they been opened separately, then B would have taken 6 hours more than A to fill the cistern. How much time will be taken by A to fill the cistern separately?

A. 1 hour
B. 2 hours
C.    6 hours
D. 8 hours


Wednesday 12 June 2019

Tricky Interview#1 Solution

Question:
W A C Program That Prints All The vowels Given In String Without Using IF and Break Statements In program?

Solution:
//Credits Gaurav and Swathi H I
#include<stdio.h>
#include<stdlib.h>
main(){
char str[10];
scanf("%s",str);
int i=0;
while(str[i]!='\0'){
(str[i]=='a'|str[i]=='e'|str[i]=='i'|str[i]=='o'|str[i]=='u')? printf("%c",str[i]):printf("");

i++;
}
}


Alternative Solution:
//JavaAbhigyan
#include<stdio.h>
#include<stdlib.h>
main()
{
    char str[10],c;
    scanf("%s",str);
    int i=0;
    while((c=str[i])!='\0')
    {
        switch(c)
        {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            printf("%c",c);
        }
        i++;
    }

}

Aptitude Hack#109(12-6-19)

Question:

A man buys eggs at 2 for Rs 1 and an equal number at 3 for Rs 2 and sells the whole at 5 for Rs 3. What's the percentage of gain or loss?

A) 27/7 % gain
B) 16/7 % loss
C) 23/7  % loss
D) 20/7 % gain


Tuesday 11 June 2019

Aptitude Hack#108(11-6-19)

Question:

A drinks machine offers three selections - Tea, Coffee or Random but the machine has been wired up wrongly so that each button does not give what it claims. If each drink costs 50p, how much minimum money do you have to put into the machine to work out which button gives which selection?

(A) 5 rupees
(B) 10 rupees
(C) 25 rupees
(D) Infinity


Monday 10 June 2019

Tricky Interview#6

Question:

WAC PROGRAM THAT GIVES THE SIZE OF STRING WITHOUT USING ANY FUNCTION(PRE DEFINED OR USER DEFINED), NO LOOPS AND NO RECURSION.

Solution:

#include<stdio.h>
void main()
{
int a[100],n;
printf("Enter the String\n");
scanf("%s",a);
n=printf("%s\n",a);
printf("%d",n-1);
}

Tricky Interview#5

Question:
How would you write a C program to print 1 to 100 without loop, recursion, or goto?

Solution:

#include<stdio.h>

void hundred() { static int i=1; printf("%d\n",i++); }

void  twenty(){ hundred(),hundred(),hundred(),hundred(),hundred(); }

void four() { twenty(),twenty(),twenty(),twenty(),twenty(); }

int main()
{
    four(),four(),four(),four();

}

Puzzle #3

Question:

12, X, 144, 441…….


 Find X?


Aptitude Hack#107(10-6-19)

Question:

If there are 51 rupees consisting of coins of 1 rupee, 50 paise, and 25 paise. Number
of 50 paise coin is double that of number of 1 rupee coin and four times that of 25
paise, and then what is the number of 50 paise coins in the collection.

(A)48
(B)51
(C)12
(D)24



Sunday 9 June 2019

Aptitude Hack#106(9-6-19)

Question:

Mr. Das decided to walk down the escalator of a mall. He found that if he walks down
26 steps, he requires 30seconds to reach the bottom. However, if he steps down 34
stair He would only require 18 seconds to get to the bottom. If the time is measured
from the moment the top step begins to descend to the time he steps off the last step
at the bottom, find out the height of the stairway insteps?

(A)46
(B)35
(C) 56
(D)55

Saturday 8 June 2019

Aptitude Hack#105(8-6-19)

Question:

In a family 7 children don't eat spinach, 6 don't eat the carrot, 5 don't eat beans, 4 don't eat spinach & carrots, 3 don't eat carrot & beans, 2 don't eat beans & spinach. One doesn't eat all 3. 
Find the no. of children.

(A)19
(B)9
(C)10
(D)11

Friday 7 June 2019

Aptitude Hack#104(7-6-19)

Question:

The difference between simple and compound interests compounded annually on a certain sum of money for 2 years at 4% per annum is Re. 1.
 The sum (in Rs.) is:

A. 625
B. 630
C. 640
D. 650


Thursday 6 June 2019

Aptitude Hack#103(6-6-19)

 Question:

If the ratio of the areas of two squares is 1:4, the ratio of their perimeters is

A. 1:2
B. 1:4
C. 1:6
D. 1:8


Wednesday 5 June 2019

Aptitude Hack#102(5-6-19)

Question:

Ram and Hari started from A and B, towards B and A at 6.00 am and 7.00 am respectively. They meet each other at 9.00 am and continued towards their respective destinations. Ram reaching B turns back and catches up with Hari before Hari reaches A at 11.00 am. At what time will Hari reach A.

 (a) 7.00 pm
 (b) 4.00 pm
 (c) 5.00 pm
 (d) 6.00 pm

Aptitude Trick#4(Square of two digit number)

Square of two digit number using Formule 1

Consider An Example

Example: Square of 26

  • Step 1:

           we separate the number into
            two parts(a & b)



  • Step 2: Now using formulae

                 a2| 2ab | b

                we get 2*2 | 2*2*6 | 6*6



Answer = 676

Aptitude Trick#3 (Square of three digit number)

Square of three digit number

Consider An Example

Example: Square of 206

  • Step 1:

           we separate the number into
            two parts(a & b)



  • Step 2: Now using formulae

                 a2| 2ab | b

                we get 20*20 | 2*20*6 | 6*6

Answer = 42436

Tuesday 4 June 2019

Aptitude Hack#101(4-6-19)

Question:

A tin of oil was 4/5 full.when 6 bottles of oil were taken out and four bottles of oil were poured into it, it was ¾ full. how many bottles of oil can the tin contain?
  
 A )   35
 B )   50
 C )   40
 D )   45

Monday 3 June 2019

Aptitude Hack#100(3-6-19)

Question:

A person has the capability of thinking 100 lines of code in five minutes and can type 100 lines of code in 10 minutes. He takes a break for five minutes after every ten minutes. How many lines of codes will he complete typing after an hour? 

(a) 100
(b) 250
(c) 350
(d) 600

Sunday 2 June 2019

Aptitude Hack#99 (2-6-19)

Question:

If 1/3rd of a number subtracted from. Of that number, then the difference is 10 more Than 1/7th of the same number. How much is that number?

   A )   420
   B )   400
   C )   405
   D )   415



Program for Shell Sort in C


Shell short is an improved and efficient version of the insertion sort.

In this algorithm, we sort the pair of elements that are far apart by gap h.
 The process is repeated by reducing h until it becomes 1.


Shell Sort

Algorithm

Following is the algorithm for shell sort.

Step 1 − Initialize the value of h

Step 2 − Divide the list into smaller 
               sub-list of equal interval h

Step 3 − Sort these sub-lists using insertion sort


Step 4 − Repeat until the complete list is sorted


Program for Shell Sort in C

#include<stdio.h>

void sort(int a[],int n)
{
int gap,i,j,temp;

for(gap=n/2;gap>0;gap/=2)
{
for(i=gap;i<n;i+=1)
{
temp=a[i];

for(j=i;j>=gap&&a[j-gap]>temp;j-=gap)

     a[j]=a[j-gap];

  a[j]=temp;

}

}

}

int main()
{
int a[20],i,n;

printf("Enter number of elements:");

scanf("%d",&n);

printf("Enter array elements:\n");

for(i=0;i<n;++i)
{
scanf("%d",&a[i]);
} sort(a,n);

printf("\nArray after shell sort:\n");

for(i=0;i<n;++i)
printf("%d ",a[i]);

    return 0;
}


Output

Enter number of elements:5
Enter array elements:
56 7 2 9 12

Array after shell sort:
2 7 9 12 56

C program to print the truth table for XY+Z


C program to print the truth table for XY+Z  

#include<stdio.h>
#include<conio.h>

void main()
{
int x,y,z;
clrscr(); //to clear the screen
printf(“XtYtZtXY+Z”);

for(x=0;x<=1;++x)
for(y=0;y<=1;++y)
for(z=0;z<=1;++z)
{
if(x*y+z==2)
printf(“nn%dt%dt%dt1”,x,y,z);
else
printf(“nn%dt%dt%dt%d”,x,y,z,x*y+z);
}
}

OUTPUT:


Print “javaabhigyan” with empty main() in C


Write a program that prints “javaabhigyan” with empty main() function.You are not allowed to write anything in main().


1.) One way of doing this is to apply GCC constructor attribute to a function so that it executes before main()

#include <stdio.h> 
  
/* Apply the constructor attribute to myStartupFun()  
   so that it is executed before main() */
void myStartupFun(void) __attribute__((constructor)); 
  
/* implementation of myStartupFun */
void myStartupFun(void) 

    printf("javaabhigyan"); 

  
int main() 



Output:
javaabhigyan


2.) In linux, just override the default definition of _start() function so that it would work as a custom startup code. See this article to understand more.

#include <stdio.h> 
#include <stdlib.h> 
  
int main(void) 


  
// _start() function 
void _start(void) 

    printf("javaabhigyan"); 
  
    // Call main() function 
    int var = main(); 
    exit(var); 


Now compile this by following command

gcc -nostartfiles -o file file.c

Output:
javaabhigyan

Compute average of two numbers without overflow


Given two numbers, a and b. Compute the average of the two numbers.

The well know formula (a + b) / 2 may fail at the following case :
If, a = b = (2^31) – 1; i.e. INT_MAX.
Now, (a+b) will cause overflow and hence formula (a + b) / 2 wont work

Improved Formula that does not cause overflow :

Average = (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2)


Below is the implementation :

// C code to compute average of two numbers 
#include <stdio.h>
#define INT_MAX 2147483647
// Function to compute average of two numbers 
int compute_average(int a, int b) 

    return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); 

  
  int main() 

    // Assigning maximum integer value 
    int a = INT_MAX, b = INT_MAX; 
  
    // Average of two equal numbers is the same number 
    printf("Actual average : %d\n",INT_MAX); 
  
    // Function to get the average of 2 numbers 
    printf("Computed average : %d",compute_average(a, b)); 
  
    return 0; 


Output:
Actual average: 2147483647
Computed average: 2147483647