Monday, 25 May 2015
Sunday, 17 May 2015
electrical brain teasing puzzle
You have just moved into an old house with a basement and an attic. There are three switches in the attic, marked "on" and "off". The three switches are connected to three bulbs in the basement.
You have to find out which switch is connected to which bulb. You are allowed to play with the switches for as long as you need to, but you may only go down into the basement once to check the bulbs and then say which which switch is connected to which bulb.
Hint: You don't need any knowledge about electrical wiring to solve this puzzle.
|
answer: make one switch turn ON for 20 min are more if you want,then turn OFF the switch and turn ON next switch.
now go to basement and check each bulb weather it was blowing are not and also check weather bulb was hot are not.
1.bulb which was hot and not blowing ----was connected to the switch you turn on earlier for 20 min are more.
2.the bulb which was blowing --------connected to switch secondly turned ON
3.bulb which was not blowing and nor hot -----connected to the switch which was remaining switch.
Friday, 1 May 2015
SPOTTURNS ACHIEVEMENTS TILL NOW
hi friends ,i am happy to share my success with you
i stated my blogger www.spotturns.blogspot.com at Feb 10nth 2014.
my blogger reaches 1000 viewers mark at JAN 18nth 2015, almost an year.
and i got add sense approval at november 2014,and i succussed "google AdSense achievement cards" at march 2015.
now i reached 2000 viewers mark very quick,i mean today (01/05/2015)i cross 2000 viewers mark(with in 4 months )
thanks for your encouragement and support, i hope same support in future also
yours lovingly
R.REDDYPRASAD
www.spotturns.blogspot.com
i stated my blogger www.spotturns.blogspot.com at Feb 10nth 2014.
my blogger reaches 1000 viewers mark at JAN 18nth 2015, almost an year.
and i got add sense approval at november 2014,and i succussed "google AdSense achievement cards" at march 2015.
now i reached 2000 viewers mark very quick,i mean today (01/05/2015)i cross 2000 viewers mark(with in 4 months )
thanks for your encouragement and support, i hope same support in future also
yours lovingly
R.REDDYPRASAD
www.spotturns.blogspot.com
spotturns achievements |
Multiple increment operators inside printf (VERY IMPORTANT )
Multiple increment operators inside printf
#include<stdio.h> void main()
{
int i = 1;
printf("%d %d %d", i, ++i, i++);}
output:
3 3 1
Output :
Pictorial representationExplanation of program
- Whenever more than one format specifiers (i.e %d) are directly or indirectly related with same variable (i,i++,++i) then we need to evaluate each individual expression from right to left.
- As shown in the above image evaluation sequence of expressions written inside printf will be – i++,++i,i
- After execution we need to replace the output of expression at appropriate place
No | Step | Explanation |
---|---|---|
1 | Evaluate i++ | At the time of execution we will be using older value of i = 1 |
2 | Evaluate ++i | At the time of execution we will be increment value already modified after step 1 i.e i = 3 |
2 | Evaluate i | At the time of execution we will be using value of i modified in step 2 |
I am sure you will get confused after viewing the above image and output of program.
MY fb PROGRAM:
#include <stdio.h>
#include <conio.h>
int main()
{
int a=5;
printf("%d %d %d", a++,a,a--);
}
guass the output to above program????????????????????????????
OUTPUT:
4 4 5
Different Types of Increment Operation
In C Programming we have two types of increment operator i.e Pre-Increment and Post-Increment Operator.
A. Pre Increment Operator
Pre-increment operator is used to increment the value of variable before using in the expression. In the Pre-Increment value is first incremented and then used inside the expression.
b = ++y;
In this example suppose the value of variable ‘y’ is 5 then value of variable ‘b’ will be 6 because the value of ‘y’ gets modified before using it in a expression.
B. Post Increment Operator
Post-increment operator is used to increment the value of variable as soon as after executing expression completely in which post increment is used. In the Post-Increment value is first used in a expression and then incremented.
b = x++;
Example program for increment operators in C:
- In this program, value of “i” is incremented one by one from 1 up to 9 using “i++” operator and output is displayed as “1 2 3 4 5 6 7 8 9”.
//Example for increment operators
#include <stdio.h>
int main()
{
int i=1;
while(i<10)
{
printf("%d ",i);
i++;
}
}
Output:
1 2 3 4 5 6 7 8 9 |
Example program for decrement operators in C:
- In this program, value of “I” is decremented one by one from 20 up to 11 using “i–” operator and output is displayed as “20 19 18 17 16 15 14 13 12 11”.
//Example for decrement operators
#include <stdio.h>
int main()
{
int i=20;
while(i>10)
{
printf("%d ",i);
i--;
}
}
Output:
20 19 18 17 16 15 14 13 12 11 |
Difference between pre/post increment & decrement operators in C:
- Below table will explain the difference between pre/post increment and decrement operators in C.
S.no
| Operator type | Operator | Description |
1 | Pre increment | ++i | Value of i is incremented before assigning it to variable i. |
2 | Post-increment | i++ | Value of i is incremented after assigning it to variable i. |
3 | Pre decrement | – –i | Value of i is decremented before assigning it to variable i. |
4 | Post_decrement | i– – | Value of i is decremented after assigning it to variable i. |
Subscribe to:
Posts (Atom)