June 11, 2008 at 10:24 pm (Uncategorized)
Many algorithm correctness and performance tests, games and others require random number generation. Here is a way to generate a random number between two limits min and max.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
int randomnum;
int min=1; /* lower limit */
int max=7; /*upper limit */
time_t seconds;
time(&seconds);
srand((unsigned int) seconds); /*seed for rand() */
randomnum = rand() % (max-min+1) + min; /*generate random number within limits*/
printf(”random number=%d\n”,randomnum);
return 0;
}
The idea behind the solution is very simple.
- rand() generates a random integer between 0 and RAND_MAX. The number generated depends on the seed
- rand()%max+1 generates an integer between 1 and max
- On the same lines, rand()%(max-min+1) generates a random number between 0 and (max-min) thereby randomizing the difference between the two limits. To this random difference, we can add a lower limit min to generate the random integer between min and max
5 Comments
April 4, 2008 at 10:10 pm (Uncategorized)
One of the questions posed in 8th mile OSP prelims was :
Write a program to check if the compiler (C compiler ) allows nested comments.
Here is the solution I came up with
#include<stdio.h>
int main()
{
int i=10,*j,k,l=20;
j=&l;
k= /* /* */i */*j;/* */ 1;
if(k==i)
printf(”does not allow nested comments\n”);
else if(k==l)
printf(”allows nested comments”);
return 0;
}
I hope it works.. Comments and suggestions are most welcome. Please tell me if u have a better solution.
7 Comments
March 31, 2008 at 7:34 pm (Uncategorized)
8th Mile is the techno-cultural fest conducted by our college, RVCE. The event occured after 5 long years and it was a huge success. The first day featured eastern music and eastern dance competitions. The performances were great and we enjoyed every single moment. On second day, we had technical events. We won second place in “On the spot Programming”. Prabhanjan is my team mate and it was a joy to watch him code a solution in last 10 minutes!!! Hats off to u Prabhanjan..
We had performance by Raghu Dixit. It was rocking
The most amazing thing about him is the spirit with which he performed. His performance was very lively and humous. He established a good rapport with the audience.
The next concert was by Praveen Godkhindi. It was majorly classical. I enjoyed it the most because I am a fan of Hindustani Classical Music. He played Bhupa, Bhinpalas and Pahadi..He also played many popular numbers from Kannada and Hindi movies. Classical music gives happiness to the soul. Its very refreshing. We realized the beauty of classical music. That concert has inspired me to continue my classical music riyaaz after engineering
8th Mile was the change we were seeking from the day-to-day routine…
1 Comments
March 26, 2008 at 9:52 pm (Uncategorized)
Since the day I began to gain understanding of the word “kernel”, I was always curious to know more and more about it. I was trying since few days to write a very simple “hello world” module
but couldnt. Today I came across this link http://tldp.org/LDP/lkmpg/2.6/html/index.html … By following the instructions given in that tutorial, I was able to write my first kernel module, compile and load it successfully.
I am sssssssooooo happy about it
Well, ” A journey of thousand miles begins with a small step”…
6 Comments
March 25, 2008 at 8:29 pm (Uncategorized)
I am trying to connect my Nokia 6020 handset through DKU-5 to my laptop for a project. I am unable to find drivers. The handset is not being recognized by the system. I use Ubuntu 7.04. I searched the web for info but couldnt find any. Can anyone let me know about the driver? Or some other data cable that can be used on linux wil also be helpful.
If I fail to explore a way to connect the mobile to my comp, i ll be forced to do the project on Windows
Please help me…
2 Comments
March 24, 2008 at 5:55 pm (Uncategorized)
I had never thought that I could stay awake all night anytime. Innofest 2008, a technical fest by IIIT, Bangalore had an overnight programming contest named CODE BUTTER on 22nd night. In a team of 3, we were supposed to solve one problem ( which was actually a mini-project) in 12 hours.
The competition was awesome. The most wonderful thing was the confidence I gained from the event. I forgot everything when I started coding at 9.30 pm at night. It was like addiction to programming. Its a good experience to work under stress.
Our team coded a utility to search files on Linux/Unix system. We used UNIX APIs for the functionality and Qt for the front end. We knew the details and usage of most APIs that we used. Qt assistant helped me a lot. We were given access to internet and that was very useful in certain special occasions (like converting a QString to char * for use by the APIs etc. ). IIIT, Bangalore is about to release our code under GPL.
7 Comments
March 11, 2008 at 7:18 pm (Uncategorized)
We have created a mailing list for RVCE lug on Google Groups. Currently there are two projects going on in association with KK Mane sir from TIFR, Mumbai.
1. Free money project- Accounting package like Tally, basically an open source alternative to Tally.
2. Book reader project
As a part of activities on campus, I conducted a session on Shell Basics because we wanted the fundamentals to be strong and work culture to be efficient. The response was overwhelming.
Last Thursday, we had Hiran in our college. Hiran had participated in Google SoC last year. He gave a session on font development and it was very interesting. Many student from our college are now interested in designing Kannada fonts.
On Saturday….Kartik Mistry, Praveen, Shyam, Vikram and srijit had come to our college. Praveen and Shyam gave lecture on GSoC. Kartik spoke about debian. Vikram talked about localization. All the lectures were awesome. Please help the swatantra project in translation on http://translate.swatantra.org if you know Kannada.
Comments
March 10, 2008 at 10:41 pm (Uncategorized)
Recently, my friend informed me that v can browse the internet using emacs. I tried doing it and it is an awesome feature.
I downloaded the packages w3m, w3m-el and w3m-img.
Started emacs, Alt+X typed w3m
This loads the w3m.
Pressed the open button in the 2nd row to enter the URL
Pressed Enter and there it is!!!
We can also use the images option to display images in the page.
Nice feature… right????
Thanks to RMS( Richard M. Stallman) for such a rich text editor
and..
Thanks to Prabhanjan ( www.prabhanjan.wordpress.com) for sharing this tip with me
Comments
February 21, 2008 at 7:54 pm (Uncategorized)
I was directed to this article by one of my friends..
http://blog.anamazingmind.com/2008/02/why-linux-doesnt-spread-curse-of-being.html
It explains the user reaction from psychology perspective. Never the less, I feel very comfortable with Linux, specially for programming, with its rich set of development tools.
4 Comments
February 21, 2008 at 7:47 pm (Uncategorized)
I was really excited to see NITK with its vast campus, well maintained buildings and bbbeeeaaauuutiful beach infront of the college. It was a great experience away from the crowded city life. My dream of visiting the sea came true after a long time.
I participated in Rectifier and Marathon. The events were well organized and it was highly competitive. Rectifier was a debugging event. Marathon tested us in all the aspects of Computer Science including Programming, Algorithms, Data Structures. It also included IT Quiz. Marathon contained five rounds and i thoroughly enjoyed each round. I qualified to the finals in both the events but the failure in the finals taught me good lessons
It often happens that you learn more from temporary “FAILURES” than “SUCCESS”.
The best time perhaps was the time spent on beach with my friends. The sound of the waves was soothing. It was Valentine’s day. There were a few young couples on the beach
It was nice to watch them happy together. One of my friends said “I personally believe there shudnt be a valentine’s day …bcoz u need to love ur loved ones everyday. Everyday is a valentine’s day. Every occassion when u r with that person is special”. Great feeling indeed!!
The Surathkal beach was relatively less crowded, very calm and relaxing. The students of NITK are lucky to study in such a great environment.
1 Comments