Wednesday, July 17, 2013

What happens if we don't use address-of in scanf

In C, while using the scanf() function, we have to specify arguments with address-of(&) operator to take the values which we give into the variables. But what happens when we don't place the address of operator? Does it return a error or works well?

Check out the following program to understand it well.

Sunday, July 14, 2013

Program with Increment Operators in printf()

We have observed a program on Increment Operators when assigned to variable. If not, click here.
We have clearly understand how to analyze the pre-Increment and post-Increment Operators in such a case and ho w the values are manipulated when it is such a case. But what happens when we use the same expression in printf(). Does the result is same or any change occurs?

Consider the following example,

Program on Increment Operator

Most of the people are confused every time in analyzing the Increment Operators because they actually do. We should be careful in analyzing the Pre-Increment and Post-Increment Operators.

In most of the competitive exams, we come across a problem on Increment Operators. We should be careful enough in solving the problems on Increment Operators.

Consider the following example, to understand the Increment and Decrement Operators.

Saturday, July 13, 2013

Switch Statement with float in C

We know that Switch Statement takes only integer values for switching to cases. But what happens if we place a float value in the switch statement. Does it return a error or it executes successfully?

Consider the following example, to understand about this concept.

Friday, July 12, 2013

Switch case with char in C

We know that switch case statement works only with integer values. But what happens when we use char values?Does it return any error? Does it works?

To answer your questions, here is a program, which takes the char input and performs the switch case operation. Check out the below example and you will understand what happens.

Wednesday, July 10, 2013

What happens to Operator Precedence in Compound Assignment

We know that as per the Operator precedence, the multiplication has more precedence than that of addition. Also we know that in when we write a compound assignment notation as,
x*=3, it means x=x*3;
So, when it comes to a equation like,
x*=a+b, 
What happens with the equation. How does the Operator precedence takes place. Check out the following program first,

Monday, July 8, 2013

Assigning float value to int type

In general, if we assign the integer value to the float type, it automatically converts the type to float by just adding the decimal points.

For example,
float a=3;
It takes the value as 3.000000. You can understand this by referring to the concept of Type casting by clicking here.

But what happens if we assign float to int? Does it give an error? Let us check it now.

Sunday, July 7, 2013

Printf in a Printf Statement

I think most of you know what an Expression means, if not click here.

So we are moving on to the complex part of the expressions, What happens when a printf() statement is included in a expression???

Before knowing about it, we go on with a simple example of expression

x=3+(y=5+6)
Do you know what would be the result of the expression, it just gives a value of 5+6 i.e., 11 to y and the value of x would be 3+y i.e., 3+11 and the value is 14.

Friday, July 5, 2013

Printf with More Format Specifiers

We know that printf() function is responsible for printing something to the Output in C. Generally we write a printf() function with a string in it to be printed, or a string with format specifiers, followed by the variables which should take place of the format specifiers.

For example,


  1. #include<stdio.h>
  2. main()
  3. {
  4. int a=5;
  5. printf("Hello\n");
  6. printf("Your number is %d", a);
  7. }
For the above program, the output turns out to be as

Hello
Your number is 5

But if it has more or less number of format specifiers, then what happens???

Saturday, June 29, 2013

Program without a Main Function

We would be wondering that we can write a C program without a main function. Generally we know that a C program cannot be executed without a main function. But we can execute it without main. Just try out the code below, it works fine even without a main function in it.

#include<stdio.h>
#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)
int begin()
{
printf(” hello “);
}