C Programming: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
 
(21 intermediate revisions by the same user not shown)
Line 10: Line 10:


== Getting Start ==
== Getting Start ==
Traditionally it was little bit difficult to programming with '''C/C++'''. Have to depends on '''Turbo C/C++''' or '''Borland C/C++''', very much annoying to install and configure them. Where [http://codeblocks.org/downloads CodeBlocks] is blessing for us with '''91.3 MB''' of installer with Zero Configuration needs, also support so many features using plugins.  First I hear from one of my colleagues then from one of my tutor and fellows at [https://techshopbd.com TechshopBD].
Traditionally it was little bit difficult to programming with '''C/C++'''. Have to depends on '''Turbo C/C++''' or '''Borland C/C++''', very much annoying to install and configure them. Where [http://codeblocks.org/downloads CodeBlocks] is blessing for us with '''91.3 MB''' of installer with Zero Configuration needs, also support so many features using plugins.  First I hear from one of my colleagues then from one of my tutor and fellows at [https://techshopbd.com TechshopBD]. A '''C Program''' basically consists of the following:
# '''Preprocessor Commands'''
# '''Functions'''
# '''Variables'''
# '''Statements & Expressions'''
# '''Comments'''


=== Hello World ===
=== Hello World ===
Line 16: Line 21:
//main.c
//main.c
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>


int main()
int main()
Line 25: Line 29:
</syntaxhighlight>
</syntaxhighlight>


== C Tokens ==
== Concepts ==
C Supports Six Types of Tokens:
* [[C Programming/Tokens|Tokens]]
# Identifiers
* [[C Programming/Operators|Operators]]
# [[C Programming#Keywords|Keywords]]
* [[C Programming/Character set|Character set]]
# Constants
* [[C Programming/Data Types|Data Types]]
# Strings
* [[C Programming/Constants|Constants]]
# Operators
* [[C Programming/Storage Class|Storage Class]]
# Special Symbols
* [[C Programming/Flow Control|Flow Control]]
* [[C Programming/Structure Datatype|Structure Datatype]]
* [[C Programming/Unions Datatype|Unions Datatype]]


=== Keywords ===
== Exercise ==
{| class="wikitable"
|-
| auto || double || int || struct
|-
| break || else || long || switch
|-
| case || enum || register || typedef
|-
| char || extern || return || union
|-
| const || float || short || unsigned
|-
| continue || for || signed || void
|-
| default || goto || sizeof || volatile
|-
| do || if || static || while
|}
 
== Exercise/Example ==
* Variable Declaration
* Variable Declaration
* Identifier
* Arithmetic Operation
* Arithmetic Operation
* Operator Precedence
* [[C Programming/String Manipulation|String Manipulation]]
* [[C Programming/String Manipulation|String Manipulation]]
* [[C Programming/File Manipulation|File Manipulation]]


== References ==
== References ==
* [https://www.w3schools.in/c-program/ C Program by W3 Schools India]
* [https://w3schools.in/c-program/ C Program by W3 Schools India]
* [https://www.w3schools.in/c-tutorial C Tutorial by W3 Schools India]
* [https://w3schools.in/c-tutorial C Tutorial by W3 Schools India]
* [https://en.wikibooks.org/wiki/C_Programming C Programming by Wiki Book]
* [https://en.wikibooks.org/wiki/C_Programming C Programming by Wiki Book]
* '''Beginning'''
* www.tutorialspoint.com/ansi_c
** [https://en.wikibooks.org/wiki/C_Programming/Variables Variables]
* [http://en.cppreference.com/w/ C++ Reference]
** [https://en.wikibooks.org/wiki/C_Programming/Intro_exercise Intro Exercise]
 
** [https://en.wikibooks.org/wiki/C_Programming/Preliminaries Preliminaries]
=== Beginning ===
** [https://en.wikibooks.org/wiki/C_Programming/Structure_and_style Structure and Style]
* [https://en.wikibooks.org/wiki/C_Programming/Variables Variables]
** [https://en.wikibooks.org/wiki/C_Programming/Simple_Input_and_Output Simple Input and Output]
* [https://en.wikibooks.org/wiki/C_Programming/Intro_exercise Intro Exercise]
** [https://en.wikibooks.org/wiki/C_Programming/Operators_and_type_casting Operators and type casting]
* [https://en.wikibooks.org/wiki/C_Programming/Preliminaries Preliminaries]
** [https://en.wikibooks.org/wiki/C_Programming/Arrays_and_strings Arrays and Strings]
* [https://en.wikibooks.org/wiki/C_Programming/Structure_and_style Structure and Style]
** [https://en.wikibooks.org/wiki/C_Programming/Program_flow_control Program Flow Control]
* [https://en.wikibooks.org/wiki/C_Programming/Simple_Input_and_Output Simple Input and Output]
** [https://en.wikibooks.org/wiki/C_Programming/Procedures_and_functions Procedures and Functions]
* [https://en.wikibooks.org/wiki/C_Programming/Operators_and_type_casting Operators and type casting]
** [https://en.wikibooks.org/wiki/C_Programming/Standard_libraries Standard Libraries]
* [https://en.wikibooks.org/wiki/C_Programming/Arrays_and_strings Arrays and Strings]
* '''Intermediate'''
* [https://en.wikibooks.org/wiki/C_Programming/Program_flow_control Program Flow Control]
** [https://en.wikibooks.org/wiki/C_Programming/Advanced_data_types Advanced Data Types]
* [https://en.wikibooks.org/wiki/C_Programming/Procedures_and_functions Procedures and Functions]
** [https://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays Pointers and Relationship to Arrays]
* [https://en.wikibooks.org/wiki/C_Programming/Standard_libraries Standard Libraries]
** [https://en.wikibooks.org/wiki/C_Programming/Memory_management Memory Management]
 
** [https://en.wikibooks.org/wiki/C_Programming/Error_handling Error Handling]
=== Intermediate ===
** [https://en.wikibooks.org/wiki/C_Programming/File_IO File I/O]
* [https://en.wikibooks.org/wiki/C_Programming/Advanced_data_types Advanced Data Types]
** [https://en.wikibooks.org/wiki/C_Programming/String_manipulation String Manipulation]
* [https://en.wikibooks.org/wiki/C_Programming/Pointers_and_arrays Pointers and Relationship to Arrays]
** [https://en.wikibooks.org/wiki/C_Programming/Further_math Further Math]
* [https://en.wikibooks.org/wiki/C_Programming/Memory_management Memory Management]
** [https://en.wikibooks.org/wiki/C_Programming/Libraries Libraries]
* [https://en.wikibooks.org/wiki/C_Programming/Error_handling Error Handling]
* '''Advanced'''
* [https://en.wikibooks.org/wiki/C_Programming/File_IO File I/O]
** [https://en.wikibooks.org/wiki/C_Programming/Common_practices Common Practices]
* [https://en.wikibooks.org/wiki/C_Programming/String_manipulation String Manipulation]
** [https://en.wikibooks.org/wiki/C_Programming/Preprocessor_directives_and_macros Preprocessor Directives and Macros]
* [https://en.wikibooks.org/wiki/C_Programming/Further_math Further Math]
** [https://en.wikibooks.org/wiki/C_Programming/Networking_in_UNIX Sockets and Networking (UNIX)]
* [https://en.wikibooks.org/wiki/C_Programming/Libraries Libraries]
** [https://en.wikibooks.org/wiki/C_Programming/Serialization Serialization and X-Macros]
 
** [https://en.wikibooks.org/wiki/C_Programming/Coroutines Coroutines]
=== Advanced ===
* '''Miscellaneous'''
* [https://en.wikibooks.org/wiki/C_Programming/Common_practices Common Practices]
** [https://en.wikibooks.org/wiki/C_Programming/Standard_Library_Reference Standard Library Reference]
* [https://en.wikibooks.org/wiki/C_Programming/Preprocessor_directives_and_macros Preprocessor Directives and Macros]
** [https://en.wikibooks.org/wiki/C_Programming/Preprocessor_reference Preprocessor Reference]
* [https://en.wikibooks.org/wiki/C_Programming/Networking_in_UNIX Sockets and Networking (UNIX)]
** [https://en.wikibooks.org/wiki/C_Programming/Language_Reference Language Reference]
* [https://en.wikibooks.org/wiki/C_Programming/Serialization Serialization and X-Macros]
*** [https://en.wikibooks.org/wiki/C_Programming/Language_Reference#Table_of_Keywords Table of Keywords]
* [https://en.wikibooks.org/wiki/C_Programming/Coroutines Coroutines]
*** [https://en.wikibooks.org/wiki/C_Programming/Language_Reference#Table_of_Operators Table of Operators]
 
*** [https://en.wikibooks.org/wiki/C_Programming/Language_Reference#Table_of_Data_Types Table of Data Types]
=== Miscellaneous ===
* [https://en.wikibooks.org/wiki/C_Programming/Standard_Library_Reference Standard Library Reference]
* [https://en.wikibooks.org/wiki/C_Programming/Preprocessor_reference Preprocessor Reference]
* [https://en.wikibooks.org/wiki/C_Programming/Language_Reference Language Reference]
** [https://en.wikibooks.org/wiki/C_Programming/Language_Reference#Table_of_Keywords Table of Keywords]
** [https://en.wikibooks.org/wiki/C_Programming/Language_Reference#Table_of_Operators Table of Operators]
** [https://en.wikibooks.org/wiki/C_Programming/Language_Reference#Table_of_Data_Types Table of Data Types]

Latest revision as of 06:23, 5 February 2018

Overview

C (/siː/, as in the letter c) is a general-purpose, imperative computer programming language, supporting structured programming, lexical variable scope and recursion, while a static type system prevents many unintended operations. By design, C provides constructs that map efficiently to typical machine instructions, and therefore it has found lasting use in applications that had formerly been coded in assembly language, including operating systems, as well as various application software for computers ranging from Supercomputers to Embedded Systems.

C was originally developed by Dennis Ritchie between 1969 and 1973 at Bell Labs, and used to re-implement the Unix Operating System. It has since become one of the most widely used programming languages of all time, with C compilers from various vendors available for the majority of existing computer architectures and operating systems. C has been standardized by the American National Standards Institute (ANSI) since 1989 and subsequently by the International Organization for Standardization (ISO).

C is an imperative procedural language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require Minimal Run-Time Support. Despite its Low-Level Capabilities, the language was designed to encourage Cross-Platform Programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with few changes to its source code. The language has become available on a very wide range of platforms, from Embedded Microcontrollers to Supercomputers.


Getting Start

Traditionally it was little bit difficult to programming with C/C++. Have to depends on Turbo C/C++ or Borland C/C++, very much annoying to install and configure them. Where CodeBlocks is blessing for us with 91.3 MB of installer with Zero Configuration needs, also support so many features using plugins. First I hear from one of my colleagues then from one of my tutor and fellows at TechshopBD. A C Program basically consists of the following:

  1. Preprocessor Commands
  2. Functions
  3. Variables
  4. Statements & Expressions
  5. Comments

Hello World

//main.c
#include <stdio.h>

int main()
{
    printf("Hello World!\n");
    return 0;
}

Concepts

Exercise

References

Beginning

Intermediate

Advanced

Miscellaneous