Home Show/Hide Menu
C Tutorials
➜ C Language
  - Features of C
  - First C Program
  - Compilation in C
  - C Character Set
  - Tokens
  - Keywords
  - Identifiers
  - Constants
  - Operators
  - Data Types
  - Variables
  - Type Casting
  - Comments
  - Input/Output
  - Escape Sequence
  - Programming Errors
➜ Control Statements
  - if Statement
  - if-else Statement
  - Nested if-else
  - else-if
  - switch Statement
  - Loop
  - while loop
  - do while loop
  - for loop
  - break
  - continue & goto
  - Nested Loop
  - Infinite Loop
➜ Functions
  - What is function
  - Call by Value & Reference
  - Recursive function
  - Storage Classes
➜ Array
  - 1-D Array
  - 2-D Array
  - Return an Array
  - Array to Function
➜ C Pointers
  - Pointers
  - Pointer to Pointer
  - Pointer Arithmetic
  - Dangling Pointers
  - sizeof() operator
  - const Pointer
  - void pointer
  - Dereference Pointer
  - Null Pointer
  - Function Pointer
  - Function pointer as argument
➜ Memory Management
  - Memory Layout of C
  - Dynamic memory
  - calloc()
  - malloc()
  - realloc()
  - free()
➜ Strings
  - gets() & puts()
  - String Functions
  - strlen()
  - strcpy()
  - strcat()
  - strcmp()
  - strrev()
  - strlwr()
  - strupr()
  - strstr()
➜ C Math
  - Math Functions
➜ Enum, Structure & Union
  - Enum
  - Structure
  - typedef
  - Array of Structures
  - Nested Structure
  - Structure Padding
  - Union
➜ File Handling
  - fprintf() fscanf()
  - fputc() fgetc()
  - fputs() fgets()
  - fseek()
  - EOF and feof()
  - fsetpos()
  - tmpfile()
  - rewind()
  - ftell()
  - lseek()
➜ Preprocessor
  - Preprocessor
  - Macros
  - #include
  - #define
  - #undef
  - #ifdef
  - #ifndef
  - #if
  - #else
  - #error
  - #pragma
➜ Command Line
  - Arguments

First C Program

Programming in C language is very simple and before starting the program of C language, we need to learn how to write, compile and run the c program.
C program consists of the following parts -

  • Preprocessor Commands - which tells a C compiler to include stdio.h and other required header files before going to actual compilation.
  • Functions - the main function where the program execution begins.
  • Variables - A declaration of variable tells the compiler where and how much storage to create for the variable.
  • Statements & Expressions - C program statements consists of various tokens i.e. a keyword, an identifier, a constant, a string literal, or a symbol. Each statement must be ended with a semicolon. The semicolon is a statement terminator.
  • Comments - Comments between /* */ symbol will be ignored by the compiler


Let us look at a simple code that would print the words "My First C Program" :

#include <stdio.h>     → Preprocessor Commands
/* Start of the program */     → Comments line
int main()     → Main Function - start of the program
{     → Open curly brace as the start point
    printf("My First C Program");     → Statement
    return 0;     → Return statement
}     → Closing curly brace marks the end





ADVERTISEMENT