Predict the output!

Q. I have an error free C code, am writing for you. This code searches for the string “C+Trivia” in Google. Surprised, how it can be?

#include "stdio.h"
#include "stdlib.h"
int main()
char* str;
printf("C + Trivia",str);
return 0;

Read more about this program here.

Continue reading


There is something about “Vim”!

Vim offer several functionalities that improve our editing and saves time. Here are some of them.

1. Copying a whole line

yy or shift y or :ny

where n is the number of line if n is not specified then copy the current line

2. Copying from current position to end of line.


3. Copying 3 lines after the current position


4. Copying a range of line

:1,5y or :1y 5

The above example copy 5 lines, from 1 to 5

5. Deleting a whole line (Deleted line is copy to the registers)

dd or :nd

Where n is the number of line if n is not specified then delete the current line

6. Deleting from current position to end of line (Deleted text is copied to the registers)

d$ or shift d

7. Deleting a range of line

:1,5d or :1d 5

The above example remove 5 lines, from 1 to 5 and copy them to a register

8. Put n times a text, previously copied, after the cursor

: np

9. Put n times a text, previously copied, before the cursor

n Shift p

10. Word completion, works in insert mode

1. Ctrl n search forward for next matching

2. Ctrl p search backward for previous matching Very useful in programming (perl, bash, java, other)

11. Put vim in replace mode

Shift r

12. Undo


13. Redo

Ctrl r

14. Getting help about a topic

:help topic

Note: previous commands work in command mode except 10.

What is being returned?

#include "stdio.h"
int main()
int i=10,j=20,k;
return 0;
addsub(int c, int d)
int x,y;
return (x,y);

it’s the value of y which is returned here, because return statement never gives error if you write more than one arguments to it separated by a’s the last argument which is returned always.
so, the output is


A little C sip

Here is a code:

#include “stdio.h”
int main()
float a=4;
int i=2;
return 0;

i expected the output to be:

0.500000 0
0 0.500000

but unfortunately..itsn’t not the same. The reason is the first printf conversion is messed up a little leading the second printf to not work in a predictable way. Go, get it run and see!

which is faster ? p++; or p=p+1;

p++ is faster because on compilation it gets translated to three machine
instructions where as p=p+1 needs four machine instructions. All machine
instructions take the same time.

For p++ the instructions are:

mov ax

inc ax



For p p+ 1 the instructions would be

mov ax

mov bx 1

add bx



This is why p++ is faster than p+1!

Python makes me happy!

Well…i am posting this as a newbie of Python. Python coders …please don’t look at it because you know the beauty of this language! I repeat..i am just a newbie.

a week ago..i came to know a about a programming language or in better word scripting language called Python.

I am just fond of this language as i found it more simpler than C/C++ or even Java.  A coding example of swapping of two numbers as follows in python:

#! /usr/bin/python



print “a is “,a,”and b is “,b


print “a is “,a,”and b is “,b

Save this file as (.py extension reports that it’s a python file) make it executable my giving it execute permission using the following command:

chmod +x

When you run this script after saving  it as , you will get the following output:

a is  10 and b is  5
a is  5 and b is  10

I hope you are remembering those codes in C/C++ and in python a single liner does the whole swapping work…interesting. Isn’t it?

Python is platform independent. You are free to run it on Windows/ Linux or Mac/Solaris systems. FYI, I use Ubuntu linux!

Is there any online study material for the same?: yes..there is! you can read Python documentation or download a book by Mr. Swaroop C H . Heartiest thanks from my side, Swaroop for your effort !

Use your code online

Usually what people do while programming is that they:

a. Open a text-editor like notepad, gedit, Vim, Emacs etc. and write the code

b. Use any particular IDE (I prefer ecclipse for Java and Kdevelop for other codes)

But in case..suppose you are somewhere where you haven’t the facility of compiling or running programs of your desired language.

I hope you certainly go for downloading and installing the compiler/interpreter for the platform …this process becomes even worse when you are window user and got a linux/Mac system to work upon.Damn…

In these cases, i preferrably use codepad…put your code or copy/paste it from the source, run it! you can post your codepad links also rather than pasting your whole bulk code. A sample example from my pastes is here.

Why Codepad????

There are various pasting sites available but i don’t know how many of them provide their online compiling and excution property. If you know any better than this..please let me know. One more thing makes it a best choice of mine is that you can save your paste permanently and use your permalink as i have pasted the link above is permanent.