SlideShare una empresa de Scribd logo
1 de 16
COMPUTER PROGRAMMING
Imtiaz Ali
INTRODUCTION TO COMPUTER PROGRAMMING
1) Loop as repetitive statement, For loop/statement.
2) While loop statement and do while loop statement.
3) Variable Types, Data types, ranges and width.
For loop or For statement
• It is the construct to repeat a body to be executed upto a
number of times depending on condition.
Syntax:
for(initialization;checking;increment)
{
// body of for loop
}
Program to generate numbers 1 to 100
#include<stdio.h>
void main(void)
{
int counter;
for(counter=1;counter<=100;counter++)
{
printf(“%d=”,counter);
}
}
Program to generate Hello Quest message 100 times
#include<stdio.h>
void main(void)
{
int counter;
for(counter=1;counter<=100;counter++)
{
printf(“Hello Quest”);
}
}
While loop
Syntax:
initialization
while(checking)
{
// body of for loop
increment
}
Program to generate numbers 1 to 100
#include<stdio.h>
void main(void)
{
int counter=1;
while(counter<=100)
{
printf(“%d=”,counter);
counter++;
}
}
Program to generate Hello Quest message 100 times
#include<stdio.h>
void main(void)
{
int counter=1;
while(counter<=100)
{
printf(“Hello Quest”);
counter++;
}
}
do-while loop
Syntax:
initialization
do {
// body of for loop
increment
} while(checking);
Program to generate numbers 1 to 100
#include<stdio.h>
void main(void)
{
int counter=1;
do
{
printf(“%d=”,counter);
counter++;
}while(counter<=100);
}
Program to generate Hello Quest message 100 times
#include<stdio.h>
void main(void)
{
int counter=1;
do
{
printf(“Hello Quest”);
counter++;
}while(counter<=100);
}
• Technical difference among for, while and do-while loop
• Write a program in C using loop to generate even
numbers from 1 to 100
• Write a program in C using loop statement to generate
odd numbers from 1 to 100
• Write a program in C using loop to generate even
numbers from 100 to 1
• Write a program in C using loop statement to generate
odd numbers from 100 to 1
• Write a program in C using loop statement to generate
table of any number
• Write a program in C using loop statements to generate 1
one time, 2 times 3….. Upto 10 ten times
1
2 2
• Write a program in C using loop statements to generate 1
one time, 2 times 3….. upto 10 ten times
1
2 2
…..
10 10 10 10 10 10 10 10 10 10
• Write a program in C using loop statements to generate
10 ten times, 9 nine times….. upto 1 one time
10 10 10 10 10 10 10 10 10 10
9 9 9 9 9 9 9 9 9
…
1
• Write a program in C using loop statements to generate
(a) *
**
***
****
*****
(b)
*****
****
***
**
*
Data types
• short int (short)
• unsigned short int (unsigned short)
• char
• unsigned char
• signed char
• int
• unsigned int(unsigned)
• long int(long)
• unsigned long int(unsigned long)
• float
• double
• long double
Data types
Ranges of values that can be stored in variables of these
types will depend on the compiler you are using, but on an
IBM PC’s and Borland turbo c compiler the ranges are:
• short int -128 to 127(1 byte)
• unsigned short int (unsigned short) 0 to 255(1 byte)
• char 0 to 255 or -128 to +127(1 byte)
• unsigned char 0 to 255(1 byte)
• signed char -128 to +127(1 byte)
• int -32768 to +32767(2 byte)
• unsigned int(unsigned) 0 to 65,535(2 byte)
• long int(long) -2147,483648 to 2147,483647(4 byte)
• unsigned long int(unsigned long) 0 to 4,294,967,295(4 byte)
• float single precision floating point(4 byte)
• double double precision floating point(8 byte)
• long double extended precision floating point(10 byte)

Más contenido relacionado

La actualidad más candente

Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++
Deepak Singh
 
Computer Practical
Computer PracticalComputer Practical
Computer Practical
PLKFM
 

La actualidad más candente (15)

Ecet 330 final exam new 2016
Ecet 330 final exam new 2016Ecet 330 final exam new 2016
Ecet 330 final exam new 2016
 
A nice 64-bit error in C
A  nice 64-bit error in CA  nice 64-bit error in C
A nice 64-bit error in C
 
Pa1 loops
Pa1 loopsPa1 loops
Pa1 loops
 
Adaptive Compilation by Jecel Mattos de Assumpção Jr
Adaptive Compilation by Jecel Mattos de Assumpção JrAdaptive Compilation by Jecel Mattos de Assumpção Jr
Adaptive Compilation by Jecel Mattos de Assumpção Jr
 
Verilog VHDL code Parallel adder
Verilog VHDL code Parallel adder Verilog VHDL code Parallel adder
Verilog VHDL code Parallel adder
 
VERILOG CODE FOR Adder
VERILOG CODE FOR AdderVERILOG CODE FOR Adder
VERILOG CODE FOR Adder
 
Concept of c
Concept of cConcept of c
Concept of c
 
F# for Trading
F# for TradingF# for Trading
F# for Trading
 
parellel computing
parellel computingparellel computing
parellel computing
 
Cpp
CppCpp
Cpp
 
Cc 16
Cc 16Cc 16
Cc 16
 
C++ by shantu
C++ by shantuC++ by shantu
C++ by shantu
 
Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++Chapter 7 - Input Output Statements in C++
Chapter 7 - Input Output Statements in C++
 
Computer Practical
Computer PracticalComputer Practical
Computer Practical
 
Programacion
ProgramacionProgramacion
Programacion
 

Similar a NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,

Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)
jewelyngrace
 

Similar a NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement, (20)

270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt
 
Survey of programming language getting started in C
Survey of programming language getting started in CSurvey of programming language getting started in C
Survey of programming language getting started in C
 
270 1 c_intro_up_to_functions
270 1 c_intro_up_to_functions270 1 c_intro_up_to_functions
270 1 c_intro_up_to_functions
 
270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt
 
C for Engineers
C for EngineersC for Engineers
C for Engineers
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt270_1_CIntro_Up_To_Functions.ppt
270_1_CIntro_Up_To_Functions.ppt
 
Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)Final project powerpoint template (fndprg) (1)
Final project powerpoint template (fndprg) (1)
 
Complete c programming presentation
Complete c programming presentationComplete c programming presentation
Complete c programming presentation
 
c++ referesher 1.pdf
c++ referesher 1.pdfc++ referesher 1.pdf
c++ referesher 1.pdf
 
Discussing Fundamentals of C
Discussing Fundamentals of CDiscussing Fundamentals of C
Discussing Fundamentals of C
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
Chp1(c 2 c++)
Chp1(c 2 c++)Chp1(c 2 c++)
Chp1(c 2 c++)
 
Basic c
Basic cBasic c
Basic c
 
C++ L01-Variables
C++ L01-VariablesC++ L01-Variables
C++ L01-Variables
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1
 
Programming using c++ tool
Programming using c++ toolProgramming using c++ tool
Programming using c++ tool
 
C tutorials
C tutorialsC tutorials
C tutorials
 
Lecture1
Lecture1Lecture1
Lecture1
 

Más de imtiazalijoono

Más de imtiazalijoono (20)

Embedded systems io programming
Embedded systems   io programmingEmbedded systems   io programming
Embedded systems io programming
 
Embedded systems tools & peripherals
Embedded systems   tools & peripheralsEmbedded systems   tools & peripherals
Embedded systems tools & peripherals
 
Importance of reading and its types.
Importance of reading and its types.Importance of reading and its types.
Importance of reading and its types.
 
Negative amplifiers and its types Positive feedback and Negative feedback
Negative amplifiers and its types Positive feedback  and Negative feedbackNegative amplifiers and its types Positive feedback  and Negative feedback
Negative amplifiers and its types Positive feedback and Negative feedback
 
Multistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifierMultistage amplifiers and Name of coupling Name of multistage amplifier
Multistage amplifiers and Name of coupling Name of multistage amplifier
 
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...Loop Introduction for Loop  while Loop do while Loop  Nested Loops  Values of...
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
 
Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge Programming Fundamentals and basic knowledge
Programming Fundamentals and basic knowledge
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
Software Development Software development process
Software Development Software development processSoftware Development Software development process
Software Development Software development process
 
Programming Fundamentals Decisions
Programming Fundamentals  Decisions Programming Fundamentals  Decisions
Programming Fundamentals Decisions
 
C Building Blocks
C Building Blocks C Building Blocks
C Building Blocks
 
Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Programming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts TranslatorsProgramming Fundamentals and Programming Languages Concepts Translators
Programming Fundamentals and Programming Languages Concepts Translators
 
Programming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages ConceptsProgramming Fundamentals and Programming Languages Concepts
Programming Fundamentals and Programming Languages Concepts
 
Programming Global variable
Programming Global variableProgramming Global variable
Programming Global variable
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
Arithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operatorsArithmetic and Arithmetic assignment operators
Arithmetic and Arithmetic assignment operators
 
INTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMINGINTRODUCTION TO COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMING
 
COMPUTER PROGRAMMING
COMPUTER PROGRAMMINGCOMPUTER PROGRAMMING
COMPUTER PROGRAMMING
 
COMPUTER PROGRAMMING
COMPUTER PROGRAMMINGCOMPUTER PROGRAMMING
COMPUTER PROGRAMMING
 

Último

notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 

Último (20)

Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
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
 
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
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
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
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 

NTRODUCTION TO COMPUTER PROGRAMMING Loop as repetitive statement,

  • 2. INTRODUCTION TO COMPUTER PROGRAMMING 1) Loop as repetitive statement, For loop/statement. 2) While loop statement and do while loop statement. 3) Variable Types, Data types, ranges and width.
  • 3. For loop or For statement • It is the construct to repeat a body to be executed upto a number of times depending on condition. Syntax: for(initialization;checking;increment) { // body of for loop }
  • 4. Program to generate numbers 1 to 100 #include<stdio.h> void main(void) { int counter; for(counter=1;counter<=100;counter++) { printf(“%d=”,counter); } }
  • 5. Program to generate Hello Quest message 100 times #include<stdio.h> void main(void) { int counter; for(counter=1;counter<=100;counter++) { printf(“Hello Quest”); } }
  • 7. Program to generate numbers 1 to 100 #include<stdio.h> void main(void) { int counter=1; while(counter<=100) { printf(“%d=”,counter); counter++; } }
  • 8. Program to generate Hello Quest message 100 times #include<stdio.h> void main(void) { int counter=1; while(counter<=100) { printf(“Hello Quest”); counter++; } }
  • 9. do-while loop Syntax: initialization do { // body of for loop increment } while(checking);
  • 10. Program to generate numbers 1 to 100 #include<stdio.h> void main(void) { int counter=1; do { printf(“%d=”,counter); counter++; }while(counter<=100); }
  • 11. Program to generate Hello Quest message 100 times #include<stdio.h> void main(void) { int counter=1; do { printf(“Hello Quest”); counter++; }while(counter<=100); }
  • 12. • Technical difference among for, while and do-while loop • Write a program in C using loop to generate even numbers from 1 to 100 • Write a program in C using loop statement to generate odd numbers from 1 to 100 • Write a program in C using loop to generate even numbers from 100 to 1 • Write a program in C using loop statement to generate odd numbers from 100 to 1 • Write a program in C using loop statement to generate table of any number • Write a program in C using loop statements to generate 1 one time, 2 times 3….. Upto 10 ten times 1 2 2
  • 13. • Write a program in C using loop statements to generate 1 one time, 2 times 3….. upto 10 ten times 1 2 2 ….. 10 10 10 10 10 10 10 10 10 10 • Write a program in C using loop statements to generate 10 ten times, 9 nine times….. upto 1 one time 10 10 10 10 10 10 10 10 10 10 9 9 9 9 9 9 9 9 9 … 1
  • 14. • Write a program in C using loop statements to generate (a) * ** *** **** ***** (b) ***** **** *** ** *
  • 15. Data types • short int (short) • unsigned short int (unsigned short) • char • unsigned char • signed char • int • unsigned int(unsigned) • long int(long) • unsigned long int(unsigned long) • float • double • long double
  • 16. Data types Ranges of values that can be stored in variables of these types will depend on the compiler you are using, but on an IBM PC’s and Borland turbo c compiler the ranges are: • short int -128 to 127(1 byte) • unsigned short int (unsigned short) 0 to 255(1 byte) • char 0 to 255 or -128 to +127(1 byte) • unsigned char 0 to 255(1 byte) • signed char -128 to +127(1 byte) • int -32768 to +32767(2 byte) • unsigned int(unsigned) 0 to 65,535(2 byte) • long int(long) -2147,483648 to 2147,483647(4 byte) • unsigned long int(unsigned long) 0 to 4,294,967,295(4 byte) • float single precision floating point(4 byte) • double double precision floating point(8 byte) • long double extended precision floating point(10 byte)