SlideShare une entreprise Scribd logo
1  sur  42
Paradigmas de Linguagens de Programação Paradigma Imperativo [Passagem de parâmetros] Aula #4 (CopyLeft)2009 - Ismar Frango ismar@mackenzie.br
Passagem de parâmetros Valor  – C, Java... Referência  – FORTRAN, C++, Pascal... Resultado  (out) – Ada, C#  Valor-resultado /*Copy-restore*/  (inout) – Ada, C#.  Read-only  – C/C++ (const) Macro  - C Nome  – ALGOL ... “ I write the music, produce it and the band plays within the  parameters  that I set.”  Sting
Passagem por valor vs. referência ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Valor ou referência? int h, i; void B( int* w ) { int j, k; i = 2*(*w); *w = *w+1; }  void A( int* x ,  int* y ) { float i, j; B( &h ); } int main() { int a, b; h = 5; a = 3; b = 2; A( &a ,  &b ); } int* &a
Passagem por valor (C++) 2 1 void f(int *p)  { *p = 5; p = NULL; } int main()  { int x=2; int *q = &x; f(q); } x = 5  q != NULL
Passagem por referência (C++) 2 2 void f(int A[]) { A[0] = 5; } int main() { int B[10]; B[0] = 2; f(B); cout << B[0] << endl;} 5
Testando... void Mystery( int & a, int & b, int c ) { a = b + c; b = 0; c = 0; } void Print() { int x = 0, y = 1, z = 2; Mystery(x, y, z); cout << x << &quot; &quot; << y << &quot; &quot; << z; Mystery(x, y, z); cout << x << &quot; &quot; << y << &quot; &quot; << z << endl; } ,[object Object],[object Object],[object Object],[object Object],[object Object]
Testando... #include <iostream> void Sum(int a, int b, int & c) { a = b + c; b = a + c; c = a + b; } int main() { int x=2, y=3; Sum(x, y, y); cout << x << &quot; &quot; << y << endl; return 0; } ,[object Object],[object Object],[object Object],[object Object],[object Object]
Associação posicional vs. Nomeada (Ada) procedure  POS_PARAM  is  procedure  ADD_UP(X_VAL,Y_VAL,Z_VAL: INTEGER )  is  begin  PUT(X_VAL+Y_VAL+Z_VAL); NEW_LINE;  end  ADD_UP;  begin  end  POS_PARAM ADD_UP(2,4,6);  ADD_UP(X_VAL=>2, Y_VAL=>4, Z_VAL=>6); ADD_UP(Z_VAL=>6, X_VAL=>2, Y_VAL=>4); ADD_UP(2, Z_VAL=>6, Y_VAL=>4);  PPA POSITIONAL PARAMETER ASSOCIATION NPA NAMED PARAMETER ASSOCIATION
Passagem por  valor  x referência (Pascal) program  P; var X, Y:  Integer ; procedure  Swap(A, B:  Integer ); var Temp: begin Temp := A; A := B; B := Temp; end ; begin readln(X, Y); Swap(X, Y); writeln(X, Y) end . valor Novas variáveis no ARI de Swap PFs VL http://stwww.weizmann.ac.il/g-cs/benari/articles/varparm.pdf
Passagem por  valor  x  referência  (Pascal) program  P; var X, Y:  Integer ; procedure  Swap( var  A, B:  Integer ); var Temp: begin Temp := A; A := B; B := Temp; end ; begin readln(X, Y); Swap(X, Y); writeln(X, Y) end . ref aliases VL
Passagem por valor (Java) public class Teste{ private static void aloca(String x) { x=&quot;Hello&quot;;} public static void main(String args[]) { String b=&quot;World&quot;; aloca(b); System.out.println(b); } } World
Passagem por valor (Java) public class Teste{ private static String aloca(String x,String y) { x=x+y; return x;} public static void main(String args[]) { String a=&quot;Hello, &quot;; String b=&quot;World&quot;; String c = aloca(a,b); System.out.println(c==a); String d=&quot;World&quot;; String e=new String(&quot;World&quot;); System.out.println(b==d); System.out.println(b==e); String f=e.intern(); System.out.println(b==f); } } false true false true
Passagem por valor (C#) void  Foo (StringBuilder x)  { x =  null ; }  ...  StringBuilder y =  new  StringBuilder();  y.Append ( &quot;hello&quot; );  Foo (y);  Console.WriteLine (y==null);  false void  Foo (StringBuilder x)  { x.Append ( &quot; World&quot; ); } ...  StringBuilder y =  new  StringBuilder();  y.Append ( “Hello&quot; );  Foo (y);  Console.WriteLine (y);   Hello World
Passagem por valor (Java) String first = new String(“Hello”); String second = first; first += “World”; System.out.println(second); Hello void giveMeAString (Object y)  { y = &quot;This is a string&quot;; }  ... Object x = null;  giveMeAString (x);  System.out.println (x);  null
O que ocorre aqui? public class Teste2 { public static void foo (String x)  { x+=&quot; World&quot;; } public static void main(String []a) { String y = new String(&quot;Hello&quot;);  foo (y);  System.out.println(y);  } } Hello public class Teste3 { public static void foo (StringBuilder x)  { x.append(&quot; World&quot;); } public static void main(String []a) { StringBuilder y = new StringBuilder(); y.append(&quot;Hello&quot;);  foo (y);  System.out.println(y);  } } Hello World
Passagem e Alocação Java  vs. C vs. C# class  Elefante { public int peso=1000;  //:-( Thou shalt not do this! } public class Teste{ public static void main(String args[]) { Elefante  dumbo = new Elefante(); dumbo.peso=2000; Elefante  dumbinho = dumbo; dumbinho.peso=500; System.out.println(dumbo.peso); } } 500 Java
Passagem e Alocação  Java  vs.  C  vs. C# #include <stdio.h> typedef struct  { int peso;  }Elefante; int main() { Elefante *dumbo = malloc (sizeof(Elefante)); dumbo->peso=2000; Elefante *dumbinho = dumbo; dumbinho->peso=500; printf(&quot;%d&quot;,dumbo->peso); return 0; } 500 C
Passagem e Alocação  Java  vs.  C  vs. C# C #include <stdio.h> typedef struct  { int peso;  }Elefante; int main() { Elefante dumbo; dumbo.peso=2000; Elefante dumbinho = dumbo; dumbinho.peso=500; printf(&quot;%d&quot;,dumbo.peso); return 0; } 2000
Java vs. C vs.  C# using System; public  struct  Elefante { public int peso; }  public class testecs { public static void Main(string []a) { Elefante dumbo = new Elefante();  dumbo.peso=2000;  Elefante dumbinho = dumbo;  dumbinho.peso=500;  Console.WriteLine (dumbo.peso);  } } 2000 C#
Java vs. C vs.  C# using System; public  class  Elefante { public int peso; }  public class testecs { public static void Main(string []a) { Elefante dumbo = new Elefante();  dumbo.peso=2000;  Elefante dumbinho = dumbo;  dumbinho.peso=500;  Console.WriteLine (dumbo.peso);  } } 500 C#
Passagem por referência (C#) void  Foo ( ref  StringBuilder x)  { x =  null ; } ... StringBuilder y =  new  StringBuilder();  y.Append ( &quot;hello&quot; );  Foo ( ref  y);  Console.WriteLine (y== null );  using System; using System.Text; public class testecsref { public static void Foo1 ( ref  Elefante x)  { x.peso=1000 ;} public static void Foo2 (Elefante x)  { x.peso=0 ;} public static void Main(string []a) { Elefante dumbo=new Elefante();  Foo1 ( ref  dumbo);  Console.WriteLine (dumbo.peso);  Foo2 (dumbo);  Console.WriteLine (dumbo.peso);  } } public class Elefante { public int peso; }  public struct Elefante { public int peso; }  1000 0 1000 1000 Qual a diferença entre passar um  value object  por referência e um  reference object  por valor? true
Value objects x reference objects (C#) void  Foo ( ref  IntHolder x) { x.i=10; } ...  IntHolder y =  new  IntHolder(); y.i=5;  Foo ( ref  y); Console.WriteLine (y.i);  10 public   struct  IntHolder  {  public   int  i; }  Value object + passagem por referência void  Foo (IntHolder x) { x.i=10; } ...  IntHolder y =  new  IntHolder(); y.i=5;  Foo (y); Console.WriteLine (y.i);  5 public   class  IntHolder  {  public   int  i; }  Reference object + passagem por valor
Parâmetros out (C#) void  Foo ( out   int  x)  {  int  a = x;  // Can't read x here - it's considered unassigned   // Assignment - this must happen before the method can complete normally x = 10;  // The value of x can now be read:   int  a = x;  }  ...  // Declare a variable but don't assign a value to it   int  y;  // Pass it in as an output parameter, even though its value is unassigned   Foo ( out  y);  // It's now assigned a value, so we can write it out:   Console.WriteLine (y);
Parâmetros in, out, in out  (Ada) procedure Quadratic( A, B, C:  in  Float; Root1, Root2:  out  Float); procedure Sort(V:  in out  Vector); with CS_IO; use CS_IO; procedure OUT_MODE_EXAMPLE is VALUE_1, VALUE_2: float; MEAN: float; procedure MEAN_VALUE (NUM_1, NUM_2:  in  float; NUM_3:  out  float) is begin NUM_3:= (NUM_1+NUM_2)/2.0; end MEAN_VALUE; begin MEAN_VALUE(VALUE_1, VALUE_2, MEAN); put(&quot;The mean is &quot;); put(MEAN);new_line; new_line; end OUT_MODE_EXAMPLE;
Parâmetros in, out, in out  (Ada) with CS_IO; use CS_IO; procedure IN_OUT_MODE_EXAMPLE is VALUE_1, VALUE_2: float; procedure MEAN_VALUE (NUM_1:  in out  float; NUM_2:  in  float) is begin NUM_1:= (NUM_1+NUM_2)/2.0; end MEAN_VALUE; begin get(VALUE_1);get(VALUE_2); put(&quot;BEFORE MEAN VALUE: VALUE_1 = &quot;); put(VALUE_1);put(&quot;, VALUE_2 = &quot;);put(VALUE_2);new_line; MEAN_VALUE(VALUE_1, VALUE_2); put(&quot;The mean is &quot;); put(VALUE_1);new_line; put(&quot;AFTER MEAN VALUE: VALUE_1 = &quot;); put(VALUE_1);put(&quot;, VALUE_2 = &quot;);put(VALUE_2);new_line; end IN_OUT_MODE_EXAMPLE;
Parameter arrays –”params” (C#), ... (Java) void  ShowNumbers ( params   int [] numbers) {  foreach  ( int  x  in  numbers)  { Console.Write (x+ &quot; &quot; ); }  Console.WriteLine();  } ...  int [] x = {1, 2, 3};  ShowNumbers (x);  ShowNumbers (4, 5);  static int sum (int ... numbers)  { int total = 0;  for (int i = 0; i < numbers.length; i++)  total += numbers [i];  return total;  }  C# Java
Parâmetros variáveis (C++) void myprintf( char *format, ... ){ va_list  vl; int i; va_start ( vl, args ); for( i = 0; args[i] != ''; ++i ){ union any_t { int i; float f; char c; } any; if( args[i]=='i' ){ any.i = va_arg( vl, int ); printf( &quot;%i&quot;, any.i ); } else if( args[i]=='f' ){ any.f = va_arg( vl, float ); printf( &quot;%f&quot;, any.f ); }else if( args[i]=='c' ){ any.c = va_arg( vl, char ); printf( &quot;%c&quot;, any.c ); } else{ throw SomeException; } va_end(  vl ); }
Parâmetros default (Ada, C++) with CS_IO;  use CS_IO;  procedure EXAMPLE is  N1: float:= 4.2;  N2: float:= 9.6;  procedure MEAN_VALUE (X1: in out float; X2: in float :=  6.4 ) is  begin  X1:= (X1+X2)/2.0;  end MEAN_VALUE begin  MEAN_VALUE(N1); put(N1); new_line;  MEAN_VALUE(N1, N2); put(N1); new_line;  end EXAMPLE;  #include <iostream> using namespace std; int a = 1; int f(int a) { return a; } int g(int x = f(a)) { return x; } int h() { a = 2; { int a = 3; return g(); } } int main() { cout << h() << endl; } 2 O que é impresso aqui?
Parâmetros read-only (C++) class IntList { public: const Print (ostream &o); }; void f(const IntList &L)  { L.Print(cout); }  bool Compare(const vector <int> & A) // precondition: A is sorted { int k; for (k=1; k<A.size(); k++) { if (A[k-1] == A[k]) return true; } return false; } E se aqui não fosse const?
Macros #define MAXLINE 100  char line[MAXLINE]; ... getline(line, MAXLINE);  #define A 2  #define B 3  #define C A + B int x = C * 2;   O que acontece aqui? Por que não tem ponto-e-vírgula?
Pass-by-name (ALGOL) procedure double(x);  real x;  begin  x := x * 2  end;  double(C[j])  C[j] := C[j] * 2. real procedure Sum(j, lo, hi, Ej); value lo, hi; integer j, lo, hi; real Ej; begin real S; S := 0; for j := lo step 1 until hi do S := S + Ej; Sum := S end; Sum(i, 1, n, x[i]*i) Como simular isso em C++ ou Java?
Pass-by-name (ALGOL) procedure swap (a, b); integer a, b, temp; begin temp := a; a := b; b:= temp end; swap(x, y) temp := x;  x := y;  y := temp   swap(i, x[i]) temp := i; i := x[i];  x[i] := temp  Antes i = 2   x[2] = 5   Depois i = 5   x[2] = 5   x[5] = 2
+Exercícios...
/* I f *y is zero and x > 0 : set *k to biggest integer. * If *y is zero and x <=0 : leave *k unchanged. * If *y is not zero : * set *k to be x divided by *y and increment *y by 1. */ #define INT_MAX 1000 void  check_divide ( int  *k,  int  x,  int  *y) { if  (*y = 0) if  (x > 0) *k = INT_MAX; else *k = x / * y  / *  *y  cannot be 0  */ ; *y++; } int main( ) { int a=2;  check_divide(&a, a, &a); cout<<a; } 0 C++
/* I f *y is zero and x > 0 : set *k to biggest integer. * If *y is zero and x <=0 : leave *k unchanged. * If *y is not zero : * set *k to be x divided by *y and increment *y by 1. */ #define INT_MAX 1000 void  check_divide ( int  *k,  int  x,  int  *y) { if  (*y  ==  0)  { if  (x > 0) *k = INT_MAX; } else { *k = x / * y  / *  *y  cannot be 0  */ ; (*y)++;} } int main( ) { int a=2;  check_divide(&a, a, &a); cout<<a; } 3 C++
#define TAM 10 void  change ( int  v[ ],  int  &ntx) { for  (;ntx>0;ntx--) v[ntx]=ntx---1; } int  main() { int  k[TAM],i=0,; for (;;) {  if  (i==TAM)  break ; k[i++]= i*2;} change(k,i); for (;;) {  if  (i>TAM)  break ; cout<<k[i++]<<endl;} } 0 2 1 6 3 10 5 14 7 18 9 C++
using namespace System;  double  average( ... array<Int32>^ arr )  {  int  i = arr->GetLength(0);  double  answer = 0.0;  for  (int j = 0 ; j < i ; j++)  answer += arr[j];  return  answer / i; }  int  main()  { Console::WriteLine(&quot;{0}&quot;, average( 1, 2, 3, 6 )); }  Visual C++ (.NET) 3
void  g ( int  &a) { a++; } void  h ( int  &a) { a*=2; } void  k ( int  &a) { a*=10; } void  f(  int  &number,  void  (*function)( int &) ) { (*function )( number ); } int  main() { int  select, count=0; for  (select = 1; select<=3 ;select++) { switch ( select )  { case  1: f( count, g );  break ; case  2: f( count, h );  break ; case  3: f( count, k ); default: break; } } cout << count; } 20 C++
Pascal procedure  swap(arg1, arg2: integer); var temp : integer; begin temp := arg1; arg1 := arg2; arg2 := temp; end ; ... { in some other procedure/function/program } var var1, var2 : integer; begin var1 := 1; var2 := 2; swap(var1, var2); end ; Var1=1 Var2=2
public class TestY { public static void differentArray(float[] x) { x = new float[100]; x[0] = 26.9f; } public static void main(String a[]) { float[ ] xx = new float[100]; xx[0] = 55.8f; differentArray(xx); System.out.println(&quot;xx[0] = &quot; + xx[0]); } } Java 55.8
procedure sub1(x: int; y: int); begin x := 1; y := 2; x := 2; y := 3; end; sub1(i, a[i]); Algol a={2,3}

Contenu connexe

Tendances

C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrencyxu liwei
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewPaulo Morgado
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Geeks Anonymes
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statementsMomenMostafa
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1Little Tukta Lita
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumlercorehard_by
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 
STL ALGORITHMS
STL ALGORITHMSSTL ALGORITHMS
STL ALGORITHMSfawzmasood
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th StudyChris Ohk
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumpingMomenMostafa
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointersMomenMostafa
 
Антихрупкий TypeScript | Odessa Frontend Meetup #17
Антихрупкий TypeScript | Odessa Frontend Meetup #17Антихрупкий TypeScript | Odessa Frontend Meetup #17
Антихрупкий TypeScript | Odessa Frontend Meetup #17OdessaFrontend
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string libraryMomenMostafa
 

Tendances (20)

C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrency
 
C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 
Idiomatic C++
Idiomatic C++Idiomatic C++
Idiomatic C++
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)
 
4 operators, expressions &amp; statements
4  operators, expressions &amp; statements4  operators, expressions &amp; statements
4 operators, expressions &amp; statements
 
Constructor,destructors cpp
Constructor,destructors cppConstructor,destructors cpp
Constructor,destructors cpp
 
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6  1
ฟังก์ชั่นย่อยและโปรแกรมมาตรฐาน ม. 6 1
 
C++20 the small things - Timur Doumler
C++20 the small things - Timur DoumlerC++20 the small things - Timur Doumler
C++20 the small things - Timur Doumler
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
STL ALGORITHMS
STL ALGORITHMSSTL ALGORITHMS
STL ALGORITHMS
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping6 c control statements branching &amp; jumping
6 c control statements branching &amp; jumping
 
verilog code
verilog codeverilog code
verilog code
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointers
 
C++ references
C++ referencesC++ references
C++ references
 
Антихрупкий TypeScript | Odessa Frontend Meetup #17
Антихрупкий TypeScript | Odessa Frontend Meetup #17Антихрупкий TypeScript | Odessa Frontend Meetup #17
Антихрупкий TypeScript | Odessa Frontend Meetup #17
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
 
9 character string &amp; string library
9  character string &amp; string library9  character string &amp; string library
9 character string &amp; string library
 
C++ Presentation
C++ PresentationC++ Presentation
C++ Presentation
 

En vedette

Paradigmas de Linguagens de Programacao - Aula #7
Paradigmas de Linguagens de Programacao - Aula #7Paradigmas de Linguagens de Programacao - Aula #7
Paradigmas de Linguagens de Programacao - Aula #7Ismar Silveira
 
Paradigmas de Linguagens de Programacao - Aula #6
Paradigmas de Linguagens de Programacao - Aula #6Paradigmas de Linguagens de Programacao - Aula #6
Paradigmas de Linguagens de Programacao - Aula #6Ismar Silveira
 
Lua para Jogos
Lua para JogosLua para Jogos
Lua para JogosDavid Ruiz
 
Paradigmas de Linguagens de Programacao - Aula #3
Paradigmas de Linguagens de Programacao - Aula #3Paradigmas de Linguagens de Programacao - Aula #3
Paradigmas de Linguagens de Programacao - Aula #3Ismar Silveira
 
Criação de Jogos 2D com Técnicas 3D Utilizando Python e C
Criação de Jogos 2D com Técnicas 3D Utilizando Python e CCriação de Jogos 2D com Técnicas 3D Utilizando Python e C
Criação de Jogos 2D com Técnicas 3D Utilizando Python e CLeinylson Fontinele
 
Paradigmas de Linguagens de Programação
Paradigmas de Linguagens de ProgramaçãoParadigmas de Linguagens de Programação
Paradigmas de Linguagens de ProgramaçãoFabio Spanhol
 
Paradigmas de linguagens de programacao - aula#9
Paradigmas de linguagens de programacao - aula#9Paradigmas de linguagens de programacao - aula#9
Paradigmas de linguagens de programacao - aula#9Ismar Silveira
 
Paradigmas de Linguagens de Programacao- Aula #8
Paradigmas de Linguagens de Programacao- Aula #8Paradigmas de Linguagens de Programacao- Aula #8
Paradigmas de Linguagens de Programacao- Aula #8Ismar Silveira
 
Apostila sistema operacional cor capa ficha 2011 02 04
Apostila sistema operacional cor capa ficha 2011 02 04Apostila sistema operacional cor capa ficha 2011 02 04
Apostila sistema operacional cor capa ficha 2011 02 04MatheusRpz
 
Paradigmas de linguagens de programacao - aula#10
Paradigmas de linguagens de programacao - aula#10Paradigmas de linguagens de programacao - aula#10
Paradigmas de linguagens de programacao - aula#10Ismar Silveira
 
Paradigmas de Linguagens de Programacao - Aula #1
Paradigmas de Linguagens de Programacao - Aula #1Paradigmas de Linguagens de Programacao - Aula #1
Paradigmas de Linguagens de Programacao - Aula #1Ismar Silveira
 
Introdução à Computação Aula 01 - Apresentação
Introdução à Computação  Aula 01 - ApresentaçãoIntrodução à Computação  Aula 01 - Apresentação
Introdução à Computação Aula 01 - ApresentaçãoLeinylson Fontinele
 
Introducao ambiente windows
Introducao ambiente windowsIntroducao ambiente windows
Introducao ambiente windowsMatheusRpz
 
Paradigmas de Linguagens de programacao - Aula #2
Paradigmas de Linguagens de programacao - Aula #2Paradigmas de Linguagens de programacao - Aula #2
Paradigmas de Linguagens de programacao - Aula #2Ismar Silveira
 
A Linguagem Lua e suas Aplicações em Jogos
A Linguagem Lua e suas Aplicações em JogosA Linguagem Lua e suas Aplicações em Jogos
A Linguagem Lua e suas Aplicações em Jogoselliando dias
 
Apostila Algoritmos e Estrutura de Dados (AEDS)
Apostila Algoritmos e Estrutura de Dados (AEDS)Apostila Algoritmos e Estrutura de Dados (AEDS)
Apostila Algoritmos e Estrutura de Dados (AEDS)Ricardo Terra
 
Engenharia de Software - Aula1
Engenharia de Software - Aula1Engenharia de Software - Aula1
Engenharia de Software - Aula1Ismar Silveira
 

En vedette (20)

Computacao grafica RGB
Computacao grafica RGBComputacao grafica RGB
Computacao grafica RGB
 
Paradigmas de Linguagens de Programacao - Aula #7
Paradigmas de Linguagens de Programacao - Aula #7Paradigmas de Linguagens de Programacao - Aula #7
Paradigmas de Linguagens de Programacao - Aula #7
 
Paradigmas de Linguagens de Programacao - Aula #6
Paradigmas de Linguagens de Programacao - Aula #6Paradigmas de Linguagens de Programacao - Aula #6
Paradigmas de Linguagens de Programacao - Aula #6
 
Lua para Jogos
Lua para JogosLua para Jogos
Lua para Jogos
 
Paradigmas de Linguagens de Programacao - Aula #3
Paradigmas de Linguagens de Programacao - Aula #3Paradigmas de Linguagens de Programacao - Aula #3
Paradigmas de Linguagens de Programacao - Aula #3
 
Criação de Jogos 2D com Técnicas 3D Utilizando Python e C
Criação de Jogos 2D com Técnicas 3D Utilizando Python e CCriação de Jogos 2D com Técnicas 3D Utilizando Python e C
Criação de Jogos 2D com Técnicas 3D Utilizando Python e C
 
Paradigmas de Linguagens de Programação
Paradigmas de Linguagens de ProgramaçãoParadigmas de Linguagens de Programação
Paradigmas de Linguagens de Programação
 
Paradigmas de linguagens de programacao - aula#9
Paradigmas de linguagens de programacao - aula#9Paradigmas de linguagens de programacao - aula#9
Paradigmas de linguagens de programacao - aula#9
 
E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 9E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 9
 
Paradigmas de Linguagens de Programacao- Aula #8
Paradigmas de Linguagens de Programacao- Aula #8Paradigmas de Linguagens de Programacao- Aula #8
Paradigmas de Linguagens de Programacao- Aula #8
 
Apostila sistema operacional cor capa ficha 2011 02 04
Apostila sistema operacional cor capa ficha 2011 02 04Apostila sistema operacional cor capa ficha 2011 02 04
Apostila sistema operacional cor capa ficha 2011 02 04
 
Paradigmas de linguagens de programacao - aula#10
Paradigmas de linguagens de programacao - aula#10Paradigmas de linguagens de programacao - aula#10
Paradigmas de linguagens de programacao - aula#10
 
A Internet das Coisas
A Internet das CoisasA Internet das Coisas
A Internet das Coisas
 
Paradigmas de Linguagens de Programacao - Aula #1
Paradigmas de Linguagens de Programacao - Aula #1Paradigmas de Linguagens de Programacao - Aula #1
Paradigmas de Linguagens de Programacao - Aula #1
 
Introdução à Computação Aula 01 - Apresentação
Introdução à Computação  Aula 01 - ApresentaçãoIntrodução à Computação  Aula 01 - Apresentação
Introdução à Computação Aula 01 - Apresentação
 
Introducao ambiente windows
Introducao ambiente windowsIntroducao ambiente windows
Introducao ambiente windows
 
Paradigmas de Linguagens de programacao - Aula #2
Paradigmas de Linguagens de programacao - Aula #2Paradigmas de Linguagens de programacao - Aula #2
Paradigmas de Linguagens de programacao - Aula #2
 
A Linguagem Lua e suas Aplicações em Jogos
A Linguagem Lua e suas Aplicações em JogosA Linguagem Lua e suas Aplicações em Jogos
A Linguagem Lua e suas Aplicações em Jogos
 
Apostila Algoritmos e Estrutura de Dados (AEDS)
Apostila Algoritmos e Estrutura de Dados (AEDS)Apostila Algoritmos e Estrutura de Dados (AEDS)
Apostila Algoritmos e Estrutura de Dados (AEDS)
 
Engenharia de Software - Aula1
Engenharia de Software - Aula1Engenharia de Software - Aula1
Engenharia de Software - Aula1
 

Similaire à Paradigmas de Linguagens de Programacao - Aula #4

Similaire à Paradigmas de Linguagens de Programacao - Aula #4 (20)

pointers 1
pointers 1pointers 1
pointers 1
 
Function recap
Function recapFunction recap
Function recap
 
Function recap
Function recapFunction recap
Function recap
 
C++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operatorC++: Constructor, Copy Constructor and Assignment operator
C++: Constructor, Copy Constructor and Assignment operator
 
C programming
C programmingC programming
C programming
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Tu1
Tu1Tu1
Tu1
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Java operators
Java operatorsJava operators
Java operators
 
Array Cont
Array ContArray Cont
Array Cont
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchained
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programming
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
 
Functions
FunctionsFunctions
Functions
 
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docxPROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
PROVIDE COMMENTS TO FELLOW STUDENTS ANSWERS AND PLEASE DON’T SAY G.docx
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
Operators
OperatorsOperators
Operators
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 

Plus de Ismar Silveira

REA - Recursos Educacionais Abertos
REA - Recursos Educacionais AbertosREA - Recursos Educacionais Abertos
REA - Recursos Educacionais AbertosIsmar Silveira
 
Charla juegos udelar2015_vfinal
Charla juegos udelar2015_vfinalCharla juegos udelar2015_vfinal
Charla juegos udelar2015_vfinalIsmar Silveira
 
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional Design
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional DesignInteraccion2014 - Presentation about Open Books, MOOCs and Instructional Design
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional DesignIsmar Silveira
 
#latinproject @openeducationweek2014 - Methodologies
#latinproject @openeducationweek2014 - Methodologies#latinproject @openeducationweek2014 - Methodologies
#latinproject @openeducationweek2014 - MethodologiesIsmar Silveira
 
MOOC e Educação Aberta - Painel @ #cbie2013
MOOC e Educação Aberta - Painel @ #cbie2013MOOC e Educação Aberta - Painel @ #cbie2013
MOOC e Educação Aberta - Painel @ #cbie2013Ismar Silveira
 
E:\Plp 2009 2\Plp Aula11
E:\Plp 2009 2\Plp Aula11E:\Plp 2009 2\Plp Aula11
E:\Plp 2009 2\Plp Aula11Ismar Silveira
 
Fundamentos de Sistemas de informacao - Aula #16
Fundamentos de Sistemas de informacao - Aula #16Fundamentos de Sistemas de informacao - Aula #16
Fundamentos de Sistemas de informacao - Aula #16Ismar Silveira
 
Um Sistema De Recomendacao para Web 2
Um Sistema De Recomendacao para Web 2Um Sistema De Recomendacao para Web 2
Um Sistema De Recomendacao para Web 2Ismar Silveira
 
Apresentação WAvalia - SBIE 2009
Apresentação WAvalia - SBIE 2009Apresentação WAvalia - SBIE 2009
Apresentação WAvalia - SBIE 2009Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #14 2009_2
Fundamentos de Sistemas de Informacao - Aula #14 2009_2Fundamentos de Sistemas de Informacao - Aula #14 2009_2
Fundamentos de Sistemas de Informacao - Aula #14 2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula 13
Fundamentos de Sistemas de Informacao - Aula 13Fundamentos de Sistemas de Informacao - Aula 13
Fundamentos de Sistemas de Informacao - Aula 13Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula 11 2009_2
Fundamentos de Sistemas de Informacao - Aula 11 2009_2Fundamentos de Sistemas de Informacao - Aula 11 2009_2
Fundamentos de Sistemas de Informacao - Aula 11 2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula 12 2009_2
Fundamentos de Sistemas de Informacao - Aula 12 2009_2Fundamentos de Sistemas de Informacao - Aula 12 2009_2
Fundamentos de Sistemas de Informacao - Aula 12 2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #10_2009_2
Fundamentos de Sistemas de Informacao - Aula #10_2009_2Fundamentos de Sistemas de Informacao - Aula #10_2009_2
Fundamentos de Sistemas de Informacao - Aula #10_2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Ismar Silveira
 
Fundamentos de Sistemas de Informacao - Aula #9_2009_2
Fundamentos de Sistemas de Informacao - Aula #9_2009_2Fundamentos de Sistemas de Informacao - Aula #9_2009_2
Fundamentos de Sistemas de Informacao - Aula #9_2009_2Ismar Silveira
 

Plus de Ismar Silveira (20)

REA - Recursos Educacionais Abertos
REA - Recursos Educacionais AbertosREA - Recursos Educacionais Abertos
REA - Recursos Educacionais Abertos
 
Charla juegos udelar2015_vfinal
Charla juegos udelar2015_vfinalCharla juegos udelar2015_vfinal
Charla juegos udelar2015_vfinal
 
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional Design
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional DesignInteraccion2014 - Presentation about Open Books, MOOCs and Instructional Design
Interaccion2014 - Presentation about Open Books, MOOCs and Instructional Design
 
#latinproject @openeducationweek2014 - Methodologies
#latinproject @openeducationweek2014 - Methodologies#latinproject @openeducationweek2014 - Methodologies
#latinproject @openeducationweek2014 - Methodologies
 
MOOC e Educação Aberta - Painel @ #cbie2013
MOOC e Educação Aberta - Painel @ #cbie2013MOOC e Educação Aberta - Painel @ #cbie2013
MOOC e Educação Aberta - Painel @ #cbie2013
 
Fundcompsis 1.1
Fundcompsis 1.1Fundcompsis 1.1
Fundcompsis 1.1
 
Ismar webinar-udelar
Ismar webinar-udelarIsmar webinar-udelar
Ismar webinar-udelar
 
wei2010
wei2010wei2010
wei2010
 
E:\Plp 2009 2\Plp Aula11
E:\Plp 2009 2\Plp Aula11E:\Plp 2009 2\Plp Aula11
E:\Plp 2009 2\Plp Aula11
 
Fundamentos de Sistemas de informacao - Aula #16
Fundamentos de Sistemas de informacao - Aula #16Fundamentos de Sistemas de informacao - Aula #16
Fundamentos de Sistemas de informacao - Aula #16
 
Um Sistema De Recomendacao para Web 2
Um Sistema De Recomendacao para Web 2Um Sistema De Recomendacao para Web 2
Um Sistema De Recomendacao para Web 2
 
Apresentação WAvalia - SBIE 2009
Apresentação WAvalia - SBIE 2009Apresentação WAvalia - SBIE 2009
Apresentação WAvalia - SBIE 2009
 
Fundamentos de Sistemas de Informacao - Aula #14 2009_2
Fundamentos de Sistemas de Informacao - Aula #14 2009_2Fundamentos de Sistemas de Informacao - Aula #14 2009_2
Fundamentos de Sistemas de Informacao - Aula #14 2009_2
 
Fundamentos de Sistemas de Informacao - Aula 13
Fundamentos de Sistemas de Informacao - Aula 13Fundamentos de Sistemas de Informacao - Aula 13
Fundamentos de Sistemas de Informacao - Aula 13
 
Fundamentos de Sistemas de Informacao - Aula 11 2009_2
Fundamentos de Sistemas de Informacao - Aula 11 2009_2Fundamentos de Sistemas de Informacao - Aula 11 2009_2
Fundamentos de Sistemas de Informacao - Aula 11 2009_2
 
Fundamentos de Sistemas de Informacao - Aula 12 2009_2
Fundamentos de Sistemas de Informacao - Aula 12 2009_2Fundamentos de Sistemas de Informacao - Aula 12 2009_2
Fundamentos de Sistemas de Informacao - Aula 12 2009_2
 
Fundamentos de Sistemas de Informacao - Aula #10_2009_2
Fundamentos de Sistemas de Informacao - Aula #10_2009_2Fundamentos de Sistemas de Informacao - Aula #10_2009_2
Fundamentos de Sistemas de Informacao - Aula #10_2009_2
 
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
 
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2Fundamentos de Sistemas de Informacao - Aula #8_2009_2
Fundamentos de Sistemas de Informacao - Aula #8_2009_2
 
Fundamentos de Sistemas de Informacao - Aula #9_2009_2
Fundamentos de Sistemas de Informacao - Aula #9_2009_2Fundamentos de Sistemas de Informacao - Aula #9_2009_2
Fundamentos de Sistemas de Informacao - Aula #9_2009_2
 

Dernier

ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 

Dernier (20)

Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 

Paradigmas de Linguagens de Programacao - Aula #4

  • 1. Paradigmas de Linguagens de Programação Paradigma Imperativo [Passagem de parâmetros] Aula #4 (CopyLeft)2009 - Ismar Frango ismar@mackenzie.br
  • 2. Passagem de parâmetros Valor – C, Java... Referência – FORTRAN, C++, Pascal... Resultado (out) – Ada, C# Valor-resultado /*Copy-restore*/ (inout) – Ada, C#. Read-only – C/C++ (const) Macro - C Nome – ALGOL ... “ I write the music, produce it and the band plays within the parameters that I set.” Sting
  • 3.
  • 4. Valor ou referência? int h, i; void B( int* w ) { int j, k; i = 2*(*w); *w = *w+1; } void A( int* x , int* y ) { float i, j; B( &h ); } int main() { int a, b; h = 5; a = 3; b = 2; A( &a , &b ); } int* &a
  • 5. Passagem por valor (C++) 2 1 void f(int *p) { *p = 5; p = NULL; } int main() { int x=2; int *q = &x; f(q); } x = 5 q != NULL
  • 6. Passagem por referência (C++) 2 2 void f(int A[]) { A[0] = 5; } int main() { int B[10]; B[0] = 2; f(B); cout << B[0] << endl;} 5
  • 7.
  • 8.
  • 9. Associação posicional vs. Nomeada (Ada) procedure POS_PARAM is procedure ADD_UP(X_VAL,Y_VAL,Z_VAL: INTEGER ) is begin PUT(X_VAL+Y_VAL+Z_VAL); NEW_LINE; end ADD_UP; begin end POS_PARAM ADD_UP(2,4,6); ADD_UP(X_VAL=>2, Y_VAL=>4, Z_VAL=>6); ADD_UP(Z_VAL=>6, X_VAL=>2, Y_VAL=>4); ADD_UP(2, Z_VAL=>6, Y_VAL=>4); PPA POSITIONAL PARAMETER ASSOCIATION NPA NAMED PARAMETER ASSOCIATION
  • 10. Passagem por valor x referência (Pascal) program P; var X, Y: Integer ; procedure Swap(A, B: Integer ); var Temp: begin Temp := A; A := B; B := Temp; end ; begin readln(X, Y); Swap(X, Y); writeln(X, Y) end . valor Novas variáveis no ARI de Swap PFs VL http://stwww.weizmann.ac.il/g-cs/benari/articles/varparm.pdf
  • 11. Passagem por valor x referência (Pascal) program P; var X, Y: Integer ; procedure Swap( var A, B: Integer ); var Temp: begin Temp := A; A := B; B := Temp; end ; begin readln(X, Y); Swap(X, Y); writeln(X, Y) end . ref aliases VL
  • 12. Passagem por valor (Java) public class Teste{ private static void aloca(String x) { x=&quot;Hello&quot;;} public static void main(String args[]) { String b=&quot;World&quot;; aloca(b); System.out.println(b); } } World
  • 13. Passagem por valor (Java) public class Teste{ private static String aloca(String x,String y) { x=x+y; return x;} public static void main(String args[]) { String a=&quot;Hello, &quot;; String b=&quot;World&quot;; String c = aloca(a,b); System.out.println(c==a); String d=&quot;World&quot;; String e=new String(&quot;World&quot;); System.out.println(b==d); System.out.println(b==e); String f=e.intern(); System.out.println(b==f); } } false true false true
  • 14. Passagem por valor (C#) void Foo (StringBuilder x) { x = null ; } ... StringBuilder y = new StringBuilder(); y.Append ( &quot;hello&quot; ); Foo (y); Console.WriteLine (y==null); false void Foo (StringBuilder x) { x.Append ( &quot; World&quot; ); } ... StringBuilder y = new StringBuilder(); y.Append ( “Hello&quot; ); Foo (y); Console.WriteLine (y); Hello World
  • 15. Passagem por valor (Java) String first = new String(“Hello”); String second = first; first += “World”; System.out.println(second); Hello void giveMeAString (Object y) { y = &quot;This is a string&quot;; } ... Object x = null; giveMeAString (x); System.out.println (x); null
  • 16. O que ocorre aqui? public class Teste2 { public static void foo (String x) { x+=&quot; World&quot;; } public static void main(String []a) { String y = new String(&quot;Hello&quot;); foo (y); System.out.println(y); } } Hello public class Teste3 { public static void foo (StringBuilder x) { x.append(&quot; World&quot;); } public static void main(String []a) { StringBuilder y = new StringBuilder(); y.append(&quot;Hello&quot;); foo (y); System.out.println(y); } } Hello World
  • 17. Passagem e Alocação Java vs. C vs. C# class Elefante { public int peso=1000; //:-( Thou shalt not do this! } public class Teste{ public static void main(String args[]) { Elefante dumbo = new Elefante(); dumbo.peso=2000; Elefante dumbinho = dumbo; dumbinho.peso=500; System.out.println(dumbo.peso); } } 500 Java
  • 18. Passagem e Alocação Java vs. C vs. C# #include <stdio.h> typedef struct { int peso; }Elefante; int main() { Elefante *dumbo = malloc (sizeof(Elefante)); dumbo->peso=2000; Elefante *dumbinho = dumbo; dumbinho->peso=500; printf(&quot;%d&quot;,dumbo->peso); return 0; } 500 C
  • 19. Passagem e Alocação Java vs. C vs. C# C #include <stdio.h> typedef struct { int peso; }Elefante; int main() { Elefante dumbo; dumbo.peso=2000; Elefante dumbinho = dumbo; dumbinho.peso=500; printf(&quot;%d&quot;,dumbo.peso); return 0; } 2000
  • 20. Java vs. C vs. C# using System; public struct Elefante { public int peso; } public class testecs { public static void Main(string []a) { Elefante dumbo = new Elefante(); dumbo.peso=2000; Elefante dumbinho = dumbo; dumbinho.peso=500; Console.WriteLine (dumbo.peso); } } 2000 C#
  • 21. Java vs. C vs. C# using System; public class Elefante { public int peso; } public class testecs { public static void Main(string []a) { Elefante dumbo = new Elefante(); dumbo.peso=2000; Elefante dumbinho = dumbo; dumbinho.peso=500; Console.WriteLine (dumbo.peso); } } 500 C#
  • 22. Passagem por referência (C#) void Foo ( ref StringBuilder x) { x = null ; } ... StringBuilder y = new StringBuilder(); y.Append ( &quot;hello&quot; ); Foo ( ref y); Console.WriteLine (y== null ); using System; using System.Text; public class testecsref { public static void Foo1 ( ref Elefante x) { x.peso=1000 ;} public static void Foo2 (Elefante x) { x.peso=0 ;} public static void Main(string []a) { Elefante dumbo=new Elefante(); Foo1 ( ref dumbo); Console.WriteLine (dumbo.peso); Foo2 (dumbo); Console.WriteLine (dumbo.peso); } } public class Elefante { public int peso; } public struct Elefante { public int peso; } 1000 0 1000 1000 Qual a diferença entre passar um value object por referência e um reference object por valor? true
  • 23. Value objects x reference objects (C#) void Foo ( ref IntHolder x) { x.i=10; } ... IntHolder y = new IntHolder(); y.i=5; Foo ( ref y); Console.WriteLine (y.i); 10 public struct IntHolder { public int i; } Value object + passagem por referência void Foo (IntHolder x) { x.i=10; } ... IntHolder y = new IntHolder(); y.i=5; Foo (y); Console.WriteLine (y.i); 5 public class IntHolder { public int i; } Reference object + passagem por valor
  • 24. Parâmetros out (C#) void Foo ( out int x) { int a = x; // Can't read x here - it's considered unassigned // Assignment - this must happen before the method can complete normally x = 10; // The value of x can now be read: int a = x; } ... // Declare a variable but don't assign a value to it int y; // Pass it in as an output parameter, even though its value is unassigned Foo ( out y); // It's now assigned a value, so we can write it out: Console.WriteLine (y);
  • 25. Parâmetros in, out, in out (Ada) procedure Quadratic( A, B, C: in Float; Root1, Root2: out Float); procedure Sort(V: in out Vector); with CS_IO; use CS_IO; procedure OUT_MODE_EXAMPLE is VALUE_1, VALUE_2: float; MEAN: float; procedure MEAN_VALUE (NUM_1, NUM_2: in float; NUM_3: out float) is begin NUM_3:= (NUM_1+NUM_2)/2.0; end MEAN_VALUE; begin MEAN_VALUE(VALUE_1, VALUE_2, MEAN); put(&quot;The mean is &quot;); put(MEAN);new_line; new_line; end OUT_MODE_EXAMPLE;
  • 26. Parâmetros in, out, in out (Ada) with CS_IO; use CS_IO; procedure IN_OUT_MODE_EXAMPLE is VALUE_1, VALUE_2: float; procedure MEAN_VALUE (NUM_1: in out float; NUM_2: in float) is begin NUM_1:= (NUM_1+NUM_2)/2.0; end MEAN_VALUE; begin get(VALUE_1);get(VALUE_2); put(&quot;BEFORE MEAN VALUE: VALUE_1 = &quot;); put(VALUE_1);put(&quot;, VALUE_2 = &quot;);put(VALUE_2);new_line; MEAN_VALUE(VALUE_1, VALUE_2); put(&quot;The mean is &quot;); put(VALUE_1);new_line; put(&quot;AFTER MEAN VALUE: VALUE_1 = &quot;); put(VALUE_1);put(&quot;, VALUE_2 = &quot;);put(VALUE_2);new_line; end IN_OUT_MODE_EXAMPLE;
  • 27. Parameter arrays –”params” (C#), ... (Java) void ShowNumbers ( params int [] numbers) { foreach ( int x in numbers) { Console.Write (x+ &quot; &quot; ); } Console.WriteLine(); } ... int [] x = {1, 2, 3}; ShowNumbers (x); ShowNumbers (4, 5); static int sum (int ... numbers) { int total = 0; for (int i = 0; i < numbers.length; i++) total += numbers [i]; return total; } C# Java
  • 28. Parâmetros variáveis (C++) void myprintf( char *format, ... ){ va_list vl; int i; va_start ( vl, args ); for( i = 0; args[i] != ''; ++i ){ union any_t { int i; float f; char c; } any; if( args[i]=='i' ){ any.i = va_arg( vl, int ); printf( &quot;%i&quot;, any.i ); } else if( args[i]=='f' ){ any.f = va_arg( vl, float ); printf( &quot;%f&quot;, any.f ); }else if( args[i]=='c' ){ any.c = va_arg( vl, char ); printf( &quot;%c&quot;, any.c ); } else{ throw SomeException; } va_end( vl ); }
  • 29. Parâmetros default (Ada, C++) with CS_IO; use CS_IO; procedure EXAMPLE is N1: float:= 4.2; N2: float:= 9.6; procedure MEAN_VALUE (X1: in out float; X2: in float := 6.4 ) is begin X1:= (X1+X2)/2.0; end MEAN_VALUE begin MEAN_VALUE(N1); put(N1); new_line; MEAN_VALUE(N1, N2); put(N1); new_line; end EXAMPLE; #include <iostream> using namespace std; int a = 1; int f(int a) { return a; } int g(int x = f(a)) { return x; } int h() { a = 2; { int a = 3; return g(); } } int main() { cout << h() << endl; } 2 O que é impresso aqui?
  • 30. Parâmetros read-only (C++) class IntList { public: const Print (ostream &o); }; void f(const IntList &L) { L.Print(cout); } bool Compare(const vector <int> & A) // precondition: A is sorted { int k; for (k=1; k<A.size(); k++) { if (A[k-1] == A[k]) return true; } return false; } E se aqui não fosse const?
  • 31. Macros #define MAXLINE 100 char line[MAXLINE]; ... getline(line, MAXLINE); #define A 2 #define B 3 #define C A + B int x = C * 2; O que acontece aqui? Por que não tem ponto-e-vírgula?
  • 32. Pass-by-name (ALGOL) procedure double(x); real x; begin x := x * 2 end; double(C[j]) C[j] := C[j] * 2. real procedure Sum(j, lo, hi, Ej); value lo, hi; integer j, lo, hi; real Ej; begin real S; S := 0; for j := lo step 1 until hi do S := S + Ej; Sum := S end; Sum(i, 1, n, x[i]*i) Como simular isso em C++ ou Java?
  • 33. Pass-by-name (ALGOL) procedure swap (a, b); integer a, b, temp; begin temp := a; a := b; b:= temp end; swap(x, y) temp := x; x := y; y := temp swap(i, x[i]) temp := i; i := x[i]; x[i] := temp Antes i = 2 x[2] = 5 Depois i = 5 x[2] = 5 x[5] = 2
  • 35. /* I f *y is zero and x > 0 : set *k to biggest integer. * If *y is zero and x <=0 : leave *k unchanged. * If *y is not zero : * set *k to be x divided by *y and increment *y by 1. */ #define INT_MAX 1000 void check_divide ( int *k, int x, int *y) { if (*y = 0) if (x > 0) *k = INT_MAX; else *k = x / * y / * *y cannot be 0 */ ; *y++; } int main( ) { int a=2; check_divide(&a, a, &a); cout<<a; } 0 C++
  • 36. /* I f *y is zero and x > 0 : set *k to biggest integer. * If *y is zero and x <=0 : leave *k unchanged. * If *y is not zero : * set *k to be x divided by *y and increment *y by 1. */ #define INT_MAX 1000 void check_divide ( int *k, int x, int *y) { if (*y == 0) { if (x > 0) *k = INT_MAX; } else { *k = x / * y / * *y cannot be 0 */ ; (*y)++;} } int main( ) { int a=2; check_divide(&a, a, &a); cout<<a; } 3 C++
  • 37. #define TAM 10 void change ( int v[ ], int &ntx) { for (;ntx>0;ntx--) v[ntx]=ntx---1; } int main() { int k[TAM],i=0,; for (;;) { if (i==TAM) break ; k[i++]= i*2;} change(k,i); for (;;) { if (i>TAM) break ; cout<<k[i++]<<endl;} } 0 2 1 6 3 10 5 14 7 18 9 C++
  • 38. using namespace System; double average( ... array<Int32>^ arr ) { int i = arr->GetLength(0); double answer = 0.0; for (int j = 0 ; j < i ; j++) answer += arr[j]; return answer / i; } int main() { Console::WriteLine(&quot;{0}&quot;, average( 1, 2, 3, 6 )); } Visual C++ (.NET) 3
  • 39. void g ( int &a) { a++; } void h ( int &a) { a*=2; } void k ( int &a) { a*=10; } void f( int &number, void (*function)( int &) ) { (*function )( number ); } int main() { int select, count=0; for (select = 1; select<=3 ;select++) { switch ( select ) { case 1: f( count, g ); break ; case 2: f( count, h ); break ; case 3: f( count, k ); default: break; } } cout << count; } 20 C++
  • 40. Pascal procedure swap(arg1, arg2: integer); var temp : integer; begin temp := arg1; arg1 := arg2; arg2 := temp; end ; ... { in some other procedure/function/program } var var1, var2 : integer; begin var1 := 1; var2 := 2; swap(var1, var2); end ; Var1=1 Var2=2
  • 41. public class TestY { public static void differentArray(float[] x) { x = new float[100]; x[0] = 26.9f; } public static void main(String a[]) { float[ ] xx = new float[100]; xx[0] = 55.8f; differentArray(xx); System.out.println(&quot;xx[0] = &quot; + xx[0]); } } Java 55.8
  • 42. procedure sub1(x: int; y: int); begin x := 1; y := 2; x := 2; y := 3; end; sub1(i, a[i]); Algol a={2,3}