Introduction To Programming

Why programs ? Programming is nothing but making the computers think the same way a human thinks. Programs are made for obtaining a specific solution which can even be solved by humans which when solved by us may consume time..

Saturday, March 6, 2010

55

#include< stdio.h >
main()
{
int a=1;
a=a+++a;
printf("%d",a);
}


output


3
Logic:
while reading the token , it is read by character by character from left to right(->)
so, the operation is equal to a++ +a.
op.jpg

break statement

break statement terminate loop.

int main()
{
int i;
for(i=0;i<2;i++)
{
printf("Before break statement");
break;
printf("After break statement");
}
return 0;
}

Output


Before break statement

Continue Statement

The remaining loop statements after continue statement are skipped and the computation proceeds directly to the next pass through the loop.

consider this eg:

int main()
{
int i;
for(i=0;i < 2;i++)
{
printf("Before continue statement");
continue;
printf("After continue statement");
}
return 0;
}

Output


Before continue statement
Before continue statement


Logic


In this program,compiler show one warning "Unreachable Code".
all statement which are after continue statement will be skipped.
so printf("After continue statement"); is unreachable code(This statement will not be execute ).
so the operation will be like this,