0% found this document useful (0 votes)
179 views18 pages

C & C++ Imp Points by Ead Shailendra Sir - 6422808

The document provides an introduction to the C programming language. It discusses that C is a procedural language originally developed in 1972 to write operating systems. The main features of C make it suitable for system programming like operating systems and compiler development. It then covers local environment setup, program structure, basic syntax, data types, variables, constants and literals in C.

Uploaded by

Irfan Qureshi
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)
179 views18 pages

C & C++ Imp Points by Ead Shailendra Sir - 6422808

The document provides an introduction to the C programming language. It discusses that C is a procedural language originally developed in 1972 to write operating systems. The main features of C make it suitable for system programming like operating systems and compiler development. It then covers local environment setup, program structure, basic syntax, data types, variables, constants and literals in C.

Uploaded by

Irfan Qureshi
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/ 18

LIVE 08:30AM EAD ONLINE CLASSES

WATSAPP - 9389976136
(1st) YOUR RECEIPT
(2nd) COMPLETE ADDRESS
Introduction to C Language
➢ C is a procedural programming language.
➢ C is a general-purpose, high-level language that was originally developed by
Dennis M. Ritchie to develop the UNIX operating system at Bell Labs. in 1972.
➢ C was invented to write an operating system called UNIX.
➢ The UNIX OS was totally written in C.
➢ It was mainly developed as a system programming language to write an
operating system.
➢ The main features of C language include low-level access to memory, a simple
set of keywords, and a clean style, these features make C language suitable for
system programming like an operating system or compiler development.
➢ Today C is the most widely used and popular System Programming Language.
➢ Most of the state-of-the-art software have been implemented using C.
➢ Today's most popular Linux OS and RDBMS MySQL have been written in C.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
➢ C has now become a widely used professional language for various reasons −
• Easy to learn
• Structured language
• It produces efficient programs
• It can handle low-level activities
• It can be compiled on a variety of computer platforms
➢ Local Environment Setup- If you want to set up your environment for C
programming language, you need the following two software tools available on
your computer-
(a) Text Editor
(b) C Compiler
(a). Text Editor- This will be used to type your program. Examples of few a
editors include Windows Notepad, OS Edit command, Brief, Epsilon, EMACS,
and vim or vi.
➢ The files you create with your editor are called the source files and they contain
the program source codes. The source files for C programs are typically named
with the extension ".c".
(b). C Compiler- The source code written in source file is the human readable
source for your program. It needs to be "compiled", into machine language so that
your CPU can actually execute the program as per the instructions given.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
C - Program Structure-
A C program basically consists of the following parts −
• Preprocessor Commands
• Functions
• Variables
• Statements & Expressions
• Comments
➢ Let us look at a simple code that would print the words "Hello World" −
#include <stdio.h> int main() {
/* my first program in C */
printf("Hello, World! \n");
return 0;
}
➢ Let us take a look at the various parts of the above program −
• The first line of the program #include <stdio.h> is a preprocessor command,
which tells a C compiler to include stdio.h file before going to actual
compilation.
• The next line int main() is the main function where the program execution
begins.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
• The next line /*...*/ will be ignored by the compiler and it has been put to add
additional comments in the program. So such lines are called comments in the
program.
• The next line printf(...) is another function available in C which causes the
message "Hello, World!" to be displayed on the screen.
• The next line return 0; terminates the main() function and returns the value 0.
Compile and Execute C Program-
Let us see how to save the source code in a file, and how to compile and run it.
Following are the simple steps −
• Open a text editor and add the above-mentioned code.
• Save the file as hello.c
• Open a command prompt and go to the directory where you have saved the file.
• Type gcc hello.c and press enter to compile your code.
• If there are no errors in your code, the command prompt will take you to the
next line and would generate a.out executable file.
• Now, type a.out to execute your program.
• You will see the output "Hello World" printed on the screen.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
C-Basic Syntax-
➢ Tokens in C- Token in C is either a keyword, an identifier, a constant, a
string literal, or a symbol. For example, the following C statement consists of
five tokens−
printf("Hello, World! \n");
➢ Semicolons- Semicolon in C program is a statement terminator. That is, each
individual statement must be ended with a semicolon. It indicates the end of
one logical entity.
printf("Hello, World! \n");
➢ Comments- Comments are like helping text in your C program and they are
ignored by the compiler. They start with /* and terminate with the characters */
as shown below-
/* my first program in C */
➢ Identifiers- A C identifier is a name used to identify a variable, function,
or any other user-defined item. An identifier starts with a letter A to Z, a to
z, or an underscore '_' followed by zero or more letters, underscores, and
digits (0 to 9).
• C does not allow punctuation characters such as @, $, and % within
identifiers. C is a case-sensitive programming language.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
LIVE 08:30AM EAD ONLINE CLASSES
WATSAPP - 9389976136
(1st) YOUR RECEIPT
(2nd) COMPLETE ADDRESS
➢ Keywords- The following list shows the reserved words in C.

➢ Whitespace in C - Whitespace is the term used in C to describe blanks,


tabs, newline characters and comments. Whitespace separates one part of a
statement from another and enables the compiler to identify where one
element in a statement, such as int, ends and the next element begins.
Therefore, in the following statement − int age;

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
C- Data Types-
Data types in c refer to an extensive system used for declaring variables or
functions of different types. The types in C can be classified as follows −
S.NO. TYPES & DESCRIPTION

1 Basic Types
They are arithmetic types and are further classified into:
(a) integer types and (b) floating-point types.

2 Enumerated types
They are again arithmetic types and they are used to define
variables that can only assign certain discrete integer values
throughout the program.

3 The type void


The type specifier void indicates that no value is available.

4 Derived types
They include- (a) Pointer types, (b) Array types, (c) Structure
types, (d) Union types and (e) Function types.

➢ The array types and structure types are referred collectively as the aggregate
types.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
C – Variables-
➢ A variable definition tells the compiler where and how much storage to
create for the variable.
➢ Basic variable types are-
S. NO. TYPE & DESCRIPTION

1 char
Typically a single octet(one byte). It is an
integer type.

2 int
The most natural size of integer for the
machine.

3 float
A single-precision floating point value.

4 double
A double-precision floating point value.

5 void
Represents the absence of type.
ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES
DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
Variable Declaration in C-
• A variable declaration provides assurance to the compiler that there exists a
variable with the given type and name so that the compiler can proceed for
further compilation without requiring the complete detail about the
variable.
• A variable declaration is useful when you are using multiple files and you
define your variable in one of the files which will be available at the time
of linking of the program.
C - Constants and Literals-
• Constants refer to fixed values that the program may not alter during its
execution. These fixed values are also called literals.
• Constants can be of any of the basic data types like an integer constant, a
floating constant, a character constant, or a string literal. There are
enumeration constants as well.
➢ Integer Literals- An integer literal can be a decimal, octal, or hexadecimal
constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, 0
for octal, and nothing for decimal.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
➢ Floating-point Literals- A floating-point literal has an integer part, a
decimal point, a fractional part, and an exponent part. You can represent
floating point literals either in decimal form or exponential form.
➢ Character Constants- Character literals are enclosed in single quotes,
e.g., 'x' can be stored in a simple variable of char type. A character literal
can be a plain character (e.g., 'x'), an escape sequence (e.g., '\t'), or a
universal character (e.g., '\u02C0').
➢ String Literals- String literals or constants are enclosed in double
quotes "". A string contains characters that are similar to character literals:
plain characters, escape sequences, and universal characters.
Defining Constants-
There are two simple ways in C to define constants −
• Using #define preprocessor.
• Using const keyword.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
C – Operators-
An operator is a symbol that tells the compiler to perform specific
mathematical or logical functions. C language is rich in built-in operators and
provides the following types of operators −
• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
• Misc Operators
C – Functions-
A function definition in C programming consists of a function header and
a function body. Here are all the parts of a function −
➢ Return Type − A function may return a value. The return_type is the data
type of the value the function returns. Some functions perform the desired
operations without returning a value. In this case, the return_type is the
keyword void.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
➢ Function Name − This is the actual name of the function. The function
name and the parameter list together constitute the function signature.
➢ Parameters − A parameter is like a placeholder. When a function is
invoked, you pass a value to the parameter. This value is referred to as
actual parameter or argument. The parameter list refers to the type, order,
and number of the parameters of a function. Parameters are optional; that
is, a function may contain no parameters.
➢ Function Body − The function body contains a collection of statements
that define what the function does.

ENGINEERING ACADEMY DEHRADUN SUBSCRIBE OUR YOUTUBE CHANNEL-EAD ONLINE CLASSES


DOWNLOAD OUR APP FORM PLAY STORE “EAD ONLINE CLASSES” FOR DIFFERENT ONLINE DETAILED COURSES
LIVE 08:30AM EAD ONLINE CLASSES
WATSAPP - 9389976136
(1st) YOUR RECEIPT
(2nd) COMPLETE ADDRESS

You might also like