Archive for the ‘Programming’ Category

Predict the output!   4 comments

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() { http://www.google.com; char* str; printf(“C + Trivia”,str); puts(str); return 0; } Read more about this program here.

Posted August 1, 2009 by neeraj in Fun, Interview, Programming

There is something about “Vim”!   Leave a comment

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. y$ 3. [...]

Posted July 31, 2009 by neeraj in Linux tips and tricks, Programming

What is being returned?   Leave a comment

#include “stdio.h” int main() { int i=10,j=20,k; k=addsub(i,j); printf(“k=%d”,k); return 0; } addsub(int c, int d) { int x,y; x=c-d;y=c+d; 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 comma..it’s the last argument which [...]

Posted July 26, 2009 by neeraj in Interview, Programming

Tagged with , , ,

CPU scheduling algorithms implemented..   3 comments

//Here it goes: #include “iostream” #include using namespace std; class cpuschedule { int n,Bu[20]; float Twt,Awt,A[10],Wt[10],w;

Posted July 26, 2009 by neeraj in Programming, Uncategorized

Tagged with , , , , ,

A little C sip   Leave a comment

Here is a code: #include “stdio.h” int main() { float a=4; int i=2; printf(“%f\t%d”,i/a,i/a); printf(“\n%d\t%f”,i/a,i/a); 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 [...]

Posted July 25, 2009 by neeraj in Programming

Tagged with , , ,

Youtube videos from your terminal…   Leave a comment

You can download youtube videos by this Python-code Download from Uploading.com just save it as name youtube-dl make it executable as: chmod +x youtube-dl and run it as: ./youtube-dl and get the required video. For other options see its program documentation.

Posted July 22, 2009 by neeraj in Linux tips and tricks, Programming

Tagged with , , ,

which is faster ? p++; or p=p+1;   Leave a comment

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 mov ax For p p+ 1 the instructions would be mov ax mov bx 1 add bx mov ax [...]

Posted July 20, 2009 by neeraj in Interview, Programming, Uncategorized

Tagged with , ,

Python makes me happy!   Leave a comment

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 [...]

Posted July 16, 2009 by neeraj in Programming

Tagged with , , ,

Use your code online   Leave a comment

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 [...]

Posted July 15, 2009 by neeraj in Programming, Uncategorized

Tagged with , , ,

Follow

Get every new post delivered to your Inbox.