Wednesday, 31 July 2019
Tuesday, 30 July 2019
Monday, 29 July 2019
Sunday, 28 July 2019
Saturday, 27 July 2019
Friday, 26 July 2019
Thursday, 25 July 2019
Wednesday, 24 July 2019
Tuesday, 23 July 2019
Monday, 22 July 2019
Sunday, 21 July 2019
Important Points and Shortcuts for Clock problems
- Clock formula: 11/12. This is a very important point for solving aptitude questions on clocks.
- As minute hand covers one full circle i.e. 360 degrees in one hour, that means it travels 360/60 = 6 degrees/min.
- An hour hand covers one part of the 12 major parts of the circle which means it covers 360/12 = 30 degrees in one hour i.e. it travels 30/60 = 1/2 degree per min.
- Now, the relative speed of the minute hand is 6 – 1/2 = 11/2 or 5.5 degrees. This 11/2 degrees will be useful in finding the angle between the two hands of the clock.
- The complete circle has a total of 360 degrees and in terms of minute spaces, it has been divided into 60 minutes spaces, which means each minute space represents 360/60 = 6 degrees.
- The complete circle has been divided into 12 equal bigger units also, which we call as hours. This further implies that every hour space covers a total of 360/12 = 30 degrees.
- The hour hand and minute hand meet once every hour. But in a 12 hour period, they meet 11 times.
- There is one angle of 180 degrees in every hour i.e. both the hands are in the straight line in the opposite direction, but in a twelve-hour period, it happens 11 times.
- There are 2 right angles every hour, but in a 12 hour period, there are 22 such angles.
- If the two hands are moving at the normal speeds, they should meet after every 65 5/11 min.
- Clock Aptitude Tricks -Short Cut - Between x and (x + 1) O’clock, the 2 hands will be ‘t’ min apart at (5x t) 12/11 past x.
Saturday, 20 July 2019
Friday, 19 July 2019
Thursday, 18 July 2019
Wednesday, 17 July 2019
Tuesday, 16 July 2019
Monday, 15 July 2019
Sunday, 14 July 2019
Saturday, 13 July 2019
Friday, 12 July 2019
Thursday, 11 July 2019
Wednesday, 10 July 2019
Tuesday, 9 July 2019
Monday, 8 July 2019
Sunday, 7 July 2019
Saturday, 6 July 2019
Alphabet Pattern
Question:
Solution:
//Method 1:
#include<stdio.h>
void main()
{
int no_of_lines, alphabet = 65, i, count, j;
printf("\nenter the number of lines you want to print\t:");
scanf("%d",&no_of_lines);
count=2*no_of_lines;
for(j=0;j<no_of_lines;j++)
{
if(j==0)
{
printf("\n\n");
for(i=0;i<count;i++)
{
if(i<no_of_lines)
{
printf(" %c", alphabet++);
}
else if(i == no_of_lines)
{
alphabet--;
}
else
{
printf(" %c",--alphabet);
}
}
}
else
{
printf("\n");
for(i=0;i<count-2*j;i++)
{
if(i<no_of_lines-j)
{
printf(" %c", alphabet++);
}
else
{
printf(" %c",--alphabet);
}
}
}
}
}
Method 3:
//Shravya Shetty
import java.io.*;
public class test {
public static void main(String agrs[]) throws IOException{
char ch;
int i=0,m;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("enter the number of lines you want to print :");
int n=Integer.parseInt(br.readLine());
m=n;
char arr[]=new char[n+1];
while(n!=0) {
i=0;
for(ch='A' ;ch<('A'+n);ch++)
{
System.out.print(ch+" ");
arr[i++]=ch;
}
for(i=(n-1);i>=0;i--)
{
if(i==(m-1)) {
continue;
}
System.out.print(arr[i]+" ");
}
System.out.println();
n--;
}
}
}
Solution:
//Method 1:
#include<stdio.h>
void main()
{
int no_of_lines, alphabet = 65, i, count, j;
printf("\nenter the number of lines you want to print\t:");
scanf("%d",&no_of_lines);
count=2*no_of_lines;
for(j=0;j<no_of_lines;j++)
{
if(j==0)
{
printf("\n\n");
for(i=0;i<count;i++)
{
if(i<no_of_lines)
{
printf(" %c", alphabet++);
}
else if(i == no_of_lines)
{
alphabet--;
}
else
{
printf(" %c",--alphabet);
}
}
}
else
{
printf("\n");
for(i=0;i<count-2*j;i++)
{
if(i<no_of_lines-j)
{
printf(" %c", alphabet++);
}
else
{
printf(" %c",--alphabet);
}
}
}
}
}
//Method 2:
//Credit Rakshita
#include<stdio.h>
int main()
{
int n,i,j=1,m;
char alpha;
printf("enter a number");
scanf("%d",&n);
m=n;
for(i=1;i<=n;i++)
{
alpha='A';
printf("%c",alpha);
for(j=1;j<m;j++)
{
alpha=alpha+1;
printf("%c",alpha);
}
if(j>=m)
{
if(m!=n)
printf("%c",alpha);
while(j!=1)
{
alpha=alpha-1;
printf("%c",alpha);
j--;
}
}
printf("\n");
m--;
}
return 0;
}
Method 3:
//Shravya Shetty
import java.io.*;
public class test {
public static void main(String agrs[]) throws IOException{
char ch;
int i=0,m;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.print("enter the number of lines you want to print :");
int n=Integer.parseInt(br.readLine());
m=n;
char arr[]=new char[n+1];
while(n!=0) {
i=0;
for(ch='A' ;ch<('A'+n);ch++)
{
System.out.print(ch+" ");
arr[i++]=ch;
}
for(i=(n-1);i>=0;i--)
{
if(i==(m-1)) {
continue;
}
System.out.print(arr[i]+" ");
}
System.out.println();
n--;
}
}
}
Swap two Variable Without Using third Variable
Question:
Solution:
#include<stdio.h>
int main(){
int a=5,b=10;
//process one
//Credits: Arjun and Shravya Kodli.
a=b+a;
b=a-b;
a=a-b;
printf("a= %d b= %d",a,b);
//process two
a=5;
b=10;
a=a+b-(b=a);
printf("\na= %d b= %d",a,b);
//process three
a=5;
b=10;
a=a^b;
b=a^b;
a=b^a;
printf("\na= %d b= %d",a,b);
//process four
a=5;
b=10;
a=b-~a-1;
b=a+~b+1;
a=a+~b+1;
printf("\na= %d b= %d",a,b);
//process five
a=5,
b=10;
a=b+a,b=a-b,a=a-b;
printf("\na= %d b= %d",a,b);
return 0;
}
Solution:
#include<stdio.h>
int main(){
int a=5,b=10;
//process one
//Credits: Arjun and Shravya Kodli.
a=b+a;
b=a-b;
a=a-b;
printf("a= %d b= %d",a,b);
//process two
a=5;
b=10;
a=a+b-(b=a);
printf("\na= %d b= %d",a,b);
//process three
a=5;
b=10;
a=a^b;
b=a^b;
a=b^a;
printf("\na= %d b= %d",a,b);
//process four
a=5;
b=10;
a=b-~a-1;
b=a+~b+1;
a=a+~b+1;
printf("\na= %d b= %d",a,b);
//process five
a=5,
b=10;
a=b+a,b=a-b,a=a-b;
printf("\na= %d b= %d",a,b);
return 0;
}
Add two number Without Using Addition Operator
Question:
Solution:
1. Recursion
int add(int, int);
int main() {
int num1, num2;
printf("\nEnter the two Numbers : ");
scanf("%d %d", &num1, &num2);
printf("\nAddition of two num is : %d", add(num1, num2));
return (0);
}
int add(int num1, int num2) {
if (!num1)
return num2;
else
return add((num1 & num2) << 1, num1 ^ num2);
}
2. Looping 1
int main() {
int num1 = 10, num2 = 5, i;
while (num2 > 0) {
num1++;
num2--;
}
printf("%d", num1);
return (0);
}
3. Looping 2
int main() {
int num1 = 10, num2 = 5, i;
while (num2--) {
num1++;
}
printf("Sum is : %d", num1);
return (0);
}
4. Looping 3
int sum(int, int);
int main() {
int a, b;
printf("Enter the two Numbers: ");
scanf("%d %d", &a, &b);
printf("Addition of two num. is : %d", add(a, b));
return(0);
}
int add(int num1, int num2) {
int i;
for (i = 0; i < num2; i++)
num1++;
return num1;
}
5. Using Subtraction for Addition!
int main() {
int num1 = 10, num2 = 5;
num1 = num1 - (-num2);
printf("Sum is : %d",num1);
return (0);
}
7. Using Complimentary function
//Shravya Shetty
#include<stdio.h> void main(){ int a=5,b=0; int res; res=a - ~b -1; printf("Answer%d",res); }
Solution:
1. Recursion
int add(int, int);
int main() {
int num1, num2;
printf("\nEnter the two Numbers : ");
scanf("%d %d", &num1, &num2);
printf("\nAddition of two num is : %d", add(num1, num2));
return (0);
}
int add(int num1, int num2) {
if (!num1)
return num2;
else
return add((num1 & num2) << 1, num1 ^ num2);
}
2. Looping 1
int main() {
int num1 = 10, num2 = 5, i;
while (num2 > 0) {
num1++;
num2--;
}
printf("%d", num1);
return (0);
}
3. Looping 2
int main() {
int num1 = 10, num2 = 5, i;
while (num2--) {
num1++;
}
printf("Sum is : %d", num1);
return (0);
}
4. Looping 3
int sum(int, int);
int main() {
int a, b;
printf("Enter the two Numbers: ");
scanf("%d %d", &a, &b);
printf("Addition of two num. is : %d", add(a, b));
return(0);
}
int add(int num1, int num2) {
int i;
for (i = 0; i < num2; i++)
num1++;
return num1;
}
5. Using Subtraction for Addition!
int main() {
int num1 = 10, num2 = 5;
num1 = num1 - (-num2);
printf("Sum is : %d",num1);
return (0);
}
6. Using Multiplication and Subtraction for Addition!
//Rakshita
#include<stdio.h>
int main()
{
int w,x,y,z;
printf("enter 2 numbers\n");
scanf(%d%d",x,y);
w=x*y-x-y;
z=x*y-w;
printf("%d",z);
return 0;
}
7. Using Complimentary function
//Shravya Shetty
#include<stdio.h> void main(){ int a=5,b=0; int res; res=a - ~b -1; printf("Answer%d",res); }