ankitweblogic logo
W e b t u t o r i a l s

C Tutorial

Programing Approach

Algorithm

Flow Chart

Define C

Define Programming

C - Syntax

Compiler vs Interpreter

C - Variables

C - Keywords

C - Data Types

C - Comments

Turbo C - Shortcut keys

C - Operators

Hierarchy of Operators

Ex: Arithmetic Operator

C - Formatting Output

Constant Variable

C - Escape Sequence

C - if , switch

Ex: If condition

Ex: Inc / Dec Operator

C - loops

Ex: Loops

C - Nesting Of loops

Ex: Nested Loops

Jumping Statements

C - Arrays 1D

C - Arrays 2D

C - Sorting

ASCII Value

Character I/O Function

C - String Functions

Ex: Strings

Array of Strings

C - Math Functions

User-defined Function

Exercise Function

C - Types of Functions

Storage Class

C - Header Files

C - Preprocessor

C - Pointers

C - Structures

C - Typedef

C - File Handling

Ex: File Handling

Command Line Argument

MCQ

C - Syntax

Syntax defines the set of rules for writing programs. Every language specification defines its own syntax.

A program in C-Language can be composed of:

  • Variables − Represents a named in memory block that can store values for the program.
  • Literals − Represents constant/fixed values.
  • Operators − Symbols that define how the operands will be processed.
  • Keywords − Words that have a special meaning in the context of a language.

First C Program

In this tutorial, we are using Turbo C++ compiler and integrated development environment (IDE), which is originally from Borland.

Example 1: WAP to print a Message "This is my first C Program"

#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    printf("This is my first C Program"); /*to print the statement*/
    getch();
}
This is my first C Program
Code Explanation:
  • #include<stdio.h> - stands for Standard input output, .h - header file. It includes the standard input output library functions like printf(), scanf().
  • #include<conio.h> - Console input output header file. It includes the console input output library functions like clrscr(), getch().
  • void main() - main() is a function from where the program start its execution, void specifies that function does not return any value.
  • { } - curly brackets define the scope of the program
  • clrscr() - to clear the screen. It will clear the output screen so that previous output will be cleared when running a new program.
  • printf() - is a function which is use to print data.
  • scanf() function is use to receive the values from user
  • & means address of a variable
  • getch() - use to input a single character. It holds the screen until user press any key.
How to compile and run the program

There are 2 ways to compile and run the c program, by menu and by shortcut.

1. By Menu: Click on compile menu and select compile option to compile the program. Than, click on run menu and select run option to run the program.

2. By Shortcut key: Press alt+f9 keys to compile the program and ctrl+f9 to run the program.

Example 2: WAP to Input 2 number and find sum.

#include<stdio.h>
#include<conio.h>
void main()
{
    int a, b, c;
    clrscr();
    printf("Enter 1st Number: ");
    scanf("%d",&a);
    printf("Enter 2nd Number: ");
    scanf("%d",&b);
    c=a+b;
    printf("Sum = %d",c);
    getch();
}
Enter 1st Number: 10
Enter 2nd Number: 20
Sum = 30