C Program to Find Total of Even Integers

C Libraries – Quick Guide

Everyone knows core of the C language is small and very simple to use, and special functionality is provided in the form of libraries of ready-made functions. Some of C libraries are provided for you, giving you access to many special abilities without needing to reinvent the wheel. You can also make your own, but to do so you need to know how your operating system builds libraries.

C Libraries are files of ready-compiled code which we can merge with a C program at compilation time. Each library comes with a number of associated header files which make the functions easier to use.

For example, there are libraries of mathematical functions, string handling functions and input/output functions and graphics libraries. It is up to every programmer to make sure that libraries are added at compilation time by typing an optional string to the compiler.

cc -o program_name prog.c –lm

when you compile the program. The ‘-lm’ means: add in ‘libm’. If we wanted to add in the socket library ‘libsocket.a’ to do some network programming as well, we would type

cc -o program_name prog.c -lm –lsocket

These C libraries are not included automatically because it would be a waste for the compiler to add on lots of code for maths functions, say, if they weren’t needed. When library functions are used in programs, the appropriate library code is included by the compiler, making the resulting object code often much longer.


C Libraries with Examples

C Libraries are supplemented by header files which define macros, data types and external data to be used in conjunction with the libraries. Once a header file has been included, it has effectively added to the list of reserved words and commands in the language. You cannot then use the names of functions or macros which have already been defined in libraries or header files to mean anything other than what the library specifies.

The most commonly used header file is the standard input/output library which is called ‘stdio.h’. This belongs to a subset of the standard C library which deals with file handling. The ‘math.h’ header file belongs to the math- ematics library ‘libm.a’. Header files for libraries are included by adding to the source code:

#include header.h

at the top of a program file. For instance:

#include "myheader.h"

includes a personal header file which is in the current directory. Or

#include <stdio.h>

includes a file which lies in a standard directory like ‘/usr/include’. The #include directive is actually a command to the C preprocessor, Some functions can be used without having to include library files or special libraries explicitly since every program is always merged with the standard C library, which is called ‘libc’

#include <stdio.h>
main ()
{
printf ("C standard I/O file is included\n");
printf ("Hello world!");

The program wishing to use a mathematical function such as cos would need to include a mathematics library header file.

#include <stdio.h>
#include <math.h>
main ()
{ double x,y;
y = sin (x);
printf ("Maths library ready");
}

The particular operating system might require its own special library for certain operations such as using a mouse or for opening windows in a GUI environment, for example. These details will be found in the local manual for a particular C compiler or operating system.

Online Training Tutorials

  • C Program to Find Total of Even IntegersC Tutorial – Learn C Programming Language TutorialLearn C programming is very easy if you follow our popular C tutorial which will take you from the beginning of C programming. This C tutorial is mainly designed for beginners and […]
  • JavaScript BooleanJavaScript BooleanJavaScript Boolean, It is often useful to have a value that distinguishes between only two possibilities, like “yes” and “no” or “on” and “off”. For this purpose, JavaScript has Boolean […]
  • Interest calculationInterest Calculation Process in SAPFirst the program identifies the items on which Interest calculation is to be calculated according to the rules defined in the interest indicator, and any additional specifications you […]
  • Company and company code defines and maintain by FICO consultants.How to Create Company Code and Assign to Company?Tutorial to Create Company code : We can have the 2 basic steps, what is company, and how to create company code, and How to assign company code to company as per below,  Company: […]
  • Installation of Presentation ServerHow to do Installation of Presentation Server (SAPGUI)?Everyone have question, How to do Installation of Presentation Server : Use presentation server DVD and go to the respective OS win32 and run setupall.exe and follow the onscreen […]
  • C Program to Find Total of Even IntegersC Program to Concatenation of StringsThe C program Concatenation of Strings is given below example. The names of employees of an organization are stored in three arrays, namely first_name, second_name, and last_name. Write […]
  • erp implementation failuresERP implementation failures – List out the reasonsMajor reasons for ERP implementation failures, Poor ERP Package Selection: Poor package selection occurs when a company has inadequately developed functional requirements definitions. […]
  • Master contractThe SD Master Contract Structure and How its Configured?A Master contract consists of other contracts that are grouped as lower level contracts. Thus, that the master contract has the general data that is relevant for all the levels of […]