Tuesday, 22 July 2014

fastest way to multiply any number by 9-Program

Give a fastest way to multiply any number by 9.
Answer:
#include <stdio.h>
#include <conio.h>
void main()
{
int n;
printf(“Enter a number:”);
scanf(“%d”,&n);
printf(“%d”, (n<<3)+n);
getch();
}

Monday, 21 July 2014

Add two numbers without operator

Add two numbers without using operators...
clue:
printf("%*d",5,4);
the return type of printf is int..in this the number 5 will be assigned to the * and the number 4 will be assigned to the d.
so the output will be
output:
     4
i.e.., 5 spaces then 4 will be printed

Reverse coding

Hi friends...
lets crack some codes..
Following are some sample inputs and outputs.Find the logic and make the code
sample:

































try it yourself
here is the answer:
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
start:
long int input,i;
long  mul=1;
long double result;
cout<<"\nEnter a positive number:";
cin>>input;
for(i=1;i<=input;i++)
{
mul=mul*input;
}
result=2.303*log10(mul);
cout<<result;
goto start;
}