AMITY UNIVERSITY, MADHYA PRADESH
CSA 401
Machine Learning Techniques
Sumbitted By:
Shruti Tripathi
Astha Bhadoria
Pradeep Rawat
Sumbitted To:
Dr. Amit Kumar Mishra
History of C language
C is a programming language developed at AT & T’s Bell Laboratories of USA in
1972 by Dennis Ritchie. C became popular because it is simple and easy to use.
Dennis Ritchie is known as the founder of the C language. It was developed to
overcome the problems of previous languages such as B, BCPL, etc.
Why we should learn C?
 Major parts of popular operating systems like Windows, UNIX, LINUX
and Android are written in C.
The popular gaming frameworks (like DirectX) that are used for creating
professional 3D computer games are written in C.
It makes more sense to first learn C and then migrate to C++, C# or Java.
Though this two-step learning process may take time but it will be worth
the trouble.
Getting Started with C
Constant
s
Keywords
Variable
s
Also known as Literals
Also known as Identifiers
Word that carries Special meaning
CONSTANTS
PRIMARY CONSTANTS SECONDARY CONSTANTS
Array
Pointer
Structure
Union etc.
Integer Constant
Real Constant
Character Constant
Must not have
a decimal point
No commas,
no blanks
Ex: 426, -800,
+896 etc.
Must have
decimal point
No commas, no
blanks
Ex: -32.76,
426.0 etc.
It is a single alphabet,
single digit or special
symbol
Both the inverted
commas should point to
the left
Ex: ‘A’ , ‘8’ , ‘=‘ etc.
Variables
The first character in the variable name must be an alphabet or underscore (_).
Any variable must be declared before it is used.
Ex: avg
basic_salary
Declare the type of any variable .
Ex: char code;
int si;
Keywords
 These are the words whose meaning is already
explained to the C compiler.
There are only 32 keywords available in C.
 Ex: auto, break, double, long, struct, void etc.
What is main() ?
 main() is a function.
It is a container of set of statements.
All statements that belong to main() are enclosed with a pair of
braces{}.
 main() function always returns an integer value, hence there is an int
before main().
Some compilers like Turbo C/C++ permit us to return nothing from
main(). In such case we should precede with keyword void.
What are Format Specifiers in C ?
The format specifiers are used in C for input and output purposes.
Using this concept the compiler can understand that what type of data
is in a variable during taking input using the scanf() function and
printing using printf() function.
Ex: %c--a single character
%s--a string
%d--a decimal integer etc.
 printf():
All output to screen is achieved using printf().
To use the printf() function, it is necessary to include #include<stdio.h>.
We also use format specifiers like: int-%d , float-%f , char-%c.
Comments in C program:
Comments are used to clarify either the purpose of the program or
purpose of some statement in the program.
Single –line comment- start with // and continue until the end of the line.
Multi-line comment- start with /* and end with */ .
 scanf():
It helps us to receive input values from the keyboard.
Use of ampersand (&) before the variables in scanf() function is necessary.
& is the ‘Address of’ operator. It gives the location number used by he variable
in memory.
printf() and scanf() statements:
Code illustrating what we revised till now:
/* Calculation of Simple Interest*/
#include<stdio.h>
int main()
{
int p, n;
float r, si;
printf(“Enter the values of p, n, r :”);
scanf(“%d%d%d”, &p, &n, &r);
si=p*n*r/100;
printf(“%f”, si);
return 0;
}
Types of Instructions in C
Type Declaration
Instruction
Arithmetic
Instruction
Control Instruction
It is used to declare the type of variables being used in
the program. Its is written at the beginning of the
main() function.
Ex: int bas;
char name, code;
It consists of a variable name on the left hand side of =
and variable names on right hand side.
Ex: int a , b, sum;
a=8;
b=0.7;
sum=a+b;
These determine the ‘flow of control’ in a program. It
controls the order in which the instructions of a
program gets executed.
THANK YOU!

INTRODUCTION TO THE BASICS OF C PROGRAMMING LANGUAGE

  • 1.
    AMITY UNIVERSITY, MADHYAPRADESH CSA 401 Machine Learning Techniques Sumbitted By: Shruti Tripathi Astha Bhadoria Pradeep Rawat Sumbitted To: Dr. Amit Kumar Mishra
  • 2.
    History of Clanguage C is a programming language developed at AT & T’s Bell Laboratories of USA in 1972 by Dennis Ritchie. C became popular because it is simple and easy to use. Dennis Ritchie is known as the founder of the C language. It was developed to overcome the problems of previous languages such as B, BCPL, etc. Why we should learn C?  Major parts of popular operating systems like Windows, UNIX, LINUX and Android are written in C. The popular gaming frameworks (like DirectX) that are used for creating professional 3D computer games are written in C. It makes more sense to first learn C and then migrate to C++, C# or Java. Though this two-step learning process may take time but it will be worth the trouble.
  • 3.
    Getting Started withC Constant s Keywords Variable s Also known as Literals Also known as Identifiers Word that carries Special meaning
  • 4.
    CONSTANTS PRIMARY CONSTANTS SECONDARYCONSTANTS Array Pointer Structure Union etc. Integer Constant Real Constant Character Constant Must not have a decimal point No commas, no blanks Ex: 426, -800, +896 etc. Must have decimal point No commas, no blanks Ex: -32.76, 426.0 etc. It is a single alphabet, single digit or special symbol Both the inverted commas should point to the left Ex: ‘A’ , ‘8’ , ‘=‘ etc.
  • 5.
    Variables The first characterin the variable name must be an alphabet or underscore (_). Any variable must be declared before it is used. Ex: avg basic_salary Declare the type of any variable . Ex: char code; int si; Keywords  These are the words whose meaning is already explained to the C compiler. There are only 32 keywords available in C.  Ex: auto, break, double, long, struct, void etc.
  • 6.
    What is main()?  main() is a function. It is a container of set of statements. All statements that belong to main() are enclosed with a pair of braces{}.  main() function always returns an integer value, hence there is an int before main(). Some compilers like Turbo C/C++ permit us to return nothing from main(). In such case we should precede with keyword void. What are Format Specifiers in C ? The format specifiers are used in C for input and output purposes. Using this concept the compiler can understand that what type of data is in a variable during taking input using the scanf() function and printing using printf() function. Ex: %c--a single character %s--a string %d--a decimal integer etc.
  • 7.
     printf(): All outputto screen is achieved using printf(). To use the printf() function, it is necessary to include #include<stdio.h>. We also use format specifiers like: int-%d , float-%f , char-%c. Comments in C program: Comments are used to clarify either the purpose of the program or purpose of some statement in the program. Single –line comment- start with // and continue until the end of the line. Multi-line comment- start with /* and end with */ .  scanf(): It helps us to receive input values from the keyboard. Use of ampersand (&) before the variables in scanf() function is necessary. & is the ‘Address of’ operator. It gives the location number used by he variable in memory. printf() and scanf() statements:
  • 8.
    Code illustrating whatwe revised till now: /* Calculation of Simple Interest*/ #include<stdio.h> int main() { int p, n; float r, si; printf(“Enter the values of p, n, r :”); scanf(“%d%d%d”, &p, &n, &r); si=p*n*r/100; printf(“%f”, si); return 0; }
  • 9.
    Types of Instructionsin C Type Declaration Instruction Arithmetic Instruction Control Instruction It is used to declare the type of variables being used in the program. Its is written at the beginning of the main() function. Ex: int bas; char name, code; It consists of a variable name on the left hand side of = and variable names on right hand side. Ex: int a , b, sum; a=8; b=0.7; sum=a+b; These determine the ‘flow of control’ in a program. It controls the order in which the instructions of a program gets executed.
  • 10.