Wednesday, March 28, 2012

gcd calculator in c


c code to find gcd of two numbers


greatest common divisor of two numbers c++


greatest common divisor of 45 and 30


greatest common divisor c++


gcd code c


gcd code c++


Sunday, March 25, 2012

using #error in c


#error preprocessor example in c


#error example in c


#line preprocessor example in c

using #line in c


#line example in c


Saturday, March 17, 2012

#pragma preprocessor

#pragma is an implementation-defined directive that allows various instructions to be given to the compiler. For example, a compiler may have an option that supports program execution tracing. A trace option would then be specified by a #pragma statement. You must check the compiler's documentation for details and options.

The #pragma directive provides a way to request special behavior from the compiler. This directive is most useful for programs that are unusually large or that need to take advantage of the capabilities of a particular compiler. Pragmas are used within the source program.

#pragma token(s)

pragma is usually followed by a single token, which represents a command for the compiler to obey. You should check the software implementation of the C standard you intend on using for a list of the supported tokens. Not surprisingly, the set of commands that can apear in #pragma directives is different for each compiler; you'll have to consult the documentation for your compiler to see which commands it allows and what those commands do.

For instance one of the most implemented preprocessor directives, #pragma once when placed at the beginning of a header file, indicates that the file where it resides will be skipped if included several times by the preprocessor.

#pragma in c

#pragma is an implementation-defined directive that allows various instructions to be given to the compiler. For example, a compiler may have an option that supports program execution tracing. A trace option would then be specified by a #pragma statement. You must check the compiler's documentation for details and options.

The #pragma directive provides a way to request special behavior from the compiler. This directive is most useful for programs that are unusually large or that need to take advantage of the capabilities of a particular compiler. Pragmas are used within the source program.

#pragma token(s)

pragma is usually followed by a single token, which represents a command for the compiler to obey. You should check the software implementation of the C standard you intend on using for a list of the supported tokens. Not surprisingly, the set of commands that can apear in #pragma directives is different for each compiler; you'll have to consult the documentation for your compiler to see which commands it allows and what those commands do.

For instance one of the most implemented preprocessor directives, #pragma once when placed at the beginning of a header file, indicates that the file where it resides will be skipped if included several times by the preprocessor.

#line preprocessor

The #line directive changes the contents of _ _LINE_ _ and _ _FILE_ _ , which are predefined identifiers in the compiler. The _ _LINE_ _ identifier contains the line number of the currently compiled line of code. The _ _FILE_ _ identifier is a string that contains the name of the source file being compiled. The general form for #line is

#line number "filename"

where number is any positive integer and becomes the new value of _ _LINE_ _ , and the optional filename is any valid file identifier, which becomes the new value of _ _FILE_ _. #line is primarily used for debugging and special applications.

For example, the following code specifies that the line count will begin with 100. The printf() statement displays the number 102 because it is the third line in the program after the #line 100 statement.

#include <stdio.h>
#line 100 /* reset the line counter */

int main(void) /* line 100 */
{ /* line 101 */
printf("%d\n",__LINE__); /* line 102 */
return 0;
}

#line in c

The #line directive changes the contents of _ _LINE_ _ and _ _FILE_ _ , which are predefined identifiers in the compiler. The _ _LINE_ _ identifier contains the line number of the currently compiled line of code. The _ _FILE_ _ identifier is a string that contains the name of the source file being compiled. The general form for #line is

#line number "filename"

where number is any positive integer and becomes the new value of _ _LINE_ _ , and the optional filename is any valid file identifier, which becomes the new value of _ _FILE_ _. #line is primarily used for debugging and special applications.

For example, the following code specifies that the line count will begin with 100. The printf() statement displays the number 102 because it is the third line in the program after the #line 100 statement.

#include <stdio.h>
#line 100 /* reset the line counter */

int main(void) /* line 100 */
{ /* line 101 */
printf("%d\n",__LINE__); /* line 102 */
return 0;
}

#line directive in c

The #line directive changes the contents of _ _LINE_ _ and _ _FILE_ _ , which are predefined identifiers in the compiler. The _ _LINE_ _ identifier contains the line number of the currently compiled line of code. The _ _FILE_ _ identifier is a string that contains the name of the source file being compiled. The general form for #line is

#line number "filename"

where number is any positive integer and becomes the new value of _ _LINE_ _ , and the optional filename is any valid file identifier, which becomes the new value of _ _FILE_ _. #line is primarily used for debugging and special applications.

For example, the following code specifies that the line count will begin with 100. The printf() statement displays the number 102 because it is the third line in the program after the #line 100 statement.

#include <stdio.h>
#line 100 /* reset the line counter */

int main(void) /* line 100 */
{ /* line 101 */
printf("%d\n",__LINE__); /* line 102 */
return 0;
}

#undef in c

The #undef directive removes a previously defined definition of the macro name that follows it. That is, it "undefines" a macro. The general form for #undef is

#undef macro-name

For example,

#define LEN 100
#define WIDTH 100

char array[LEN][WIDTH];

#undef LEN
#undef WIDTH

/* at this point both LEN and WIDTH are undefined */

Both LEN and WIDTH are defined until the #undef statements are encountered. #undef is used principally to allow macro names to be localized to only those sections of code that need them.

#undef directive

The #undef directive removes a previously defined definition of the macro name that follows it. That is, it "undefines" a macro. The general form for #undef is

#undef macro-name

For example,

#define LEN 100
#define WIDTH 100

char array[LEN][WIDTH];

#undef LEN
#undef WIDTH

/* at this point both LEN and WIDTH are undefined */

Both LEN and WIDTH are defined until the #undef statements are encountered. #undef is used principally to allow macro names to be localized to only those sections of code that need them.

#undef

The #undef directive removes a previously defined definition of the macro name that follows it. That is, it "undefines" a macro. The general form for #undef is

#undef macro-name

For example,

#define LEN 100
#define WIDTH 100

char array[LEN][WIDTH];

#undef LEN
#undef WIDTH

/* at this point both LEN and WIDTH are undefined */

Both LEN and WIDTH are defined until the #undef statements are encountered. #undef is used principally to allow macro names to be localized to only those sections of code that need them.

#error directive

#error

The #error directive forces the compiler to stop compilation. It is used primarily for debugging. The general form of the #error directive is

#error error-message

The error-message is not between double quotes. When the #error directive is encountered, the error message is displayed, possibly along with other information defined by the compiler.

#error in c

#error

The #error directive forces the compiler to stop compilation. It is used primarily for debugging. The general form of the #error directive is

#error error-message

The error-message is not between double quotes. When the #error directive is encountered, the error message is displayed, possibly along with other information defined by the compiler.