If you still don't trust this program, compile and execute it. Shocked ? In fact, there is a main in this program, but hidden. This is based on the concept of token pasting. What happens here is, change is initially replaced by modify(a, n, i, m, a, l). The arguments are then replaced as follows

t = ar = na = ii = mn = as = l

The statement i ## t ## a ## r gets changed to m ## a ## i ## n, which is then concatenated as main. Eventually,'change' is changed to 'main'. Since all these steps take place even before compilation (at the macro expansion stage), the compiler does not throw an error.

Usually in C
programming, whatever we type gets stored in the keyboard buffer
(temporary storage) and then the CPU takes input from the buffer.
If a scanf is used to read input, this buffer is inspected first. If the input is available in the buffer itself, it is taken directly and the scanf statement terminates. Only if the buffer does not have the requested input, the user is prompted for input.

Whenever we input a number (int, float or double), we give the number
and press enter to specify that our input is ready to be taken. Both
(number and enter) are stored in the buffer.

After enter is pressed, the
number gets stored in the (int, float or double) variable. But, where
does the enter go? Yes, it remains in the buffer. Next time when a
character or string is to be given as input, this enter will be taken
directly from the keyboard buffer and we will not be prompted to input
the character or string.

Solution 1:
To get rid of this let us use getchar() before the second scanf(), that
is at line number 10. getchar() takes the enter from the buffer. But,
since we didn't assign it to any variable, it gets wasted (removed from
the buffer).

Solution 2:
Instead
of using getchar(), we may get the character twice, that is use scanf (
"%c %c", &ch, &ch ) ; instead of scanf ( "%c", &ch ) ; In
this case, first enter is stored in ch and later, the input we give
replaces it.

The best solution:Which one of the above do you think is the best solution? If you think it is solution 1, then you are wrong. If you think it is solution 2, then also you are wrong. Both of the above are only solutions, but not the best. The best and right solution is to clear the buffer using the inbuilt function.

If you are a Turbo C programmer, use the following statement before line 10.
fflush (stdin);

If you are a gcc programmer, use the following statement before line 10.
__fpurge (stdin); // It is double 'underscore' followed by fpurge
and include <stdio_ext.h>

In a C program, what will we do if we want to display only specific number of digits (which is determined at run time, like user input) after decimal
point? We can get the number from the user, put
it in switch() and provide a case for each individual number, as follows.

Wednesday, 4 September 2013

Career
of an engineer begins with an interview. Interview is a process where
the abilities of a candidate are tested to check if the candidate
suits for the job/position. In this post, I would like to share my
first interview experience.

A
week before the interview, started my preparation for the interview
process. Students with percentage more than 75, right from their 10th
standard, were eligible for direct HR with Technical interview
(without necessity to take up the Aptitude & Vocabulary written
tests). I am one of the privileged students, to take up the direct HR
& Technical. I read the ‘Cracking the IT interview’ book and
prepared accordingly.

Registration:

The
registration was held on 31st
August, 2013 at the Main Computer Laboratory of my college, where we
were asked to provide our details like address, passport number,
degree and school marks, etc. We were also asked to attach our
resume, mark sheet and ID proof copies. While the registration
process, the work preference locations were also asked. My
preferences were Bangalore, Chennai and Hyderabad in that order.

Interview
day:

Before
the interview, a pre-placement talk was held at the Sona Auditorium.
There, we were given an overview of the company (Accenture) and its
achievements. After that, we were asked to move to PG Auditorium.
There, we were split into batches and sent to the ECE block, where
the placement cell and the HR department are located. Since the batch
allocation was based on the aggregate marks starting from 10th
standard, I was in the first batch.

The
Interview:

Before
I enter the Interview panel, I was given the registration sheet,
which was filled by me the previous day. I entered the interview
panel by around 10:30 am. Upon entering the panel, with a smile in my
face, I made a handshake with both the interviewers, although I was a
bit nervous. Then, I gave them the registration sheet (which also
contained the resume attached). When I was asked to sit by one of the
interviewers, I thanked him and sat. The conversation went as
follows.

(Throughout
the following conversation, I meant the person who asked technical
questions as ‘Tech’ and the one who asked HR questions as ‘HR’)

Tech :
Tell me about yourself.

Me :
I’m Suresh, doing final year IT. I am happy to say that a
Programming Club has been started in my college because of my
initiative. I’ve cleared the Software Developer Level 1 exam
conducted by Accenture and Carnegie Mellon University as a part of
Accenture Open Education (AOE). I’m one of the Microsoft Student
Partners of India. I had also been the Joint Secretary of Tamil
(Local Language) development club in my college. I’ve also
participated and won in several project presentation contests and
debugging contests. (I was shivering at the beginning. They noticed
it; but somehow, I managed and later I felt better)

Tech :
Inside your college or in other colleges?

Me :
Both in my college as well as in other colleges, sir.

Tech :
What are the languages you are good at?

Me :
I’m
good at C, sir.

Tech :
Only
C?

Me :
I
also know C++, sir.

Tech :
Don’t
you know Java?

Me :
I
would rate myself as 6 or 7 on a scale of 10, sir.

Tech :
What’s
the primary difference between C and C++?

Me :
C
is a structured language, where all the functions are global. C++ is
an object-oriented language, wherein both the data as well as the
functions are put together in a single entity called a class.

Tech :
What
are the key features of Object-Orientation?

Me :
Encapsulation,
Polymorphism, Abstraction and Inheritance.

Tech :
How
will you perform inheritance?

Me :
The
colon (:) operator is used for inheritance in C++ whereas in Java,
the ‘extends’ keyword is used.

Tech :
What is an abstract class?

Me :
An abstract class is one which can contain abstract methods. An
abstract class cannot have an object

Tech :
Then, why do we go for interface concept?

Me :
Since, multiple inheritance is not supported in Java, the interface
concept was introduced, sir. The difference between an abstract class
and an interface is that, an abstract class can have abstract methods
as well as normal methods, whereas an interface should only have
abstract methods. Another advantage of having an interface is that,
it could be used as a substitute for macro of C/C++, where we can
have final (constant) variables (attributes).(Then Tech asked a few questions regarding my projects)

HR :
What do you feel is the difference between your school and your
college life?

Me :
In school, I will not interact with people so easily. Also, I never
used to do presentations on stages. Only after coming to college, I
got rid of my stage fear. My college has helped me a lot by providing
enough opportunities to get rid of my stage fear.

HR :
What will you do at your free time?

Me :
I used to browse the internet, sir.

HR :
What kind of information do you browse?

Me :
I used to check and respond to mails and at some times, I also used
to visit some social networking sites.

HR :
Most of the people spend a lot of time in social networking sites.
What do you feel about it?

Me :
In my point of view, it depends upon the individual who’s using it,
sir. Because, there are so many groups available.

HR :
How do these groups help?

Me :
Sometimes, even Google will not provide answers to our questions,
sir. At those times, social networking helps out as there are several
groups. Also, in emergency situations like blood requirement, social
networking can be used, so that we get more number of responses in
short period of time.

HR :
What do you want to be by 10 years from now? Do you have any idea or
you want life to just go like that?

Me :
No, sir. I have some plans.

HR :
What are those plans?

Me :
I would like to be in a good position like Team Lead. …

(There
was an interrupt asking whether the interviewers need coffee or
tender coconut. By the time they reply, I was thinking about how to
continue my answer).

Me :
Because, by 10 years, I might have got some experience and so, I
would like to be a team lead.

HR :
So, you have done lot of co-curricular activities. You’ve been a
bright student. What made you to do so?

Me :
It’s just because of the interest, sir. Every time I participate in
a contest, from the feedback, I try to improve myself. Hence, I could
gain new exposure and experience from each event.

(Now,
he wanted to complete filling the registration form and so, asked
questions about filling that.)

HR :
So, you’ve not worked with Accenture before, right?

Me :
Yes, sir. I have not.

HR :
No gaps between studies?

Me :
No gaps, sir.

HR :
Tell your work preference.

Me :
Sir, I would work at any place.

(He
kept me asking and I had been repeating the same for 3 times)

HR :
Chennai, Bangalore or Hyderabad. Which is your first preference?

Me :
Bangalore, sir.

HR :
Next preference?

Me :
Chennai, sir.

HR :
Third is Hyderabad, right?

Me :
Yes, sir. But, it’s not that I’ll be working only in these
places.

HR :
(After
writing down my preferences in the registration sheet, which also
acted as evaluation sheet). Do you have any more questions to ask?
(looking at Tech)

Tech
:
No.

(I
got up. They made a handshake with me. I thanked them and came out.)

After
the interview:

The
total interview was not more than 10 minutes. I came out with a
relaxation, spoke to my HOD (Dr. J. Akilandeswari) and former HOD
(Dr. B. Saravanan). Right from 10:45 am, I was staying in the college
waiting for the results. By 1:30 pm, the written round results were
announced where only 67 out of 200+ were selected for the interview.

Result
declaration:

We
all were waiting in the PG auditorium since 6:15 pm for the
declaration of the results. I had dinner by 7:30 pm in a nearby
hotel. Then, again we were waiting from 8:30pm. The results were
announced by 10pm. HODs of various departments, placement cell team,
Accenture recruiters, college chairman, secretary, principal and
several staff were also present at the auditorium while the results
were announced. The total count was 383, out of which, I was one
among them. Felt happy. But, as soon as the entire list of selected
candidates has been read by 11 pm, there were some weeping faces in
the auditorium. As I came out, I could see some parents giving sweet
to their children, who were Accenture employees from then.

One’s
birth and education becomes meaningful, only when his/her career
begins

Sunday, 16 September 2012

Introduction:
Most of the Java programmers might have worked with the (Ugly) syntax of an anonymous class. This post will cleanly explain the Ugly syntax (especially with Anonymous classes) of Java. For example, consider the button click event in Java Swing.

This is a very straight forward way, where each and every process is done step by step. Now, before moving on to the equivalent ugly syntax code, we must be knowing 5 Java concepts.

1. Interface object concept:

An interface can have an object to which, an object of one of the classes implementing it, can be assigned.For example, in the above code, ActionListener is an interface and e is an object of it. We have instantiated e by invoking the new operator on the EventHandler class (which implements the ActionListener interface).

2. Anonymous object concept:

The synonym for the term 'Anonymous' is 'nameless'. There might be some situations when we would require the object of a particular class, in just one statement. In such cases to avoid 2 lines of code, we may go for an Anonymous object.

For example:

ActionListener e = new EventHandler();

button_object.addActionListener(e);

could be written as

button_object.addActionListener(new EventHandler());

This is done purely to reduce the lines of code; however doing so affects the readability of the code, whereas the efficiency of the code remains unaltered.

3. Method implementation specific to an object:
While writing multi-threading code in Java, one might have written code something like this.

Thread t = new Thread()
{
public void run()
{
// Thread code
}
};

One can say that this code implements the method run(), which is specific to the object t.

4. Method implementation specific to an instance of an interface:
This is nothing but the combination of the concepts 1 and 3.This concept will be well understood with the following examples.

Sunday, 9 September 2012

As a Java programmer, everyone will know that Java can be embedded in Web pages as Applets. This post will show how an Applet can be embedded in a Web page, which is hosted in a free domain.

Step 1: Make the Java applet source file ready.

Step 2: Compile the Java applet to get the class file.

Step 3: Write an HTML code, embedding the Applet.
Step 4: Create a free domain using one of the free hosting services like 000webhost
Step 5: Upload the .class and the .html files into the same directory

Sunday, 2 September 2012

Initially I would like to inform that this post is not to hurt anybody. The only intension of this post is to make people to utilize the available resources efficiently

We, the homosapiens, keep telling that certain resources are not abundantly available. Now-a-days, electricity is very scarce in India. This is very evident as most of us might have been facing many problems because of frequent and unannounced power cuts.

Do you think that electricity is really insufficient ? That might be true to some extent, but, what I feel is that some people are overusing (and thereby wasting) it. The variations are very drastic in the country. When there is a group of people suffering because of power cut, there is a group which consumes electricity without any use. There are some people who are waiting for the power to type their documents in a computer. There are also people who keep their computer turned on the whole day whether or not they are using it.

Petrol hike keeps persisting because of the inefficient usage of it. People start preserving a thing, only when there occurs a scarcity. If a certain resource is abundantly available, we use it to a greater extent. Why not we preserve that particular resource inspite of its abundant availability ? We expect certain things as a rule. For example, some of us use helmets for the sake that it's compulsory and not for our own safety. Another example is the rain water harvesting scheme of Tamil Nadu government a few years ago.

I don't mean that we should limit the usage of resources. My point is that don't use any resource unless it is needed (or in other words, don't unnecessarily use any resource).

"It's our duty to leave behind all the resources to our future generations"

Sunday, 26 August 2012

On 25th of August, a group of more than 150 people from my college (Sona College of Technology), went to Infosys as an industrial visit. This post is about IT students' campus visit to Infosys, Bangalore.

My stay at hostel:

We had planned to depart at 3 am on 25th August. Since my home was far away from the college and there would not be sufficient transport facilities around the midnight, I went to the college hostel the previous day at 10 pm and stayed there in my friend, Vignesh's room. The stay in the hostel was a bit strange to me; everyone using laptops/desktops for browsing, playing games or listening to music; people walking in the corridor with mobiles in their hands; funny talks and many more scenes.

Departure:

On the day of our departure, almost everyone reached the college by 3:15 am. A group of 41 students (32 girls and 9 boys) and 2 staff from IT department departed the college campus sharp by 3:34 am in the bus (owned by Lakshmi Vilas), which we had booked. Unfortunately, no one had brought songs in pen drive and so, we couldn't listen to good songs. But, then, we watched the film titled 'Naan ee' (நான் ஈ). Some of us (including me) were sleeping in the bus (as we had waken up so early).

Infosys:

After having refreshment at Krishnagiri and breakfast at Hosur, we shifted to another (Karnataka registered) busin order to reduce the bus fare by minimizing the tollgate charge. The driver of that bus drove very fast and harsh. Holding breath, we were keenly looking for Infosys. By the time we reached Infosys, it was 9:12 am. But, they said that they couldn't let us in without the whole college assembling. The CSE department had departed the college only around 6 am and said that they would be reaching only after 10:30. Then, upon request, the Infosys organizers let the IT students and MCA students (who had already assembled by the time we reached Infosys) in.

The campus:

The campus was full of green plants and trees. There were many magnificent buildings. Seeing the surroundings of the campus, mind was very pleasing. We could see trees and buildings on all the directions. Then, after refreshment, we were made to sit in an auditorium, which also had a balcony. Some of us sat in the ground floor whereas the rest were sitting in the balcony.

Presentation:

There were 6 colleges including AVS Engineering College, Paavai College of Engineering, participating in this campus visit program. First of all, they asked our expectations in that program. One or two students from each college told their expectations, whereas 6 students represented Sona College. The entire session was co-ordinated by a person called 'Dattatreya'. Several other speakers also addressed on various topics. Time passed away so quickly and around 1:20, we were taken for lunch. After lunch and photographs, we went back to the auditorium.Interactive sessions: In the afternoon, there were 2 small interactive programs. Initially there was a story matching contest (by re-arranging the given sheets of papers) and then there was a group discussion, in which four people from each college were allowed to participate. I was one among them. Later, the do's and don'ts of a group discussion were listed. After that, the Curriculum Vitae structure and the most common interview questions were discussed. Finally, after writing feedback, they gave us the email ids of the volunteers, who co-ordinated the event. After the completion of the sessions, we came out of the campus by taking photographs all the way through.Return back: While returning back, after changing to Tamil Nadu bus, one of my professors, Mr. Ilanchezian and I kept discussing regarding various things for more than an hour till we reach Krishnagiri for dinner. After dinner, I went to the front side of the bus and slept till we reach the college. By the time, we all land in the college campus, it was 11:50 pm. I stayed in Vignesh's room in college hostel and returned back to my home the next day morning around 6:30 am.

Saturday, 4 August 2012

When I had been to internship at IIIT, Hyderabad during my fourth semester holidays, I kept reporting my work to my HOD (Dr. J. Akilandeswari) via email. She replied that it was her wish that I take a presentation on "Android application development" after my return to college, as I did my internship project on Android platform. Being a lover of sharing knowledge, I was overwhelmed with joy and immediately replied my acceptation to my HOD through mail.

Longing days:

After returning to my college, HOD specified a Saturday (August 4th, 2012) for doing the presentation and asked me to contact my lecturer, Mr. Murali, to make the hall arrangements. Everything were ready on 31st July and I was waiting for the day to come. At last, the day came and I did the presentation on "An introduction to Android application development" at PG auditorium of my college approximately about one hour and fifteen minutes for the 3rd year IT students.

Presentation:

This was the first time in my life doing a continuous presentation for more than an hour. Though I had stage fear during previous presentations and seminars, I couldn't find stage fear in myself during this presentation (might be because, I was doing announcements in different classes the previous week, regarding programming club, Aspirations - a programming contest conducted by Infosys every year and was taking classes in the programming club of my college). I think because of my confidence, I could explain clearly, whatever I intended to tell.

Feedback:

Some of my friends appreciated my confidence, professionalism and accent. Some added that they could understand the concepts very clearly, though they have attended Android workshops. Because of the lack of time, I could not complete explaining whatever I had prepared. But then, I was happy about the feedback given by my friends. I should really thank my HOD for giving me such a golden opportunity.