0% found this document useful (0 votes)
14 views10 pages

CPL Lecture-01

This document provides an introduction to the C programming language. It discusses key aspects of C including program structure, header files, the main function, comments, data types, variables, and input/output. C is a structured programming language that supports functions and comments to make code more readable and maintainable by breaking programs into smaller modules. The main function acts as the entry point for a C program.

Uploaded by

Pakhi Sohel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views10 pages

CPL Lecture-01

This document provides an introduction to the C programming language. It discusses key aspects of C including program structure, header files, the main function, comments, data types, variables, and input/output. C is a structured programming language that supports functions and comments to make code more readable and maintainable by breaking programs into smaller modules. The main function acts as the entry point for a C program.

Uploaded by

Pakhi Sohel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Computer Programming

Language
Instructor: Jarin Tasnim
Email: [email protected]
Number: 01844505100
Introduction to C
▪ C is a structured programming language
▪ C supports functions that enables easy maintainability of code, by breaking large file
into smaller modules
▪ Comments in C provides easy readability
▪ C is a powerful language
Program Structure
A sample C program
#include<stdio.h>
Int main()
{
other statements
//comments after double slash
}
Header Files

• The files that are specified in the include section is called as header file
• These are precompiled files that has some functions defined in them
• We can call those functions in our program by supplying parameters
• Header file is given an extension .h
• C source file is given an extension .c
Main Function

• Main() this is the entry point of a program


• When a file is executed, the start point is the main function
• From main function the flow goes as per the programmers choice.
• There may or may not be other functions written by user in a program
• Main function is compulsory for any c program
Comments in C

• Single line comment


• // (double slash)
• Termination of comment is by pressing enter key
• Multiple line comment
• /*……
………*/
• This can span over to multiple lines
Data types in C

• Primitive data types


• Int, float, double, char
• Aggregate data types
• Arrays come under this category
• Arrays can contain collection of int or float or char or double data
• User defined data types
• Structures and enum fall under this category.
Variables

• Variables are data that will keep on changing


• Declaration
• Data_type variable_name;
• int a;
• Definition/initialization
• Var_name = value
• a = 10;
• Usage
• a = a+1; // increments the value of a by 1
Rules to be maintained when writing variable
names

• Should not be a reversed word like int, float, do, while etc..
• Should start with a letter or an underscore(_)
• Can contain letters, numbers or underscore.
• No other special characters are allowed including space
• Variable names are case sensitive
• A and a are different.
Input and Output

• Input
• Scanf(“%d”, &a);
• Gets an integer value from the user and stores it under the name “a”
• Output
• Printf(“%d”, a);
• Prints the value present in variable a on the screen

You might also like