Custom Search

Wednesday, April 25, 2007

Google as a calculator

Google is tremendously increasing the applications. It designed a calculator in the search bar itself. When you need some calculation urgently, you need not search for calculator. All the calculations can be done with google.com



for example,

type this in google,

2 + 3 * 5

you will see a result like this

2 + (3 * 5) = 17

it supports many scientific calculations also

sin(pi/2)



result is



sin(pi / 2) = 1

half a cup in teaspoons



half (1 US cup) = 24 US teaspoons

160 pounds * 4000 feet in calories

(160 pounds force) * 4 000 feet = 207.390891 kilocalories

euro to INR conversion



1 Euro = 56.012747 Indian rupees

When you need some calculations urgently, dont waste your time to search your calculator or no need to download and install a calculator application. Go to google and type what ever the calculations you need. It is very easy.



For more information visit http://www.google.co.in/intl/en/help/features.html#calculator

Tuesday, April 24, 2007

StumbleUpon -Discover great websites

An excellent addon for firefox for internet browsing lovers StumbleUpon.

Idea is simple but extremely good.



I will try to explain in my words. First, you need to install StumbleUpon, give your email id to store ur preferences.

It gives a list of topics, select your choices. I recommend you to select very few that you are really interested.

Click on save. on the toll bar click stumble

You will get a web page from your preferred choices.



There is a drop down menu on the tool bar showing ALL.

Click ALL and select a topic for example, "Internet Tools". From now on if you press stumble, you will see a web page from that "Internet Tools".



It also provides option to include web pages to StumbleUpon. open the web page you wanted to include in stumbleupon. click i like it button on stumble tool bar. It will recognize that and add it to your interested sites. It will show that page to others which matches to the type of the topic.



Here is the link to install StumbleUpon http://www.stumbleupon.com/

Saturday, April 14, 2007

Metacafe.com

If u r much interested in watching videos from across the world and wanna save them in ur PC?

here is the useful software that will make ur complete work.



have a look at this site once. Metacafe

It automatically downloads many videos from the internet when ur internet connection is idle.

There are option to specify ur interested topics and options to control the type of videos that has to be downloaded also.

U need not worry, if u r at home u can control many videos not being downloaded.



Its really cool one i got.

Wednesday, April 11, 2007

Slideshare.com

A good website for sharing powerpoint presentations. Slideshare

While browsing the net, i got this site. I felt very interesting....



Try this once. Hope u love it. It needs flash payer installed in the browser.

Complete text of the presentation is available in the bottom of the page. It is awesome. initially, We can view the text before watching entire presentation.

http://www.slideshare.net/jignesh/ddos-attacks

Saturday, March 24, 2007

Question for the week -2

2 power 4 = 16 and the sum of the digits is 1 + 6 = 7

2 power 15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26



What is the sum of the digits of the number 2 power 1000

Wednesday, March 21, 2007

Questions for the week - 1

//correct all errors and make the program do insertion sort



// There are some logical errors. Note that, there is no compilation error.



// program compiled in gcc linux fedora core 5







int X[10],



Y[10],



NumInputs,



NumY = 0;







void GetArgs(int AC, char **AV)







{ int I;











NumInputs = AC - 1;



for (I = 0; I NumInputs; I++)



X[I] = atoi(AV[I+1]);



}







void ScootOver(int JJ)







{ int K;







for (K = NumY-1; K JJ; K++)



Y[K] = Y[K-1];







}







void Insert(int NewY)







{ int J;







if (NumY = 0) {







Y[0] = NewY;



return;



}







for (J = 0; J NumY; J++) {



if (NewY Y[J]) {











ScootOver(J);



Y[J] = NewY;



return;



}



}



}







void ProcessData()







{







for (NumY = 0; NumY NumInputs; NumY++)







Insert(X[NumY]);







}







void PrintResults()







{ int I;







for (I = 0; I NumInputs; I++)



printf("%d\n",Y[I]);



}







int main(int Argc, char ** Argv)







{







GetArgs(Argc,Argv);







ProcessData();



PrintResults();



}

Tuesday, March 20, 2007

Quine

Write a C program that executes and prints itself in the output.
(Do not use any file concepts such as reading from source file, the source will not be provided.)

The answer is
A program that produces its complete source code as its only output is called a quine. This is a technique some times used in viruses.( dont ask me to write a virus or to help in writing a virus ).

char*f="char*f=%c%s%c;main()
{printf(f,34,f,34,10);}";
main(){printf(f,34,f,34,10);}

Let us understand the above program.
Before that, have a look at this code
char t[10]="%s";
char name[10]="hello";
printf(t,name);

it prints
hello

generally printf takes parameters. treats the first string is to be printed and if there is some %s in the first string, it searches for the next parameter(ignores it, if there is no corrosponding parameter in the printf call). prints it with out any doubt.

Now, let us understand this code

The program is
char*f="char*f=%c%s%c;main(){printf(f,34,f,34,10);}";
main(){printf(f,34,f,34,10);}

initially, we r declaring a character pointer f.
we are storing the text that is present in the program into the pointer p but, with some technique to print itself twice.

char*f="char*f=%c%s%c;main(){printf(f,34,f,34,10);}";
main(){printf(f,34,f,34,10);}

we are storing char *f=%c%s%c;main(){printf(f,34,f,34,10);}
in to the character pointer f
in the main we are calling a printf.
f is passed as a first variable to printf

char*f="char*f=%c%s%c;main(){printf(f,34,f,34,10);}";
main(){printf(f,34,f,34,10);}

The printf will look like

printf("char*f=%c%s%c;main(){printf(f,34,f,34,10);}" ,34,f,34,10);
observer the double quotes text in printf, it has %c%s%c

printf("char*f= %c%s%c;main(){printf(f,34,f,34,10);}",34,f,34,10);

there i am printing 34, f, 34. (34 is ascii double quotes ("))
the entire printf will look like
printf("char*f=" char*f=%c%s%c;main(){printf(f,34,f,34,10);}"",10);

we can omit 10. it is not necessary.

if it is not clear, write the program on a paper and try the steps described above.

if u r comfortable, have a look at ............(not compulsary, leave this complex example if u dont understand)
A complex quine example

/* A simple quine (self-printing program), in standard C. */

/* Note: in designing this quine, we have tried to make the code clear and readable, not concise and obscure as many quines are, so that the general principle can be made clear at the expense of length. In a nutshell: use the same data structure (called "progdata" below) to output the program code (which it represents) and its own textual representation. */

#include

void quote(const char *s)
/* This function takes a character string s and prints the
* textual representation of s as it might appear formatted in C
* code. */
{
int i;

printf(" \"");
for (i = 0; s[i]; i++) {
/* Certain characters are quoted. */
if (s[i] == '\\')
printf("\\\\");
else if (s[i] == '"')
printf("\\\"");
else if (s[i] == '\n')
printf("\\n");
/* Others are just printed as such. */
else
printf("%c", s[i]);
/* Also insert occasional line breaks. */
if (i % 48 == 47)
printf("\"\n \"");
}
printf("\"");
}

/* What follows is a string representation of the program code, from
* beginning to end (formated as per quote() function, above), except
* that the string _itself_ is coded as two consecutive '@'
* characters. */
const char progdata[] =
"/* A simple quine (self-printing program), in st"
"andard C. */\n\n/* Note: in designing this quine, "
"we have tried to make the code clear\n * and read"
"able, not concise and obscure as many quines are"
", so that\n * the general principle can be made c"
"lear at the expense of length.\n * In a nutshell:"
" use the same data structure (called \"progdata\"\n"
" * below) to output the program code (which it r"
"epresents) and its own\n * textual representation"
". */\n\n#include \n\nvoid quote(const char "
"*s)\n /* This function takes a character stri"
"ng s and prints the\n * textual representati"
"on of s as it might appear formatted in C\n "
"* code. */\n{\n int i;\n\n printf(\" \\\"\");\n "
" for (i = 0; s[i]; i++) {\n /* Certain c"
"haracters are quoted. */\n if (s[i] == '\\\\"
"')\n printf(\"\\\\\\\\\");\n else if ("
"s[i] == '\"')\n printf(\"\\\\\\\"\");\n "
" else if (s[i] == '\\n')\n printf(\"\\\\n\""
");\n /* Others are just printed as such. *"
"/\n else\n printf(\"%c\", s[i]);\n "
" /* Also insert occasional line breaks. */"
"\n if (i % 48 == 47)\n printf(\"\\"
"\"\\n \\\"\");\n }\n printf(\"\\\"\");\n}\n\n/* What "
"follows is a string representation of the progra"
"m code, from\n * beginning to end (formated as pe"
"r quote() function, above), except\n * that the s"
"tring _itself_ is coded as two consecutive '@'\n "
"* characters. */\nconst char progdata[] =\n@@;\n\nin"
"t main(void)\n /* The program itself... */\n{\n"
" int i;\n\n /* Print the program code, chara"
"cter by character. */\n for (i = 0; progdata[i"
"]; i++) {\n if (progdata[i] == '@' && prog"
"data[i + 1] == '@')\n /* We encounter "
"two '@' signs, so we must print the quoted\n "
" * form of the program code. */\n {"
"\n quote(progdata); /* Quote all. *"
"/\n i++; /* Skip second"
" '@'. */\n } else\n printf(\"%c\","
" progdata[i]); /* Print character. */\n }\n "
" return 0;\n}\n";

int main(void)
/* The program itself... */
{
int i;

/* Print the program code, character by character. */
for (i = 0; progdata[i]; i++) {
if (progdata[i] == '@' && progdata[i + 1] == '@')
/* We encounter two '@' signs, so we must print the quoted
* form of the program code. */
{
quote(progdata); /* Quote all. */
i++; /* Skip second '@'. */
} else
printf("%c", progdata[i]); /* Print character. */
}
return 0;
}


I hope the things are clear about quine. if any one can explain in better way, mail me i will forward it to all.
Thank you.

Thursday, March 15, 2007

C - Review II

1. struct fprintf{

int i;
};
void main(){
int fprintf;
struct fprintf cprintf;
cprintf.i=55;
printf("%d",cprintf.i);
}
Output : 55

2. main(){

int a = 88;
printf("%d",a<<3);
printf("%d",a<<1);
printf("%d",a<<1);
}
what is the value of a after the execution of 3 printf statements

Answer : 88. We are not modifying a value

C - Review II 3

3. Explain which one is better and why? or are they same? There is no compilation or runtime error

i) int a[1000][1000];
for(int i =0;i < 1000;i++)
for(int j=0;j < 1000;j++)
printf(“%d”,a[i][j]);

ii) int a[1000][1000];
for(int j = 0;j < 1000;j++)
for(int i = 0;i < 1000;i++)
printf(“%d”,a[i][j]);

Answer : Code snippet (i) recommonded when programming language uses row-major order

Code snippet (ii) recommonded when programming language uses column-major order

C - Review II 4 ,5

4. main() {

int reset(int );
int i=5;
reset(i);
}
int reset(int n){
if(n==0)
return 0;
else
printf(“%d”, n);
reset(n--);
}
Output: infinite recursion. It continuously prints 5 and after some time stack overflow occurs.

5.

main(){

register int i;

int *ptr;

ptr = &i;

i=10;

printf(“%d”,*ptr);

}

Output: Compilation error. We cannot refer the address of a register variable