SlideShare ist ein Scribd-Unternehmen logo
1 von 22
VISHWAKARMA GOVERNMENT
ENGINEERING COLLAGE
sky
 COMPUTER PROGRAMING & UTILIZATION
 Prepared by:
Meet Patel 140170119056
Sindhi Parth 140170119057
Soni Kunjan 140170119058
Thakor Chetan 140170119059
Thakor Milan 140170119060
OUTLINE
 Data Types &
Variables
 Arithmetic & Logical
Operations
 Conditionals
 Loops
Name Description Size* Range*
char Character or small
integer
1 byte signed: -128 to 127
unsigned: 0 to 255
short int
(short)
Short integer 2 bytes signed: -32768 to 32767
unsigned: 0 to 65535
int Integer 4 bytes signed: -2147483648 to
2147483647
unsigned: 0 to 4294967295
long int
(long)
Long integer 4 bytes signed: -2147483648 to
2147483647
unsigned: 0 to 4294967295
float Floating point
number
4 bytes 3.4e +/- 38 (7 digits)
double Double precision
floating point number
8 bytes 1.7e +/- 308 (15 digits)
long
double
Long double
precision floating
point number
8 bytes 1.7e +/- 308 (15 digits)
Data types
 Variable Declaration
int length = 100;
char num = ‘9’; //The actual value is 57
float deposit = 240.5;
unsigned short ID = 0x5544;
Try the following statements, and see what happens
unsigned char value = -1;
printf(“The value is %d n”, value);
unsigned char value = 300;
printf(“The value is %d n”, value);
Result
Definition Memory layout Display comment
unsigned char
value = -1
11111111 255
unsigned char
value = 300
00101100 44 overflow
 Local variable
Local variables are declared within the body of a function,
and can only be used within that function.
 Static variable
Another class of local variable is the static type. It is specified
by the keyword static in the variable declaration.
The most striking difference from a non-static local variable is,
a static variable is not destroyed on exit from the function.
 Global variable
A global variable declaration looks normal, but is located
outside any of the program's functions. So it is accessible to all
functions.
Variable types
Variable Definition vs Declaration
Definition Tell the compiler about the variable: its type and
name, as well as allocated a memory cell for the
variable
Declaration Describe information ``about'' the variable,
doesn’t allocate memory cell for the variable
Arithmetic Operations
Arithmetic Assignment Operators
Increment and Decrement Operators
awkward easy easiest
x = x+1; x += 1 x++
x = x-1; x -= 1 x--
Example
 Arithmetic operators
int i = 10;
int j = 15;
int add = i + j; //25
int diff = j – i; //5
int product = i * j; // 150
int quotient = j / i; // 1
int residual = j % i; // 5
i++; //Increase by 1
i--; //Decrease by 1
 Comparing them
int I = 10;
int j = 15;
float k = 15.0;
j / i = ?
j % i = ?
k / i = ?
k % i = ?
The Answer
j / I = 1;
j % I = 5;
k / I = 1.5;
k % I It is
illegal.
Note: For %, the
operands can
only be integers.
Logical Operations
 What is “true” and “false” in C
In C, there is no specific data type to represent “true” and “false”. C
uses value “0” to represent “false”, and uses non-zero value to stand
for “true”.
 Logical Operators
A && B => A and B
A || B => A or B
A == B => Is A equal to B?
A != B => Is A not equal to B?
A > B => Is A greater than B?
A >= B => Is A greater than or equal to B?
A < B => Is A less than B?
A <= B => Is A less than or equal to B?
 Don’t be confused
&& and || have different meanings from & and |.
& and | are bitwise operators.
Conditionals
 if statement
Three basic formats,
if (expression){
statement …
}
if (expression) {
statement …
}else{
statement …
}
 if (expression)
{
statement…
} else if
(expression) {
statement…
} else{
statement…
}
 The switch statement
switch (expression)
{
case item1:
statement;
break;
case item2:
statement;
break;
default:
statement;
break;
}
Loops
 for statement
for (expression1; expression2; expression3){
statement…
}
expression1 initializes;
expression2 is the terminate test;
expression3 is the modifier;
 The while statement
while (expression) {
statement …
}
while loop exits only when the expression is false.
 An example
int x = 3;
while (x>0) {
printf("x=%d n",x);
x--;
}
for <==> while
for (expression1;
expression2;
expression3){
statement…
}
expression1;
while (expression2)
{
statement…;
expression3;
}
equals
THANK YOU
sky

Weitere ähnliche Inhalte

Was ist angesagt?

C sharp_basic_ideas
C sharp_basic_ideasC sharp_basic_ideas
C sharp_basic_ideas
Ralph Weber
 

Was ist angesagt? (20)

Operator Precedence and Associativity
Operator Precedence and AssociativityOperator Precedence and Associativity
Operator Precedence and Associativity
 
C# conditional branching statement
C# conditional branching statementC# conditional branching statement
C# conditional branching statement
 
Decisions
DecisionsDecisions
Decisions
 
Type conversion
Type conversionType conversion
Type conversion
 
Type casting in c programming
Type casting in c programmingType casting in c programming
Type casting in c programming
 
C –imp points
C –imp pointsC –imp points
C –imp points
 
For Loops and Variables in Java
For Loops and Variables in JavaFor Loops and Variables in Java
For Loops and Variables in Java
 
Introduction
IntroductionIntroduction
Introduction
 
Operators
OperatorsOperators
Operators
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
Vb.Net 01 To 03 Summary Upload
Vb.Net 01 To 03 Summary UploadVb.Net 01 To 03 Summary Upload
Vb.Net 01 To 03 Summary Upload
 
C sharp_basic_ideas
C sharp_basic_ideasC sharp_basic_ideas
C sharp_basic_ideas
 
Selection statements
Selection statementsSelection statements
Selection statements
 
Conditional statement
Conditional statementConditional statement
Conditional statement
 
Compiler lab final report writing
Compiler lab final report writingCompiler lab final report writing
Compiler lab final report writing
 
CIS 1403 lab 4 selection
CIS 1403 lab 4 selectionCIS 1403 lab 4 selection
CIS 1403 lab 4 selection
 
FUNDAMENTAL OF C
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
 
Type conversion in c
Type conversion in cType conversion in c
Type conversion in c
 
Vb decision making statements
Vb decision making statementsVb decision making statements
Vb decision making statements
 
Overview of C Language
Overview of C LanguageOverview of C Language
Overview of C Language
 

Andere mochten auch

EJERCICIOS DE LÓGICA MATEMÁTICA BETTY MARTINEZ
EJERCICIOS DE LÓGICA MATEMÁTICA  BETTY MARTINEZEJERCICIOS DE LÓGICA MATEMÁTICA  BETTY MARTINEZ
EJERCICIOS DE LÓGICA MATEMÁTICA BETTY MARTINEZ
Tyta Martinez
 
Actividad consulta. fraudulentos vencidos metodos de desechos
Actividad consulta. fraudulentos vencidos metodos de desechosActividad consulta. fraudulentos vencidos metodos de desechos
Actividad consulta. fraudulentos vencidos metodos de desechos
lorenaarias3261997
 
Computer programing
Computer programingComputer programing
Computer programing
JT Taylor
 

Andere mochten auch (20)

EJERCICIOS DE LÓGICA MATEMÁTICA BETTY MARTINEZ
EJERCICIOS DE LÓGICA MATEMÁTICA  BETTY MARTINEZEJERCICIOS DE LÓGICA MATEMÁTICA  BETTY MARTINEZ
EJERCICIOS DE LÓGICA MATEMÁTICA BETTY MARTINEZ
 
Business Models and Entrepreneurial Strategy
Business Models and Entrepreneurial StrategyBusiness Models and Entrepreneurial Strategy
Business Models and Entrepreneurial Strategy
 
Examen final brayan
Examen final brayanExamen final brayan
Examen final brayan
 
Affordable care act final project
Affordable care act final projectAffordable care act final project
Affordable care act final project
 
Guia de power point
Guia de power pointGuia de power point
Guia de power point
 
dementia interdisciplinary
dementia interdisciplinarydementia interdisciplinary
dementia interdisciplinary
 
Functional Resume
Functional Resume Functional Resume
Functional Resume
 
Actividad consulta. fraudulentos vencidos metodos de desechos
Actividad consulta. fraudulentos vencidos metodos de desechosActividad consulta. fraudulentos vencidos metodos de desechos
Actividad consulta. fraudulentos vencidos metodos de desechos
 
Diapositivas 8d
Diapositivas 8dDiapositivas 8d
Diapositivas 8d
 
Segunda guerra mundial 1939
Segunda guerra mundial 1939Segunda guerra mundial 1939
Segunda guerra mundial 1939
 
Supriya Resume
Supriya ResumeSupriya Resume
Supriya Resume
 
Trade smart case studies
Trade smart case studiesTrade smart case studies
Trade smart case studies
 
Presentación daysi dominguez
Presentación daysi dominguezPresentación daysi dominguez
Presentación daysi dominguez
 
Evaluacion de proyectos
Evaluacion de proyectosEvaluacion de proyectos
Evaluacion de proyectos
 
Aula3 T23
Aula3 T23Aula3 T23
Aula3 T23
 
Vibo
ViboVibo
Vibo
 
AKL
AKLAKL
AKL
 
Mobile Programing
Mobile ProgramingMobile Programing
Mobile Programing
 
Computer programing
Computer programingComputer programing
Computer programing
 
The ROI of cloud computing
The ROI of cloud computingThe ROI of cloud computing
The ROI of cloud computing
 

Ähnlich wie CPU

data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de la
LEOFAKE
 
Kuliah komputer pemrograman
Kuliah  komputer pemrogramanKuliah  komputer pemrograman
Kuliah komputer pemrograman
hardryu
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
KrishanPalSingh39
 
Csharp4 operators and_casts
Csharp4 operators and_castsCsharp4 operators and_casts
Csharp4 operators and_casts
Abed Bukhari
 

Ähnlich wie CPU (20)

C C++ tutorial for beginners- tibacademy.in
C C++ tutorial for beginners- tibacademy.inC C++ tutorial for beginners- tibacademy.in
C C++ tutorial for beginners- tibacademy.in
 
c_tutorial_2.ppt
c_tutorial_2.pptc_tutorial_2.ppt
c_tutorial_2.ppt
 
C tutorial
C tutorialC tutorial
C tutorial
 
data type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de ladata type.pptxddddswwyertr hai na ki extend kr de la
data type.pptxddddswwyertr hai na ki extend kr de la
 
Kuliah komputer pemrograman
Kuliah  komputer pemrogramanKuliah  komputer pemrograman
Kuliah komputer pemrograman
 
C tutorial
C tutorialC tutorial
C tutorial
 
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdfguia de referencia para a linguagem do fabricante CCS info_syntax.pdf
guia de referencia para a linguagem do fabricante CCS info_syntax.pdf
 
presentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptxpresentation_data_types_and_operators_1513499834_241350.pptx
presentation_data_types_and_operators_1513499834_241350.pptx
 
Basic Of C language
Basic Of C languageBasic Of C language
Basic Of C language
 
additional.pptx
additional.pptxadditional.pptx
additional.pptx
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
CHAPTER 2
CHAPTER 2CHAPTER 2
CHAPTER 2
 
Python
PythonPython
Python
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
Csharp4 operators and_casts
Csharp4 operators and_castsCsharp4 operators and_casts
Csharp4 operators and_casts
 
Token and operators
Token and operatorsToken and operators
Token and operators
 
Data types
Data typesData types
Data types
 
PE1 Module 2.ppt
PE1 Module 2.pptPE1 Module 2.ppt
PE1 Module 2.ppt
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
 

Kürzlich hochgeladen

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 

Kürzlich hochgeladen (20)

Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 

CPU

  • 2.  COMPUTER PROGRAMING & UTILIZATION  Prepared by: Meet Patel 140170119056 Sindhi Parth 140170119057 Soni Kunjan 140170119058 Thakor Chetan 140170119059 Thakor Milan 140170119060
  • 3. OUTLINE  Data Types & Variables  Arithmetic & Logical Operations  Conditionals  Loops
  • 4. Name Description Size* Range* char Character or small integer 1 byte signed: -128 to 127 unsigned: 0 to 255 short int (short) Short integer 2 bytes signed: -32768 to 32767 unsigned: 0 to 65535 int Integer 4 bytes signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 long int (long) Long integer 4 bytes signed: -2147483648 to 2147483647 unsigned: 0 to 4294967295 float Floating point number 4 bytes 3.4e +/- 38 (7 digits) double Double precision floating point number 8 bytes 1.7e +/- 308 (15 digits) long double Long double precision floating point number 8 bytes 1.7e +/- 308 (15 digits) Data types
  • 5.  Variable Declaration int length = 100; char num = ‘9’; //The actual value is 57 float deposit = 240.5; unsigned short ID = 0x5544; Try the following statements, and see what happens unsigned char value = -1; printf(“The value is %d n”, value); unsigned char value = 300; printf(“The value is %d n”, value);
  • 6. Result Definition Memory layout Display comment unsigned char value = -1 11111111 255 unsigned char value = 300 00101100 44 overflow
  • 7.  Local variable Local variables are declared within the body of a function, and can only be used within that function.  Static variable Another class of local variable is the static type. It is specified by the keyword static in the variable declaration. The most striking difference from a non-static local variable is, a static variable is not destroyed on exit from the function.  Global variable A global variable declaration looks normal, but is located outside any of the program's functions. So it is accessible to all functions. Variable types
  • 8. Variable Definition vs Declaration Definition Tell the compiler about the variable: its type and name, as well as allocated a memory cell for the variable Declaration Describe information ``about'' the variable, doesn’t allocate memory cell for the variable
  • 9.
  • 12. Increment and Decrement Operators awkward easy easiest x = x+1; x += 1 x++ x = x-1; x -= 1 x--
  • 13. Example  Arithmetic operators int i = 10; int j = 15; int add = i + j; //25 int diff = j – i; //5 int product = i * j; // 150 int quotient = j / i; // 1 int residual = j % i; // 5 i++; //Increase by 1 i--; //Decrease by 1
  • 14.  Comparing them int I = 10; int j = 15; float k = 15.0; j / i = ? j % i = ? k / i = ? k % i = ? The Answer j / I = 1; j % I = 5; k / I = 1.5; k % I It is illegal. Note: For %, the operands can only be integers.
  • 15. Logical Operations  What is “true” and “false” in C In C, there is no specific data type to represent “true” and “false”. C uses value “0” to represent “false”, and uses non-zero value to stand for “true”.  Logical Operators A && B => A and B A || B => A or B A == B => Is A equal to B? A != B => Is A not equal to B?
  • 16. A > B => Is A greater than B? A >= B => Is A greater than or equal to B? A < B => Is A less than B? A <= B => Is A less than or equal to B?  Don’t be confused && and || have different meanings from & and |. & and | are bitwise operators.
  • 17. Conditionals  if statement Three basic formats, if (expression){ statement … } if (expression) { statement … }else{ statement … }  if (expression) { statement… } else if (expression) { statement… } else{ statement… }
  • 18.  The switch statement switch (expression) { case item1: statement; break; case item2: statement; break; default: statement; break; }
  • 19. Loops  for statement for (expression1; expression2; expression3){ statement… } expression1 initializes; expression2 is the terminate test; expression3 is the modifier;
  • 20.  The while statement while (expression) { statement … } while loop exits only when the expression is false.  An example int x = 3; while (x>0) { printf("x=%d n",x); x--; }
  • 21. for <==> while for (expression1; expression2; expression3){ statement… } expression1; while (expression2) { statement…; expression3; } equals