Quiz on Functions in C++
Functions are sets of statements that take inputs, perform a specific calculation, and produce outputs. During the upcoming quiz we will test your understanding of the C++ Functions. Good Luck!
0 of 15 Questions completed Questions: You have already completed the quiz before. Hence you can not start it again. Quiz is loading… You must sign in or sign up to start the quiz. You must first complete the following: 0 of 15 Questions answered correctly Your time: Time has elapsed You have reached 0 of 0 point(s), (0) Earned Point(s): 0 of 0, (0) #include <iostream> using namespace std; int main() { int i = 6; cout<<i++<< ” “<<++i<<” “<<i++; return 0; } #include <iostream> using namespace std; int fun(int n) { for(;n > 0; n–) cout<<“QuizOrbit”<<” “; return 0; } int main() { int ptr=fun(2); return 0; } #include<iostream> using namespace std; void dFunction(int p, …) { cout<<p<<” “; } int main() { dFunction(1, 3, 5, 7); dFunction(3, 6, 12); return 0; } #include<iostream> using namespace std; void (*fun)(); void display(); int main() { fun = display; (*fun)(); return 0; } void display() { cout<<“QuizOrbit “; } #include <iostream> using namespace std; void function(int *ptr) { *ptr = 40; } int main() { int x = 30; function(&x); cout << x; return 0; } #include<bits/stdc++.h> using namespace std; int main() { float var= 54.154365; cout << setprecision(6) << var; return 0; } #include <iostream> using namespace std; void find(); void find() { static int i=1; cout<<i<<” “; i++; } int main() { find(); find(); find(); return 0; } #include <iostream> using namespace std; void fun(int p, int *q) { p = 20; *q = 30; } int main() { int p = 10; fun(p, &p); cout << p; return 0; } #include <iostream> using namespace std; void sqNumber(int *x) { *x=*x * *x +(*x+1); } int main ( ) { int x = 6; sqNumber(&x); cout << x; return 0; } #include <iostream> using namespace std; inline int maximum(int a, int b ) { return ( a > b ? a : b ); } int main() { int x = 30; int y = 40; cout << maximum(x, y ); return 0; } #include <iostream> using namespace std; int gCD(int a, int b) { int tempvar=0; while (b != 0) { tempvar = a% b; a = b; b = tempvar; } return(a); } int main () { int a=9, b = 12; cout << gCD(a, b); return(0); } #include<bits/stdc++.h> using namespace std; int mul(int a, int b) { return (a * b); } float mul(float a, float b) { return (a / b); } int main() { int x = 10, y = 2; float n = 13.2345, m = 2.0; cout << mul(x, y) <<” “; cout <<setprecision(3)<< mul(n, m); return 0; } #include <iostream> using namespace std; class Rect { private: int length; int breadth; public: Rect(int l, int b) { length=l; breadth=b; } void showdata(); }; void Rect::showdata() { cout<<length++; cout<<” “<<++breadth; } int main() { Rect r(5,6); r.showdata(); return 0; } Quiz Summary
Information
Results
Results
0 Essay(s) Pending (Possible Point(s): 0) Categories
1. Question
2. Question
3. Question
4. Question
5. Question
6. Question
7. Question
8. Question
9. Question
10. Question
11. Question
12. Question
13. Question
14. Question
15. Question
Summary
An important tool of any programmer is a function. Enhancing code quality and promoting code reuse are two of its benefits. Hopefully, you gained a better understanding of your knowledge of functions from the quiz. Programmers won’t move forward until they understand the topic fully.
I wish you a happy learning experience!