Sunday, August 19, 2007

printf statement

printf statement plays lot of tricks with those who are always new to the C programming language. Consider the following statement which I was informed when I was doing my second semester
int i=5;

printf(”%d %d %d”,i,++i,i++);

The output predicted by most of the students is usually 5 6 6. But this is not the actual output for this statement. The printf statement usually is handled by the compiler from right side to left side. So it starts from i++ first. Here the initial value of i is 5. So when it reaches i++ statement the value remains the same (its a post increment) and the next step is ++i which is pre increment step and the value of i becomes 7 (coz the i++ increments the value of i after it reaches the next step i.e. ++i). So the final value of i is 7 here.

But while printing the printf statement executes in the normal fashion as we expect it to execute. So it prints the value of i first followed by ++i and finally i++. So the actual output for this statement is 7 7 5.

For those who know this please dont mind about this post. For those who dont know this hope you find it useful (though mostly all will be knowing it ;) But still many dont know this coz I’ve asked many about this and many still struggle in this).

I’ll ask an important question in the next post which i think many C program lovers will like.

Cheers!!!!

Thursday, August 16, 2007

interesting facts and programs related to C programming.

Here are some interesting facts and programs related to C programming.

* We all know that to print something in the output screen we have to use printf statement and a printf statement statement ends with a semi-colon according to the syntax. But to print something in the output screen without using semi-colon we can make use of if statement with printf statement. Try executing the following code in Turbo C after including the header files.

void main()

{

if(printf(”Hi”))

{

}

}

The Hi given inside the printf will be displayed in the output screen. Since I didnt use the getch() statement, you’ll have to press alt+F5 to view the output screen. I’ll post few other small programs later which you may find useful for debugging competitions in other college symposiums.

Yours buggingly

Vinod…(my friend)

Friday, August 10, 2007

Quiz

So here are the answers for the QCT 1 questions.
1. N81 and N95 are the two premium multimedia handsets released by Nokia recently.
2. CISCO
3. Fixed-wing aircraft
4. The Strand magazine
5. PageRank
6. TouchLight
7. Microsoft Surface
8. Synthesizer
I am happy that I got a very good response to the very first edition of QCT. Thanks for your reply friends. I’ll post the answers of those who mailed me just this time because others have given me the answers in the comments. From next time please mail the answers to my mail id.
Answers from Marc
1. N80, N95
2. Cisco
3. fixed wing
4. —
5. Page Rank
6. —
7. Microsoft Surface
8. —
Answer from Vijay Krishnan
1. N800 and ????
2. Cisco
3. Pass
4. Playboy??? ;)
5. PAGERANK
6. sumthng related to laser???
7. Must be the new Windows OS… Dunno what…
8. Im from CSE dept…
Answers from KrishnaKumar
1. N95 and um.. N101 (he he)
2. Skype?
3. as far as i know, military aircrafts use huge propeller powered jet engines.
4. this i know being such a big fan of SH… The Strand.
5. all greek and latin… but it sounds like Pagerank
6. no idea da.. good Q though.
7. again good Q… the technology seems to be straight from sci-fi… i am reminded of Minority Report… Tom Cruise uses a similar interactive system. no idea what it’s called.
8. dai i remember telling you about this one day when we were hearing to Bon Jovi’s ‘It’s My Life’… it’s called the Talkbox, no?
(well I too remember that. you said that when the song was alomst about to end. But I’m not talking about that here. I went through wiki about the answer you gave. But I guess its not the same).
Answers from Mahesh
1. N91 and N75
2. CISCO(thanks to webEx thru which i know this)
3. There is something called Hovercrafts..it is used in IIT shaastra…chumma…
4. theriyalada
5. Pagerank(appada..sure 1 correct)
6. i-phone?
7. Microsoft surface(sure 2 correct)
8. Electronic Keyboard? (i.e the casio,yamaha,korg..that keyboard)
So the scores are given below.
Marc got 4.5 (.5 for N95)
Harish got 2
Sundar got 2
Karthik got 4 (You gave me the answer for PageRank in brackets but ur actual answer was dunno. So i cant consider it as answer. Sorry dude no points here. lol.. Better luck next time)
Vijay Krishnan got 2
KrishnaKumar got 2.5
Mahesh got 3
Well friends since our exams are from next week I’ll post the next quiz i.e. QCT 2 after exams. Thanks again for your reply. Hope you guys liked it.

If you are interested to conduct quiz here then send me your questions to my mail id (vinodkumar.wall@gmail.com). I’ll post your questions. Send the answers after few days so that I can also answer your questions. ;)
Cheers!!!

Wednesday, August 08, 2007

Punjab Engineering Entrance exam for exceptional Sardars

Punjab Engineering Entrance exam for exceptional Sardars

Time Limit: 3 weeks [Each question 10 marks]

1. Spell — Bush, Carter and Clinton

2. Can you explain Einstein’s Theory of Relativity?

(a) yes
(b) no

3. What does AIR (All India Radio) stand for?

4. Advanced math. If you have three apples how many apples do you have?

5. Where is the basement in a three-story building located?

6. What are coat hangers used for?

7. Six kings of India have been called Akbar, the last one being Akbar the Sixth. Name the previous five.

8. Metric conversion. How many feet is 0.0 meters?

9. What language is spoken in Tamil Nadu?

10. What time is it when the big hand is on the 12 and the little hand is on the 5?

*You must answer at least three questions correctly to qualify*

Source: http://dragonz-prs.com/