Academic Tutorials



English | French | Portugese | Dutch | Italian
Google

Online

À la maison Codes sources E-Livres Téléchargements Nous contacter Au sujet de nous

HTML Tutorials
HTML Tutorial
XHTML Tutorial
CSS Tutorial
TCP/IP Tutorial
CSS 1.0
CSS 2.0
HLML
XML Tutorials
XML Tutorial
XSL Tutorial
XSLT Tutorial
DTD Tutorial
Schema Tutorial
XForms Tutorial
XSL-FO Tutorial
XML DOM Tutorial
XLink Tutorial
XQuery Tutorial
XPath Tutorial
XPointer Tutorial
RDF Tutorial
SOAP Tutorial
WSDL Tutorial
RSS Tutorial
WAP Tutorial
Web Services Tutorial
Browser Scripting
JavaScript Tutorial
VBScript Tutorial
DHTML Tutorial
HTML DOM Tutorial
WMLScript Tutorial
E4X Tutorial
Server Scripting
ASP Tutorial
PERL Tutorial
SQL Tutorial
ADO Tutorial
CVS
Python
Apple Script
PL/SQL Tutorial
SQL Server
PHP
.NET (dotnet)
Microsoft.Net
ASP.Net
.Net Mobile
C# : C Sharp
ADO.NET
VB.NET
VC++
Multimedia
SVG Tutorial
Flash Tutorial
Media Tutorial
SMIL Tutorial
Photoshop Tutorial
Gimp Tutorial
Matlab
Gnuplot Programming
GIF Animation Tutorial
Scientific Visualization Tutorial
Graphics
Web Building
Web Browsers
Web Hosting
W3C Tutorial
Web Building
Web Quality
Web Semantic
Web Careers
Weblogic Tutorial
SEO
Web Site Hosting
Domain Name
Java Tutorials
Java Tutorial
JSP Tutorial
Servlets Tutorial
Struts Tutorial
EJB Tutorial
JMS Tutorial
JMX Tutorial
Eclipse
J2ME
JBOSS
Programming Langauges
C Tutorial
C++ Tutorial
Visual Basic Tutorial
Data Structures Using C
Cobol
Assembly Language
Mainframe
Forth Programming
Lisp Programming
Pascal
Delphi
Fortran
OOPs
Data Warehousing
CGI Programming
Emacs Tutorial
Gnome
ILU
Soft Skills
Communication Skills
Time Management
Project Management
Team Work
Leadership Skills
Corporate Communication
Negotiation Skills
Database Tutorials
Oracle
MySQL
Operating System
BSD
Symbian
Unix
Internet
IP-Masquerading
IPC
MIDI
Software Testing
Testing
Firewalls
SAP Module
ERP
ABAP
Business Warehousing
SAP Basis
Material Management
Sales & Distribution
Human Resource
Netweaver
Customer Relationship Management
Production and Planning
Networking Programming
Corba Tutorial
Networking Tutorial
Microsoft Office
Microsoft Word
Microsoft Outlook
Microsoft PowerPoint
Microsoft Publisher
Microsoft Excel
Microsoft Front Page
Microsoft InfoPath
Microsoft Access
Accounting
Financial Accounting
Managerial Accounting


Introduction à la programmation de C


Previous Next





  1. En 1972, C a été développé aux laboratoires de Bell par Dennis Ritchie.



  2. C est un langage de programmation simple avec relativement un simple pour comprendre la syntaxe et peu de mots-clés.


  3. C est inutile. C lui-même n'a aucune commande d'entrée-sortie, n'a pas le soutien des cordes car un type de données fondamental. Il n'y a aucune fonction utile de maths établie po.



  4. C exige l'utilisation des bibliothèques car C est inutile par lui-même. Ceci augmente la complexité de l'utilisation de C.The des bibliothèques de norme ANSI et d'autres méthodes, la question des bibliothèques standard est résolues.






C programmant : : Un programme rapide du monde de Hellow

Let's give a simple program that prints out "Hello World" to standard out. We'll call our program as hello.c.

#include <stdio.h>

main() {
printf("Hello, world!\n");
return 0;
}



Explanation of The Above Code:

  • #include <stdio.h> -This line tells the compiler to include this header file for compilation.

    • What is header file?They contain prototypes and other compiler/pre-processor directive.Prototypes are also called the basic abstract function definitions.



    • Some common header files are stdio.h,stdlib.h, unistd.h and math.h.



  • main()- This is a function, in particular it is the main block.


  • { } - These curly braces are equivalent to the stating that "block begin" and "block end".These can be used at many places,such as switch and if statement.



  • printf() - This is the actual print statement which is used in our c program fraquently.we have header file stdio.h! But what it does? How it is defined?



  • return 0-What is this? Who knows what is this


Seems like trying to figure out all this is just way too confusing.

  • Then the return 0 statement. Seems like we are trying to give something back, and it gives the result as an integer. Maybe if we modified our main function definition: int main() ,now we are saying that our main function will be returning an integer!So,you should always explicitly declare the return type on the function.



  • Let us add #include <stdlib.h> to our includes. Let's change our original return statement to return EXIT_SUCCESS;. Now it makes sense!



  • printf always returns an int. The main pages say that printf returns the number of characters printed.It is good programming practice to check for return values. It will not only make your program more readable, but at the end it will make your programs less error prone. But we don't really need it in this particular case.So we cast the function's return to (void). fprintf,exit and fflush are the only functions where you should do this.



  • What about the documentation? We should probably document some of our code so that other people can understand what we are doing. Comments in the C89 standard are noted by this: /* */. The comment always begins with /* and ends with */.




An Improved Code of The Above Example
#include <stdio.h> #include <stdlib.h>

/* Main Function
* Purpose: Controls our program, prints Hello, World!
* Input: None
* Output: Returns Exit Status
*/

int main() {
(void)printf("Hello, world!\n");
return EXIT_SUCCESS;
}

Note:

The KEY POINT of this whole introduction is to show you the fundamental difference between understandability and correctness. If you lose understandability in an attempt to gain correctness, you will lose at the end. Always place the understandability as a priority ABOVE correctness. If a program is more understandable in the end,the chances it can be fixed correctly will be much higher. It is recommend that you should always document your program. You stand less of a chance of screwing up your program later,if you try to make your program itself more understandable.




The advantages of C

In other words,for writing anything from small programs for personal amusement to complex industrial applications,C is one of a large number of high-level languages designed for general-purpose programming.

C has many advantages:

  • Before C,machine-language programmers criticized high-level languages because,with their black box approach,they shielded the user from the working details of all its facilities and the computer. To give access to any level of the computer down to raw machine language,however, C was designed and because of this, it is perhaps the most flexible high-level language.



  • To organize programs in a clear,easy,logical way,C has features that allow the programmer.For example,C allows meaningful names for variables without any loss of efficiency, yet it gives a complete freedom of programming style,a set of flexible commands for performing tasks repetitively (for, while,do) and including flexible ways of making decisions.



  • C is also succinct. It permits the creation of tidy and compact programs. This feature can be a mixed blessing, however, and the C programmer must balance readability and simplicity.



  • C allows commands that are invalid in some other languages. This is no defect, but a powerful freedom which, when used with caution, makes many things easily possible. It does mean that there are concealed difficulties in C, but if you write thoughtfully and carefully, you can create fast, efficient programs.



  • With C, you can use every resource of your computer offers. C tries to link closely with the local environment, providing facilities for gaining access to common peripherals like printers and disk drives.




The C Compilation Model



Creating, Compiling and Running Your Program
Creating the program

First create a file containing the complete program, such as the above example. You can use any ordinary editor to create the file. One such editor is textedit which is available on most UNIX systems.

The filename must have extension ``.c'' (full stop, lower case c), e.g. myprog.c or progtest.c. The contents must have to obey C syntax. For example, they might be as in the above example,starting with the line /* /* end of the program */.




Compilation

There are many C compilers are present around. The cc is being the default Sun compiler. The GNU C compiler gcc is popular and also available for many platforms. PC users may also be familiar with Borland bcc compiler.

There are also C++ compilers which are usually denoted by CC (note upper case CC.For example Sun provides GNU and CCGCC. The GNU compiler is also denoted by the command g++

Other C/C++ compilers also exist. All the above compilers operate in essentially the share many common command line options and same manner. However, the best source of each compiler is through online manual pages of your system: e.g. man cc.

In the basic discussions of compiler operation,for the sake of compactness,we will simply refer to the cc compiler -- other compilers can simply be substituted in place of cc until and unless otherwise stated.

Your program simply invoke the command cc to Compile . The command must be followed by the name of the (C) program you wish to compile it.

The compilation command is:

    cc program.c

where program.c is name of the file.

If there are obvious errors in your program (such as mistypings, misspelling one of the key words or omitting a semi-colon), the compiler will detect it and report them.

It may possible that the compiler cannot detect logical errors.

If the compiler option -o is used : the file listed after the -oor when the compiler has successfully digested your program, the compiled version, or executable, is left in a file called a.out

It is convenient to use a -o and filename in the compilation as in

    cc -o program program.c

which puts the compiled program into the file program ( any file you name following the "-o" argument) instead of putting it in the file a.out .




Running the program

The next stage is to run your executable program.You simply type the name of the file containing it, in this case program (or a.out),to run an executable in UNIX.

This executes your program able to print any results to the screen. At this stage there may be run-time errors, such as it may become evident that the program has produced incorrect output or division by zero.

If so, you must return to edit your program source, and compile it again, and run it again.




C is a High Level Language

C is also called as a high-level language. To give a list of instructions (a computer program) to a computer,the high-level computer language is used. The native language of the computer is a stream of numbers called machine level language. As you might expect, the action resulting from a single machine language instruction is very primitive, and many thousands of them can be required to do something like substantial. A high-level language provides a set of instructions you can recombine creatively and give to the imaginary black boxe of the computer. The high-level language software will then translate these high-level instructions into the low-level machine language instructions




Characteristics of C

We briefly list some of C's characteristics that have lead to its popularity as a programming language and define the language. Naturally we will be studying many of these aspects throughout our tutorial.

 

  • Extensive use of function calls
  • Small size
  • Loose typing -- unlike PASCAL
  • Structured language
  • Low level (BitWise) programming readily available
  • Pointer implementation - extensive use of pointers for memory, array, structures and functions.

C has now become a widely used professional language for various reasons.

  • It has high-level constructs.
  • It produces efficient programs.
  • It can handle low-level activities.
  • It can be compiled on a variety of computers.

The main drawback of c is that it has poor error detection which can make it off putting to the beginner. However diligence in this matter can pay off handsomely since having learned the rules of the C we can break them. Not all languages allow this. This if done carefully and properly leads to the power of C programming.




C Program Structure

A C program basically has the following form:

  • Preprocessor Commands
  • Function prototypes -- declare function types and variables passed to function.

  • Type definitions
  • Variables
  • Functions

We must have a main() function

C assumes that function returns an integer type,if the type definition is omitted. NOTE: This can be a source of the problems in a program

/* Sample program */

main()
{
printf( ``I Like C \n'' );
exit ( 0 );
}
NOTE:
  1. printf is a standard C function -- called from main.
  2. C requires a semicolon at the end of the every statement.
  3. \n signifies newline. Formatted output -- more later.
  4. exit() is also a standard function that causes the program to terminate. Strictly speaking it is not needed here as it is the last line of main() and the program will terminate anyway.





Previous Next

Keywords: c programming language, c language programming tutorial pdf, history of c programming, basic c programming, c band satellite programming, syntax use in c programming, c programming software download, turbo c programming, c programming code, learn c programming


HTML Quizes
HTML Quiz
XHTML Quiz
CSS Quiz
TCP/IP Quiz
CSS 1.0 Quiz
CSS 2.0 Quiz
HLML Quiz
XML Quizes
XML Quiz
XSL Quiz
XSLT Quiz
DTD Quiz
Schema Quiz
XForms Quiz
XSL-FO Quiz
XML DOM Quiz
XLink Quiz
XQuery Quiz
XPath Quiz
XPointer Quiz
RDF Quiz
SOAP Quiz
WSDL Quiz
RSS Quiz
WAP Quiz
Web Services Quiz
Browser Scripting Quizes
JavaScript Quiz
VBScript Quiz
DHTML Quiz
HTML DOM Quiz
WMLScript Quiz
E4X Quiz
Server Scripting Quizes
ASP Quiz
PERL Quiz
SQL Quiz
ADO Quiz
CVS Quiz
Python Quiz
Apple Script Quiz
PL/SQL Quiz
SQL Server Quiz
PHP Quiz
.NET (dotnet) Quizes
Microsoft.Net Quiz
ASP.Net Quiz
.Net Mobile Quiz
C# : C Sharp Quiz
ADO.NET Quiz
VB.NET Quiz
VC++ Quiz
Multimedia Quizes
SVG Quiz
Flash Quiz
Media Quiz
SMIL Quiz
Photoshop Quiz
Gimp Quiz
Matlab Quiz
Gnuplot Programming Quiz
GIF Animation Quiz
Scientific Visualization Quiz
Graphics Quiz
Web Building  Quizes
Web Browsers Quiz
Web Hosting Quiz
W3C Quiz
Web Building Quiz
Web Quality Quiz
Web Semantic Quiz
Web Careers Quiz
Weblogic Quiz
SEO Quiz
Web Site Hosting Quiz
Domain Name Quiz
Java Quizes
Java Quiz
JSP Quiz
Servlets Quiz
Struts Quiz
EJB Quiz
JMS Quiz
JMX Quiz
Eclipse Quiz
J2ME Quiz
JBOSS Quiz
Programming Langauges Quizes
C Quiz
C++ Quiz
Visual Basic Quiz
Data Structures Using C Quiz
Cobol Quiz
Assembly Language Quiz
Mainframe Quiz
Forth Programming Quiz
Lisp Programming Quiz
Pascal Quiz
Delphi Quiz
Fortran Quiz
OOPs Quiz
Data Warehousing Quiz
CGI Programming Quiz
Emacs Quiz
Gnome Quiz
ILU Quiz
Soft Skills Quizes
Communication Skills Quiz
Time Management Quiz
Project Management Quiz
Team Work Quiz
Leadership Skills Quiz
Corporate Communication Quiz
Negotiation Skills Quiz
Database Quizes
Oracle Quiz
MySQL Quiz
Operating System Quizes
BSD Quiz
Symbian Quiz
Unix Quiz
Internet Quiz
IP-Masquerading Quiz
IPC Quiz
MIDI Quiz
Software Testing Quizes
Testing Quiz
Firewalls Quiz
SAP Module Quizes
ERP Quiz
ABAP Quiz
Business Warehousing Quiz
SAP Basis Quiz
Material Management Quiz
Sales & Distribution Quiz
Human Resource Quiz
Netweaver Quiz
Customer Relationship Management Quiz
Production and Planning Quiz
Networking Programming Quizes
Corba Quiz
Networking Quiz
Microsoft Office Quizes
Microsoft Word Quiz
Microsoft Outlook Quiz
Microsoft PowerPoint Quiz
Microsoft Publisher Quiz
Microsoft Excel Quiz
Microsoft Front Page Quiz
Microsoft InfoPath Quiz
Microsoft Access Quiz
Accounting Quizes
Financial Accounting Quiz
Managerial Accounting Quiz

Privacy Policy
Copyright © 2003-2024 Vyom Technosoft Pvt. Ltd., All Rights Reserved.