

Mecanisme de transmitere a parametrilor
Presentation
•
Computers
•
10th - 11th Grade
•
Medium
Marilena Vilciu
Used 5+ times
FREE Resource
6 Slides • 14 Questions
1
Mecanisme de transmitere a parametrilor funcțiilor C++
Valoare și referință

2
3
Parametrii actuali la transmiterea prin valoare
expresii ex: dubleaza(b+1)
variabile ex: dubleaza(a)
constante ex: dubleaza(5)
4
Multiple Select
int f (int x){
x++;
return x;
}
Cum pot apela funcția?
f(10);
cout<<f(10);
f(a);
f(b+5)
cout<<f(c);
5
Multiple Select
void f (int x){
x++;
}
Cum pot apela funcția?
f(10);
cout<<f(10);
f(a);
f(b+5)
cout<<f(5);
6
Parametrii actuali la transmiterea prin referință
Practic, funcția crează un alias al parametrului actual transmis prin referință, deci trebuie să fie stocat undeva, să aibă o adresă.
Doar variabile pot fi parametri referință
ex: dubleaza(a), nu dubleaza(b+1) sau dubleaza(10)
7
8
Multiple Select
int f (int &x){
x++;
return x;
}
Cum pot apela funcția?
f(10);
cout<<f(10);
f(a);
f(b+5)
cout<<f(c);
9
Multiple Choice
void f (int x){
x++;
}
Rulez codul
x=6; f(x);
cout<<x;
Ce se va afișa?
6
7
x
10
Multiple Choice
void f (int &x){
x++;
}
Rulez codul
x=6; f(x);
cout<<x;
Ce se va afișa?
6
7
x
11
Multiple Choice
void f (int x, int &y){
x++; y++;
}
Rulez codul
x=y=6; f(x,y);
cout<<x<<' '<<y;
Ce se va afișa?
6 7
7 7
6 6
7 6
12
Multiple Choice
void f (int &x, int &y){
x++; y++;
}
Rulez codul
x=y=6; f(x,y);
cout<<x<<' '<<y;
Ce se va afișa?
6 7
7 7
6 6
7 6
13
Multiple Choice
void f (int x, int y){
x++; y++;
}
Rulez codul
x=y=6; f(x,y);
cout<<x<<' '<<y;
Ce se va afișa?
6 7
7 7
6 6
7 6
14
Multiple Choice
void f (int &x, int y){
x++; y++;
}
Rulez codul
x=y=6; f(x,y);
cout<<x<<' '<<y;
Ce se va afișa?
6 7
7 7
6 6
7 6
15
Multiple Choice
int f(int a){
a=a%10;
return a;
}
Dacă a=2021, ce va afișa secvența
cout<<f(a)<<' '; cout<<a;
1 1
1 2021
202 202
202 2021
16
Multiple Choice
___________{
a=a%10;
}
Ce antet ar putea avea funcția pentru ca în a să rămână doar ultima sa cifră?
void f(int a)
int f(int a)
void f(int &a)
17
Multiple Choice
___________{
int aux;
aux=a;
a=b;
b=aux;
}
Ce antet ar putea avea funcția pentru a interschimba a și b?
void f(int a, int b)
void f(int &a, int b)
void f(int a, int &b)
void f(int &a, int &b)
18
Multiple Choice
___________{
while (a>9) a=a/10;
}
Ce antet ar putea avea funcția pentru ca în a (pozitiv) să rămână doar prima sa cifră?
void f(int a)
int f(int a)
int f(int &a)
void f(int &a)
19
Multiple Choice
___________{
while (a>9) a=a/10;
return a;
}
Ce antet ar putea avea funcția pentru a returna doar prima cifră a lui a (pozitiv), fără a modifica a?
void f(int a)
int f(int a)
int f(int &a)
void f(int &a)
20
Mecanisme de transmitere a parametrilor funcțiilor C++
Valoare și referință

Show answer
Auto Play
Slide 1 / 20
SLIDE
Similar Resources on Wayground
13 questions
Polynomial Multiplication
Presentation
•
10th Grade
13 questions
Geo 2.1b - Parallel Lines Cut by a Transversal
Presentation
•
10th Grade
17 questions
Genetics Review Part 2 (Practice)
Presentation
•
6th - 9th Grade
15 questions
Snake Python
Presentation
•
KG
15 questions
Basic Rational Functions
Presentation
•
10th - 12th Grade
16 questions
Operations with Polynomials
Presentation
•
11th Grade
17 questions
Pola Penalaran
Presentation
•
10th Grade
13 questions
Systems of Inequalities
Presentation
•
9th - 11th Grade
Popular Resources on Wayground
20 questions
"What is the question asking??" Grades 3-5
Quiz
•
1st - 5th Grade
20 questions
“What is the question asking??” Grades 6-8
Quiz
•
6th - 8th Grade
10 questions
Fire Safety Quiz
Quiz
•
12th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
34 questions
STAAR Review 6th - 8th grade Reading Part 1
Quiz
•
6th - 8th Grade
20 questions
“What is the question asking??” English I-II
Quiz
•
9th - 12th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
47 questions
8th Grade Reading STAAR Ultimate Review!
Quiz
•
8th Grade
Discover more resources for Computers
20 questions
“What is the question asking??” English I-II
Quiz
•
9th - 12th Grade
10 questions
Fire Prevention
Quiz
•
9th - 12th Grade
50 questions
STAAR English 2 Review
Quiz
•
10th Grade
20 questions
Figurative Language Review
Quiz
•
10th Grade
41 questions
US History STAAR Review
Quiz
•
11th Grade
20 questions
Grammar
Quiz
•
9th - 12th Grade
16 questions
AP Biology: Unit 1 Review (CED)
Quiz
•
9th - 12th Grade
20 questions
verbos reflexivos en español
Quiz
•
9th - 12th Grade