Unazat FOR.

Slides:



Advertisements
Similar presentations
Chapter 6 Advanced Function Features Pass by Value Pass by Reference Const parameters Overloaded functions.
Advertisements

 2003 Prentice Hall, Inc. All rights reserved. 1 Functions and Recursion Outline some useful problems.
第三次小考. #include using namespace std; int aaa(int *ib,int a1,int a2) { int u,v; int m=(a1+a2)/2; if(a1==a2)return ib[a1]; u=aaa(ib,a1,m); cout
While Loops Programming. COMP102 Prog Fundamentals I: while Loops/Slide 2 Shortcut Assignments l C++ has a set of shortcut operators for applying an operation.
Computer Science 1620 Functions. Given a number n, the factorial of n, written n!, is computed as follows: note: 0! = 1 examples: n! = n x (n-1) x (n-2)
Computer Science 1620 Accumulators. Recall the solution to our financial program: #include using namespace std; int main() { double balance = ;
1 Lecture 10:Control Structures II (Repetition) Introduction to Computer Science Spring 2006.
Computer Science 1620 Function Scope & Global Variables.
1 9/08/06CS150 Introduction to Computer Science 1 Arithmetic Operators.
1 9/25/06CS150 Introduction to Computer Science 1 Nested Ifs, Logical Operators, exit() Page 194.
1 CS150 Introduction to Computer Science 1 Exponents & Output page & Section 3.8.
1 9/26/07CS150 Introduction to Computer Science 1 Exponents & Output page & Section 3.8.
Loops Programming. COMP104 Lecture 9 / Slide 2 Shortcut Assignment l C++ has a set of operators for applying an operation to a variable and then storing.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Lecture 6: Expressions and Interactivity (Part II) Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
Module 4: Structures ITEI222 Advanced Programming.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Current Assignments Homework 3 is due tonight. Iteration and basic functions. Exam 1 on Monday.
ITEC 320 C++ Examples.
Tracing through E01, question 9 – step 1 // p02.cc P. Conrad, for CISC181 07S // Exam question for E01 #include using namespace std; void mysteryFunction(int.
COMP102 – Programming Fundamentals I LA2B (Mon 5-7pm) LA2E (Fri 3-5pm) LA2F (Fri 5-7pm) TA: Jackie Lo.
Lecture 7: Making Decisions Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
1 Manipulators manipulators are used only in input and output statements endl, fixed, showpoint, setw, and setprecision are manipulators that can be used.
CSE 332: C++ template examples Today: Using Class and Function Templates Two examples –Function template for printing different types –Class template for.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Chapter 05 (Part II) Control Statements: Part II.
Chapter 2 Creating a C++ Program. Elements of a C++ Program Four basic ways of structuring a program Four basic ways of structuring a program 1.Sequencing.
1 Compiler directive: #define, usage 1 #include using namespace std; #define TAX //double TAX=0.08; #define LAST_NAME "Li" #define FIRST_NAME "Dennis"
Intro. to Computer Programming Eng. Nehal A. Mohamed Spring Semester-2016.
Chapter five exercises. a. false; b. true; c. false; d. true; e. true; f. true; g. true; h. false.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
1 C++ Classes and Data Structures Course link…..
Example 21 #include<iostream.h> int main() { char Letter = 0;
Chapter 13 Introduction to C++ Language
LESSON 2 Basic of C++.
#define #include<iostream> using namespace std; #define GO
Welcome to Who Wants to be a Millionaire
Introduction to Programming
Programming Fundamentals
לולאות קרן כליף.
Universiteti Shtetëror i Tetovës Fakulteti i Shkencave Matematike-Natyrore Departamenti i Informatikës PROGRAMIM.
Reserved Words.
Dynamic Memory Allocation Reference Variables
Programming -2 برمجة -2 المحاضرة-5 Lecture-5.
פונקציות לעיתים קרובות לא נוח להגדיר את כל התוכנה בתוך גוף אחד.
Të llogaritet shuma e elementeve të vektorit.
אבני היסוד של תוכנית ב- C++
אבני היסוד של תוכנית ב- C++
Programming -2 برمجة -2 المحاضرة-7 Lecture-7.
Screen output // Definition and use of variables
5. Unazat.
הרצאה 03 אבני היסוד של תוכנית ב- C
6. Unaza While dhe Do While
F U N K S I O N E T.
Counting Loops.
Starting Out with C++: From Control Structures through Objects
Pointers & Functions.
اصول کامپیوتر ۱ مبانی کامپیوتر و برنامه‌سازی
Code::Block vs Visual C++
Targetimi i elementeve specifike
Degëzimet.
Programim I Degëzimet Gazmend Xhaferi.
Variablat dhe konstantet
Degëzimet.
Pointers & Functions.
(Dreaded) Quiz 2 Next Monday.
Unazat while.
Reading from and Writing to Files Part 2
Introduction to Algorithms and Programming COMP151
Operatorët.
Presentation transcript:

Unazat FOR

Unazat FOR Gjatë realizimit të unazave for mund të paraqiten disa raste karakteristike, të cilat mund të quhen si: unaza të zakonshme, unaza të përbëra dhe unaza të ndërthurura 13:16

Unazat e zakonshme Unazat brenda të cilave përfshihet vetëm një komandë quhen unaza të zakonshme Nëse për realizimin e unazave të zakonshme shfrytëzohet komanda for, në formë të përgjithshme ajo shkruhet kështu: for (i=f; i<=p;i=i+h) a false

Bllok-diagrami i unazës FOR i=f i<=p false true a false i=i+h

Shembull #include<iostream> using namespace std; int main() { int i,n; double s=0; cout << "Vlera e variables n="; cin >> n; for(i=2; i<=n; i=i+2) s=s+i*i; cout << "Shuma e katroreve te numrave cift s=" << s << "\n"; return 0; } false

Shembull #include<iostream> #include<iomanip> using namespace std; int main() { const int a=1, b=5; double r, pi=3.14159; char T[]="-----------------------"; cout << " r s p" << endl << T <<endl; for(r=a; r<=b; r=r+0.5) { cout << fixed << setprecision(2) << setw (6) << r << setw(8) << pi*r*r <<2*pi*r <<endl;} cout << T << endl; return 0; } false

Unaza të ndërthurura Brenda një unaze mund të përfshihen edhe unaza të tjera, me kusht që ato të mos priten mes vete #include<iostream> #include<iomanip> using namespace std; int main() { int i, j; for (i=0; i<=9;i++) { for (j=0;j<=i;j++) cout << setw(3) << j; cout << endl;} return 0; } false