SlideShare a Scribd company logo
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)

More Related Content

PDF
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
PDF
Xi CBSE Computer Science lab programs
Prof. Dr. K. Adisesha
 
PDF
Dummy log generation using poisson sampling
Kwanghee Choi
 
PPTX
Hello world program
mohamedsaad24
 
PPTX
Python Basis Tutorial
md sathees
 
PDF
A formalization of complex event stream processing
Sylvain Hallé
 
PDF
Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)
Sylvain Hallé
 
2Bytesprog2 course_2014_c1_sets
kinan keshkeh
 
Xi CBSE Computer Science lab programs
Prof. Dr. K. Adisesha
 
Dummy log generation using poisson sampling
Kwanghee Choi
 
Hello world program
mohamedsaad24
 
Python Basis Tutorial
md sathees
 
A formalization of complex event stream processing
Sylvain Hallé
 
Runtime Monitoring of Stream Logic Formulae (Talk @ FPS 2015)
Sylvain Hallé
 

What's hot (15)

ODT
Ecet 330 final exam new 2016
sergejsvolkovs10
 
PDF
A nice 64-bit error in C
PVS-Studio
 
PPTX
Pa1 loops
aiclub_slides
 
PDF
Adaptive Compilation by Jecel Mattos de Assumpção Jr
FAST
 
PDF
Verilog VHDL code Parallel adder
Bharti Airtel Ltd.
 
PDF
VERILOG CODE FOR Adder
Rakesh kumar jha
 
PPT
Concept of c
Rohan Gajre
 
PPTX
F# for Trading
Phillip Trelford
 
PPT
parellel computing
katakdound
 
PDF
Cc 16
Web Developer
 
PPTX
C++ by shantu
Shant007
 
PDF
Chapter 7 - Input Output Statements in C++
Deepak Singh
 
PDF
Computer Practical
PLKFM
 
DOCX
Programacion
HenryMalave1
 
Ecet 330 final exam new 2016
sergejsvolkovs10
 
A nice 64-bit error in C
PVS-Studio
 
Pa1 loops
aiclub_slides
 
Adaptive Compilation by Jecel Mattos de Assumpção Jr
FAST
 
Verilog VHDL code Parallel adder
Bharti Airtel Ltd.
 
VERILOG CODE FOR Adder
Rakesh kumar jha
 
Concept of c
Rohan Gajre
 
F# for Trading
Phillip Trelford
 
parellel computing
katakdound
 
C++ by shantu
Shant007
 
Chapter 7 - Input Output Statements in C++
Deepak Singh
 
Computer Practical
PLKFM
 
Programacion
HenryMalave1
 
Ad

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

PDF
Lenguaje de Programación en C Presentacion
jicemtec
 
PPTX
Microcontroller lec 3
Ibrahim Reda
 
PDF
2 1. variables & data types
웅식 전
 
PPTX
Data Type in C Programming
Qazi Shahzad Ali
 
PPTX
C for Engineers
Julie Iskander
 
PDF
C programing Tutorial
Mahira Banu
 
PDF
CP Handout#5
trupti1976
 
DOCX
C tutorials
Amit Kapoor
 
DOC
C language
SMS2007
 
PPTX
C programming language
Abin Rimal
 
PPTX
COM1407: Variables and Data Types
Hemantha Kulathilake
 
DOCX
Complete c programming presentation
nadim akber
 
DOC
C notes for exam preparation
Lakshmi Sarvani Videla
 
PPTX
Fundamentals of Programming Constructs.pptx
vijayapraba1
 
PPTX
C programming
AsifRahaman16
 
PPS
T02 a firstcprogram
princepavan
 
PPS
T02 a firstcprogram
princepavan
 
PPT
C the basic concepts
Abhinav Vatsa
 
PPT
C tutorial
Anurag Sukhija
 
Lenguaje de Programación en C Presentacion
jicemtec
 
Microcontroller lec 3
Ibrahim Reda
 
2 1. variables & data types
웅식 전
 
Data Type in C Programming
Qazi Shahzad Ali
 
C for Engineers
Julie Iskander
 
C programing Tutorial
Mahira Banu
 
CP Handout#5
trupti1976
 
C tutorials
Amit Kapoor
 
C language
SMS2007
 
C programming language
Abin Rimal
 
COM1407: Variables and Data Types
Hemantha Kulathilake
 
Complete c programming presentation
nadim akber
 
C notes for exam preparation
Lakshmi Sarvani Videla
 
Fundamentals of Programming Constructs.pptx
vijayapraba1
 
C programming
AsifRahaman16
 
T02 a firstcprogram
princepavan
 
T02 a firstcprogram
princepavan
 
C the basic concepts
Abhinav Vatsa
 
C tutorial
Anurag Sukhija
 
Ad

More from imtiazalijoono (20)

PDF
Embedded systems io programming
imtiazalijoono
 
PDF
Embedded systems tools & peripherals
imtiazalijoono
 
PPTX
Importance of reading and its types.
imtiazalijoono
 
PPTX
Negative amplifiers and its types Positive feedback and Negative feedback
imtiazalijoono
 
PPTX
Multistage amplifiers and Name of coupling Name of multistage amplifier
imtiazalijoono
 
PDF
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
imtiazalijoono
 
PDF
Programming Fundamentals and basic knowledge
imtiazalijoono
 
PDF
Programming Fundamentals Functions in C and types
imtiazalijoono
 
PDF
Software Development Software development process
imtiazalijoono
 
PDF
Programming Fundamentals Decisions
imtiazalijoono
 
PDF
C Building Blocks
imtiazalijoono
 
PDF
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
PPTX
Programming Fundamentals and Programming Languages Concepts Translators
imtiazalijoono
 
PPTX
Programming Fundamentals and Programming Languages Concepts
imtiazalijoono
 
DOCX
Programming Global variable
imtiazalijoono
 
PPTX
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
PPTX
Arithmetic and Arithmetic assignment operators
imtiazalijoono
 
PPTX
INTRODUCTION TO COMPUTER PROGRAMMING
imtiazalijoono
 
PPTX
COMPUTER PROGRAMMING
imtiazalijoono
 
PPTX
COMPUTER PROGRAMMING
imtiazalijoono
 
Embedded systems io programming
imtiazalijoono
 
Embedded systems tools & peripherals
imtiazalijoono
 
Importance of reading and its types.
imtiazalijoono
 
Negative amplifiers and its types Positive feedback and Negative feedback
imtiazalijoono
 
Multistage amplifiers and Name of coupling Name of multistage amplifier
imtiazalijoono
 
Loop Introduction for Loop while Loop do while Loop Nested Loops Values of...
imtiazalijoono
 
Programming Fundamentals and basic knowledge
imtiazalijoono
 
Programming Fundamentals Functions in C and types
imtiazalijoono
 
Software Development Software development process
imtiazalijoono
 
Programming Fundamentals Decisions
imtiazalijoono
 
C Building Blocks
imtiazalijoono
 
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
Programming Fundamentals and Programming Languages Concepts Translators
imtiazalijoono
 
Programming Fundamentals and Programming Languages Concepts
imtiazalijoono
 
Programming Global variable
imtiazalijoono
 
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
Arithmetic and Arithmetic assignment operators
imtiazalijoono
 
INTRODUCTION TO COMPUTER PROGRAMMING
imtiazalijoono
 
COMPUTER PROGRAMMING
imtiazalijoono
 
COMPUTER PROGRAMMING
imtiazalijoono
 

Recently uploaded (20)

PPTX
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PPTX
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
PDF
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
PPTX
Introduction of deep learning in cse.pptx
fizarcse
 
PDF
Zero Carbon Building Performance standard
BassemOsman1
 
PDF
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PPTX
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
PPTX
Color Model in Textile ( RGB, CMYK).pptx
auladhossain191
 
PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PDF
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PDF
Introduction to Data Science: data science process
ShivarkarSandip
 
PPT
Ppt for engineering students application on field effect
lakshmi.ec
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PPTX
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PDF
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 
business incubation centre aaaaaaaaaaaaaa
hodeeesite4
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
MSME 4.0 Template idea hackathon pdf to understand
alaudeenaarish
 
EVS+PRESENTATIONS EVS+PRESENTATIONS like
saiyedaqib429
 
Introduction of deep learning in cse.pptx
fizarcse
 
Zero Carbon Building Performance standard
BassemOsman1
 
Introduction to Ship Engine Room Systems.pdf
Mahmoud Moghtaderi
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
AgentX UiPath Community Webinar series - Delhi
RohitRadhakrishnan8
 
Color Model in Textile ( RGB, CMYK).pptx
auladhossain191
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
20ME702-Mechatronics-UNIT-1,UNIT-2,UNIT-3,UNIT-4,UNIT-5, 2025-2026
Mohanumar S
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
Introduction to Data Science: data science process
ShivarkarSandip
 
Ppt for engineering students application on field effect
lakshmi.ec
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
22PCOAM21 Session 2 Understanding Data Source.pptx
Guru Nanak Technical Institutions
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
dse_final_merit_2025_26 gtgfffffcjjjuuyy
rushabhjain127
 

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)