Pages

Search This Site..

Jun 9, 2012

C Aptitude 18
C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc.

In this site, we have discussed various type of C programs till date and from now on, we will move further by looking at the C aptitude questions.

In the coming days, we will post C aptitude questions, answers and explanation for interview preparations.

The C aptitude questions and answers for those questions along with explanation for the interview related queries.

We hope that this questions and answers series on C program will help students and freshers who are looking for a job, and also programmers who are looking to update their aptitude on C program.
Some of the illustrated examples will be from the various companies, and IT industry experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.

Explanation: In first sizeof, str1 is a character pointer so it gives you the size of the pointer variable. In second sizeof the name str2 indicates the name of the array whose size is 5 (including the '\0' termination character). The third sizeof is similar to the second one.

C aptitude 18.2

main()
{
char not;
not=!2;
printf("%d",not);
}

Answer: 0
Explanation:! is a logical operator. In C the value 0 is considered to be the boolean value FALSE, and any non-zero value is considered to be the boolean value TRUE. Here 2 is a non-zero value so TRUE. !TRUE is FALSE (0) so it prints 0.

Explanation: The input program to the compiler after processing by the preprocessor is,
main()
{
if(0)
puts("NULL");
else if(-1)
puts("TRUE");
else
puts("FALSE");
}
Preprocessor doesn't replace the values given inside the double quotes. The check by if condition is boolean value false so it goes to else. In second if -1 is boolean value true hence "TRUE" is printed.

Jun 7, 2012

In this post, we are giving the some tips on how to prepare and write the C aptitude exams.
Dear friends while you are attending an interview,these days almost all companies have the C aptitude round for the freshers, so be prepare for an interview.
Preparation for C aptitude exams:"One important key to success is self-confidence.An important key to self-confidence is preparation"
- Arthur Ashe.
Preparation for an interview is not an one day preparation before interview process,
So Don't wait for an interview call, be updated every day. Preparation for an interview is not an easy thing,
you should know all the details about the attending company, interview pattern, company structure, depth in concepts, and more.
Every job interview question is asked to test your skill, so be prepare for your interview.
Study the Basic concepts:
You should know the basic knowledge of the language. Read more and more c language books of

different authors,recall your study materials, and try to understand the concepts like structures,

pointers, arrays, and etc. Don't simply read the concepts, try to under stand it, and solve the problems on it.

Invest on good C aptitude, C language books surely these books are returns the good knowledge on C program.
Point it down
How much you are studied is not an important thing, what you really understand at the end

of the day is important. While attending the aptitude tests be specific is very important,

for that you should memorize the things what you are studied, so while preparing just note down the important

things or underline it or use the flash cards for memorizing.
Solve, Solve,and Solve
Solve the more and more examples available on C. Try to solve the C Aptitude questions from various books or websites, it gives the strong hands on C.
Try to solve the C online tests, it is very help full to manage the time and you can know about your capability. Depends on the score you can take the more difficult tests.
Look at the history
Format/type of test isn’t a huge surprise, so try to solve the attending company previous papers. They are not repeat the same questions, but pattern and concept are the same. By solving the previous year papers you have an idea what to except.
How to write the C Aptitude exams?

“Strength of mind is exercise, not rest.”

- Alexander Pope

Each and every interview attending is a technique or a skill, you should know about an interview techniques,

interview questions pattern or type of interview. C aptitude round is the one which finds the real talent of your programming skill, your IQ, and how you are solving the problems in the given time inter well.
Time is the key
In the C Aptitude test round companies are giving very less time and more questions, So don't waste the time while answering.
Read the question carefully and understand it quickly. Don't confused with questions it take more time.

First try to solve the questions on which you are very well known concepts,

i.e. if you are good in pointers just solve the pointers questions first, then try the other questions, it helps you to score more.

Don't waste the time on one single question, if you didn't get it, just move forward after finishing other one's if you have a more enough time then attend that type of questions.
Be specific
Don't guess the answer just by looking at it, it surely looses your marks. Try to solve the

each and every question by paper work.
If you are really prepared and you know the concept very well you will get the answer which is in the options list.
For example:
Predict the output or error(s) for the following:

main()
{
int i=-1;
+i;
printf("i = %d\n\n",+i);
}

Options:
a. i = 0
b. i = 1
c. i = 2
d. i = -1
if you don't know the concept of unary operators, and you are going to guessing it, by looking at the +i, you will choose b or c both are wrong.
Unary + is the only dummy operator in C. Where-ever it comes you can just ignore it just because it has no effect in the expressions (hence the name dummy operator) so answer is -1.
Compiler depends
Some C puzzles are really very tricky be care full while answering those questions.
For example:
Predict the output or error(s) for the following:

Options:
a.Value of x = 6 and Value of y = 30
b.Value of x = 7 and Value of y = 42
c.Value of x = 7 and Value of y = 49
d.Compiler dependent
In this question most of the compilers produce the answer c,because in any expression pre

increment operator has a higher priority than arithmetic operator as a result value of x is increment

is first two times then value of y is evaluated.But some compilers may produce an entire different outputs,

so there is a choice compiler dependent, so the answer is d.

Contrary methods

In some cases if you don't know the answer, you can find the answer by looking at the options.
Example:
Predict the output or error(s) for the following:

Options:
a.six
b.3
c.three
d.four
In this question if you don't know any thing about switch statement, but by looking at the options, you can easily point out that six, 3, four are not the answers, so answer is three.
Dear friends be prepare for your interviews and be confident. Don't blame your luck

after every interview, Best of luck for your interviews

"Luck is where opportunity meets preparation". Best of luck for your interviews.
-Denzel Washington

You can easily select the code by double clicking on the code area above.

C Aptitude 17
C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc.

In this site, we have discussed various type of C programs till date and from now on, we will move further by looking at the C aptitude questions.

In the coming days, we will post C aptitude questions, answers and explanation for interview preparations.

The C aptitude questions and answers for those questions along with explanation for the interview related queries.

We hope that this questions and answers series on C program will help students and freshers who are looking for a job, and also programmers who are looking to update their aptitude on C program.
Some of the illustrated examples will be from the various companies, and IT industry experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.

Explanation: sserts are used during debugging to make sure that certain conditions are satisfied. If assertion fails, the program will terminate reporting the same. After debugging use,
#undef NDEBUG
and this will disable all the assertions from the source code. Assertion
is a good debugging tool to make use of.

C aptitude 17.2

main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
}

Answer: i = -1, +i = -1

Explanation:Unary + is the only dummy operator in C. Where-ever it comes you can just ignore it just because it has no effect in the expressions (hence the name dummy operator).

Explanation: You can create a variable of type void * but not of type void, since void is an empty type. In the second line you are creating variable vptr of type void * and v of type void hence an error.

C Aptitude 16
C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc.

In this site, we have discussed various type of C programs till date and from now on, we will move further by looking at the C aptitude questions.

In the coming days, we will post C aptitude questions, answers and explanation for interview preparations.

The C aptitude questions and answers for those questions along with explanation for the interview related queries.

We hope that this questions and answers series on C program will help students and freshers who are looking for a job, and also programmers who are looking to update their aptitude on C program.
Some of the illustrated examples will be from the various companies, and IT industry experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.

Explanation: Since a void pointer is used it can be type casted to any other type pointer. vp = &ch stores address of char ch and the next statement prints the value stored in vp after type casting it to the proper data type pointer. the output is ‘g’. Similarly the output from second printf is ‘20’. The third printf statement type casts it to print the string from the 4th value hence the output is ‘fy’.

Explanation:In this problem we have an array of char pointers pointing to start of 4 strings. Then we have ptr which is a pointer to a pointer of type char and a variable p which is a pointer to a pointer to a pointer of type char. p hold the initial value of ptr, i.e. p = s+3. The next statement increment value in p by 1 , thus now value of p = s+2. In the printf statement the expression is evaluated *++p causes gets value s+1 then the pre decrement is executed and we get s+1 – 1 = s . the indirection operator now gets the value from the array of s and adds 3 to the starting address. The string is printed starting from this position. Thus, the output is ‘ck’.

Explanation: Here a string (a pointer to char) is initialized with a value “girl”. The strlen function returns the length of the string, thus n has a value 4. The next statement assigns value at the nth location (‘\0’) to the first location. Now the string becomes “\0irl” . Now the printf statement prints the string after each iteration it increments it starting position. Loop starts from 0 to 4. The first time x[0] = ‘\0’ hence it prints nothing and pointer value is incremented. The second time it prints from x[1] i.e “irl” and the third time it prints “rl” and the last time it prints “l” and the loop terminates.

Jun 6, 2012

C Aptitude 15
C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc.

In this site, we have discussed various type of C programs till date and from now on, we will move further by looking at the C aptitude questions.

In the coming days, we will post C aptitude questions, answers and explanation for interview preparations.

The C aptitude questions and answers for those questions along with explanation for the interview related queries.

We hope that this questions and answers series on C program will help students and freshers who are looking for a job, and also programmers who are looking to update their aptitude on C program.
Some of the illustrated examples will be from the various companies, and IT industry experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.

Predict the output or error(s) for the following:

C aptitude 15.1

main()
{
extern out;
printf("%d", out);
}
int out=100;

Answer: 100

Explanation: This is the correct way of writing the previous program 14.3

C aptitude 15.2

main()
{
show();
}
void show()
{
printf("I'm the greatest");
}

Answer: Compier error: Type mismatch in redeclaration of show.

Explanation:When the compiler sees the function show it doesn't know anything about it. So the default return type (ie, int) is assumed. But when compiler sees the actual definition of show mismatch occurs since it is declared as void. Hence the error.
The solutions are as follows:
1. declare void show() in main() .
2. define show() before main().
3. declare extern void show() before the use of show().

Explanation: Error is in line with statement a++. The operand must be an lvalue and may be of any of scalar type for the any operator, array name only when subscripted is an lvalue. Simply array name is a non-modifiable lvalue.

Jun 5, 2012

C Aptitude 14
C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc.

In this site, we have discussed various type of C programs till date and from now on, we will move further by looking at the C aptitude questions.

In the coming days, we will post C aptitude questions, answers and explanation for interview preparations.

The C aptitude questions and answers for those questions along with explanation for the interview related queries.

We hope that this questions and answers series on C program will help students and freshers who are looking for a job, and also programmers who are looking to update their aptitude on C program.
Some of the illustrated examples will be from the various companies, and IT industry experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.

Explanation: in the end of nested structure yy a member have to be declared

C aptitude 14.2

main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}

Answer: Linker error: undefined symbol 'i'.

Explanation:extern declaration specifies that the variable i is defined somewhere else. The compiler passes the external variable to be resolved by the linker. So compiler doesn't find an error. During linking the linker searches for the definition of i. Since it is not found the linker flags an error.

C aptitude 14.3

main()
{
printf("%d", out);
}
int out=100;

Answer: Compiler error: undefined symbol out in function main.

Explanation: The rule is that a variable is available for use from the point of declaration. Even though a is a global variable, it is not available for main.

Jun 4, 2012

C Aptitude 13
C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc.

In this site, we have discussed various type of C programs till date and from now on, we will move further by looking at the C aptitude questions.

In the coming days, we will post C aptitude questions, answers and explanation for interview preparations.

The C aptitude questions and answers for those questions along with explanation for the interview related queries.

We hope that this questions and answers series on C program will help students and freshers who are looking for a job, and also programmers who are looking to update their aptitude on C program.
Some of the illustrated examples will be from the various companies, and IT industry experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.

Predict the output or error(s) for the following:

C aptitude 13.1

ain()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
}

Answer: 1

Explanation: before entering into the for loop the checking condition is "evaluated". Here it evaluates to 0 (false) and comes out of the loop, and i is incremented (note the semicolon after the for loop).

Explanation:p is pointing to character '\n'.str1 is pointing to character 'a' ++*p meAnswer:"p is pointing to '\n' and that is incremented by one." the ASCII value of '\n' is 10. then it is incremented to 11. the value of ++*p is 11. ++*str1 meAnswer:"str1 is pointing to 'a' that is incremented by 1 and it becomes 'b'. ASCII value of 'b' is 98. both 11 and 98 is added and result is subtracted from 32.
i.e. (11+98-32)=77("M");

Jun 3, 2012

C Aptitude 12
C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc.

In this site, we have discussed various type of C programs till date and from now on, we will move further by looking at the C aptitude questions.

In the coming days, we will post C aptitude questions, answers and explanation for interview preparations.

The C aptitude questions and answers for those questions along with explanation for the interview related queries.

We hope that this questions and answers series on C program will help students and freshers who are looking for a job, and also programmers who are looking to update their aptitude on C program.
Some of the illustrated examples will be from the various companies, and IT industry experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.

Predict the output or error(s) for the following:

C aptitude 12.1

void main()
{
int i=5;
printf("%d",i+++++i);
}

Answer: Compiler Error

Explanation: The expression i+++++i is parsed as i ++ ++ + i which is an illegal combination of operators.