Introduction to Algorithms and Programming COMP151

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick Strings #include using namespace std; int main () { string word; cout
Advertisements

For(int i = 1; i
Computer Science 1620 Math Library. Remember this program? suppose that I invest $25000 into a mutual fund that returns 8% per year. Write a program to.
Introduction to C++ Programming. Brief Facts About C++ Evolved from C Designed and implemented by Bjarne Stroustrup at the Bell Labs in the early 1980s.
Pass by Value. COMP104 Pass by Value / Slide 2 Passing Parameters by Value * A function returns a single result (assuming the function is not a void function)
Factorial Preparatory Exercise #include using namespace std; double fact(double); int fact(int); int main(void) { const int n=20; ofstream my_file("results.txt");
Vectors, lists and queues
Chapter 6 Advanced Function Features Pass by Value Pass by Reference Const parameters Overloaded functions.
Write a function to calculate the cubic function: y = 4x 3 + 2x 2 –5x – 4 The function should return y for any given value of x. Question One #include.
Functions Prototypes, parameter passing, return values, activation frams.
Problem You require an algorithm that will receive the length of the hypotenuse and one of the sides of a right triangle, and calculate the length of the.
ELEC 206 Computer Applications for Electrical Engineers Dr. Ron Hayne
Derived data types Dealing with data –Where the information is stored –What value is kept there –What kind of information is stored Address operator Pointers.
Exercise 2.
Revision.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 102 Computer Programming II (Lab:
第三次小考. #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
Tinaliah, S. Kom.. * * * * * * * * * * * * * * * * * #include using namespace std; void main () { for (int i = 1; i
Triana Elizabeth, S.Kom. #include using namespace std; void main () { for (int i = 1; i
Esempio Polimorfismo1 // Definition of abstract base class Shape #ifndef SHAPE_H #define SHAPE_H class Shape { public: virtual double area() const { return.
Introduction to Functions Programming. COMP102 Prog Fundamentals I: Introduction to Functions /Slide 2 Introduction to Functions l A complex problem is.
More on Functions Programming. COMP104 Lecture 19 / Slide 2 Passing Parameters by Reference l To have a function with multiple outputs, we have to use.
Exercise Exercise3.1 8 Exercise3.1 9 Exercise
Exercise Exercise Exercise Exercise
1 Lab Session-4 CSIT121 Fall 2004 Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
Exercise Exercise Exercise Exercise
Exercise Exercise6.1 7 Exercise6.1 8 Exercise6.1 9.
1 Lab Session-3 CSIT121 Fall 2003 Some Questions Scope of Variables Top Down Design Problem The Solution Lab Exercise for Demo.
Summary of Loops Programming. COMP102 Prog Fundamentals I: Summary of Loops /Slide 2 Which Loop to Use? l for loop n for calculations that are repeated.
1 Session-9 CSIT 121 Spring 2006 Lab Demo (first 20 minutes) The correct way to do the previous lab sheet Function calls Calling void functions Calling.
C++ programming I Lab#3 Control Statements Instructor: Eng. Ruba A. Salamah Tuseday: 17/10/2010.
CS1201: Programming Language 2 Recursion By: Nouf Almunyif.
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.
Objective: Students will be able to: Declare and use variables Input integers.
Input a number #include using namespace std; int main() { int num; cout num; return 0; }
Lecture 4 1 Loops - Exercises. Lecture 4 Exercise 1 2 What is the value of x when the do... while loop completes? int x = 10, k; do{ k = ++x; x -= 2;
1 Lab Session-IV CSIT121 Spring 2002 Some Questions Scope of Variables Top Down Design Problem The Solution Lab Exercises Lab Exercise for Demo.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Functions Jordi Cortadella Department of Computer Science.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
Pointers A variable that holds an address value is called a pointer variable, or simply a pointer.  What is the data type of pointer variables? It’s not.
LESSON 5 Loop Control Structure. Loop Control Structure  Operation made over and over again.  Iterate statement.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
DEVRY COMP 122 Lab 4 Lab Report and Source Code Check this A+ tutorial guideline at
Pointers What is the data type of pointer variables?
Fucntions in C++ Malik Jahan Khan
#define #include<iostream> using namespace std; #define GO
Object Oriented Programming Mansoor Ahmed Bughio
Chapter 4 Loops Case Studies
Static Data Member and Functions
Dynamic Memory Allocation Reference Variables
Random Number Generation
Introduction to Algorithms and Programming COMP151
Programming -2 برمجة -2 المحاضرة-7 Lecture-7.
Starting Out with C++: From Control Structures through Objects
Pointers & Functions.
Anatomy of a Function Part 1
Code::Block vs Visual C++
الوحدة الرابعة البرمجة وصياغة حل المسائل البرمجة وأهميتها أهداف الدرس الأول مفهوم البرمجة. الفرق بين المبرمج ومستخدم البرنامج. الحاجة إلى البرامج.
Introduction to Algorithms and Programming COMP151
Control Structures Part 3
CS1201: Programming Language 2
რეკურსიული პროგრამირება
Introduction to Algorithms and Programming
Pointers & Functions.
Introduction to Algorithms and Programming
Introduction to Algorithms and Programming COMP151
Introduction to Algorithms and Programming COMP151
Reading from and Writing to Files Part 2
Presentation transcript:

Introduction to Algorithms and Programming COMP151 LAB 3 pattern printing Introduction to Algorithms and Programming COMP151

Exercise 1: Print the following : " " " " " " " " " "

#include<iostream> using namespace std; int main() { cout<<"\"\n"; cout<<"\"\t\"\n"; cout<<"\"\t\"\t\"\n"; cout<<"\"\t\"\t\"\t\"\n"; cout<<"\"\t\"\t\"\t\"\t\"\n"; return(0); }

Exercise 2: Print the following: ???????????

#include<iostream> using namespace std; int main() { cout<<"\?\?\?\?\?\?\?\?\?\?\?\n"; cout<<" \?\?\?\?\?\?\?\?\?\?\?\n"; return(0); }

Exercise 3: Print the following: * * * * * * * * * *

#include<iostream> using namespace std; int main() { cout<<"\t\t\t*\n"; cout<<"\t\t*\t\t*\n"; cout<<"\t*\t\t*\t\t*\n"; cout<<"*\t\t*\t\t*\t\t*\n"; return(0); }

Exercise 4: Print the following: * ** ***

#include<iostream> using namespace std; int main() { cout<<" \*\n"; cout<<" \* \*\n"; cout<<" \* \* \*\n"; return(0); }