SlideShare ist ein Scribd-Unternehmen logo
1 von 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}

Weitere Àhnliche Inhalte

Was ist angesagt?

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
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 featuresBartlomiej Filipek
 
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
 
verilog code
verilog codeverilog code
verilog codeMantra VLSI
 
8 arrays and pointers
8  arrays and pointers8  arrays and pointers
8 arrays and pointersMomenMostafa
 
C++ references
C++ referencesC++ references
C++ referencescorehard_by
 
ĐĐœŃ‚ĐžŃ…Ń€ŃƒĐżĐșĐžĐč 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
 
C++ Presentation
C++ PresentationC++ Presentation
C++ PresentationCarson Wilber
 

Was ist angesagt? (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
 

Andere mochten auch

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
 
E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 9E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 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
 

Andere mochten auch (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
 

Ähnlich wie Paradigmas de Linguagens de Programacao - Aula #4

Function recap
Function recapFunction recap
Function recapalish sha
 
Function recap
Function recapFunction recap
Function recapalish sha
 
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 operatorJussi Pohjolainen
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxssuser3cbb4c
 
C++ Language
C++ LanguageC++ Language
C++ LanguageVidyacenter
 
EcmaScript unchained
EcmaScript unchainedEcmaScript unchained
EcmaScript unchainedEduard TomĂ s
 
Scala 2 + 2 > 4
Scala 2 + 2 > 4Scala 2 + 2 > 4
Scala 2 + 2 > 4Emil Vladev
 
46630497 fun-pointer-1
46630497 fun-pointer-146630497 fun-pointer-1
46630497 fun-pointer-1AmIt Prasad
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programmingPrabhu Govind
 
java compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxjava compilerCompiler1.javajava compilerCompiler1.javaimport.docx
java compilerCompiler1.javajava compilerCompiler1.javaimport.docxpriestmanmable
 
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.docxamrit47
 
Operators
OperatorsOperators
OperatorsDaman Toor
 

Ähnlich wie 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++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
 
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
 

Mehr von 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
 
Ismar webinar-udelar
Ismar webinar-udelarIsmar webinar-udelar
Ismar webinar-udelarIsmar 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
 

Mehr von 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
 

KĂŒrzlich hochgeladen

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxdhanalakshmis0310
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
TỔNG ÔN TáșŹP THI VÀO LỚP 10 MÔN TIáșŸNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGở Â...
TỔNG ÔN TáșŹP THI VÀO LỚP 10 MÔN TIáșŸNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGở Â...TỔNG ÔN TáșŹP THI VÀO LỚP 10 MÔN TIáșŸNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGở Â...
TỔNG ÔN TáșŹP THI VÀO LỚP 10 MÔN TIáșŸNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGở Â...Nguyen Thanh Tu Collection
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 

KĂŒrzlich hochgeladen (20)

SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
TỔNG ÔN TáșŹP THI VÀO LỚP 10 MÔN TIáșŸNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGở Â...
TỔNG ÔN TáșŹP THI VÀO LỚP 10 MÔN TIáșŸNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGở Â...TỔNG ÔN TáșŹP THI VÀO LỚP 10 MÔN TIáșŸNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGở Â...
TỔNG ÔN TáșŹP THI VÀO LỚP 10 MÔN TIáșŸNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGở Â...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

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}