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

Wednesday, 19 June 2019

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