C Programming Language

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

AN

PERSENTATION AT “C LANGUAGE”
(C PROGRAMMING LANGUAGE AT L&B)

Submitted By: - Submitted To:-


Khushbu Mahawar Mr. S.N.Vijay
19EJEEE012 (Head of EE)
CONTENT
 INTRODUCTION
 VARIABLE
 IDENTIFIER
 CONSTANT
 KEYWORDS
 INPUT/OUTPUT
 INSTRUCTIONS
 OPERATORS
 CONDITIONAL STATEMENT
 LOOPS
 PROGRAM
 BIBLIOGRAPHY
INTRODUCTION

ESTABLISHED

ON 1972 on Digital Equipment corporation


by Dennis Ritchiefor UNIX system
highlevel language
Easy to learn
Case sensitive
VARIABLE
 A variable is nothing but a name given to a storage area
that our programs can manipulate. Each variable in C has
a specific type, which determines the size and layout of
the variable’s memory. The name of the variable can be
letters, digits, and the underscore character. It must be
begins with a character or an underscore
Type Description
char character type variable (‘a’, ’b’)
int integer type variable (1,3,2)
float floating type variable(3.14,2.0)
void repersent the absence of type
IDENTIFIER
 A 'C' program consist of two types of elements , user
defined and system defined. Idetifiers is nothing but a
name given to these elements
 An identifier is a word used by a programmer to name a
variable , function, or label.
 identifiers consist of letters and digits, in any order,
except that the first charecter or lable.
 Identifiers consist of letters and digits if any order,
except that the first charecter must be letter.
 Both Upper and lowercase letters can be used
CONSTANTS
 A constant is a value or an identifier whose value cannot
be altered in a program. For example: 1, 2.5,
 As mentioned, an identifier also can be defined as a
constant. eg. const double PI = 3.14
 Here, PI is a constant. Basically what it means is that, PI
and 3.14 is same for this program.
 There are 3 types of constants
1. Integer constant 1, 2, 3, 4
2. Real constant 1.0, 2.0, 4.0
3. Character constant ‘a’, ‘b’, ‘c’,
KEYWORDS
 Keywords are nothing but
system defined identifiers. auto double int struct
 Keywords are reserved words break else long switch
of the language.
 They have specific meaning in case enum register typedef
the language and cannot be
used by the programmer as char extern return union
variable or constant names
const float short unsigne
 C is case senitive, it means d
these must be used as it is continue for signed void
 32 Keywords in C
default goto sizeof volatile
Programming
do if static while
INPUT / OUTPUT
 Output
In C programming, printf() is one of the main output
function. The function sends formatted output to the
screen.
e.g. printf(“ Hello World! \n ”);
 Input

In C programming, scanf() is one of the commonly used


function to take input from the user. The scanf() function
reads formatted input from the standard input such as
keyboards.
Scanf(“ %d”,&age);
INSTRUCTION
 Instructions in C are the commands in the program that
will instruct C compiler to perform specific tasks or
actions. Whenever we write a C instruction, we are
telling C compiler to do a task for us.
 There are three types of instructions in C. They are as
follows:
 1) Type Declaration Instruction
2) Arithmetic Instruction
3) Control instruction
OPERATORS
 An operator is a symbol that operates on a value or a
variable. For example: + is an operator to perform
addition.
 C has a wide range of operators to perform various
operations.
 Arithmatic operators ( +, -, /, %)

 Relational operators( ==, >=, <=, !=)

 Logical operator ( &&, ||, !)

 Bitwise operator( &,|, ^)

 Assignment operator( ==, +=, -=, *=, %=)

 Ternary operator ( ?, :)
CONDITIONAL STATEMENT
 C has the following conditional statements:
  Use if:- to specify a block of code to be executed, if a
specified condition is true.
if(condition){
// Do something if true
}
 Use if-else:- to specify a block of code to be executed, if the
same condition is false.
if(condition){
// do something if true
}
else {
// Do somethig if true
}
 Use else if to specify a new condition to test, if the first
condition is false.
if(condition){
// Do something if true
}
else-if {
//Do something if true/ false
}
else-if {
//do something if ture/false
}
else{
//do somethig if true
}
 Use switch to execute more than 2 conditions/ statement
at a time and in a single program
 For Example:-

Switch(condition){
case:1 //Do something
break;
case: 2 //Do something
break;
default : // do something
break;
}
LOOPS

 Loop is used to execute the block of code several times


according to the condition given in the loop. It means it
executes the same code multiple times so it saves code
and also helps to traverse the elements of an array.
 There are three types of loops in c language

 For loop

For(initialisation; condition; updation){


//printf(“Hello World”);
}
 While loop
Initialisation
while(condition) {
//do something
updation
}
 Do while loop

do{
//do something
updation
} while(condition);
PROGRAM:- WRITE A PROGRAM TO CALCULATE SUM
OF ALL NUMBER BETWEEN 5 TO 50
#include <stdio.h>
int main() {
int marks ;
printf("Enter marks: /n ");
scanf("%d", &marks);
for (marks < 30) {
printf(“ Grade is C: \n”);
}
else if (marks >= 70 && marks < 70){
Printf(“ Grade is B: \n”);
}
else if( marks>= 70 && marks<= 90){
Printf(“ Grade is A: \n”);
}
else{
Printf(“ Grade is A+: \n”);
}
return 0;
}
OUTPUT
Enter marks : 45
Grade is : B
BIBLIOGRAPHY
 Training report
 Google

 Wikipedia

 Javatpoint

 Books

You might also like