Check if string is a palindrome using a function. #1395 #include #include using namespace std; bool IsPalindrome(char* str) { int len=strlen(str); for(int i=0;i Check if a character array or c-style string is same (Palindrome) when reversed using an independent function.
Call by reference demonstration #2647 #include using namespace std; void addsomething(int &); int something=5; int main() { int a=10; cout<<"Before function call: a = "< Function Call by Reference and Call by Value comparison #2680 #include using namespace std; void increment(int &); int increase_and_return(int); int main() { int a=10; cout<<"Before referenced function call: a = "< Variable swapping using function call by reference #2685 #include using namespace std; void swap(int &,int &); int main () { int a=10,b=13; cout <<"The original values are : "; cout <<" a = "< Global and Local Function Declaration #2689 #include using namespace std; int action1(int,int); int main() { int action2(int,int); int a=10,b=15; cout< Understanding global and local function declaration using a function declaration above main and another inside the main routine. Passing null terminated string to function using array notation #2701 //using array notation #include #include using namespace std; int space_count(char []); int main() { char str[80]; int spaces=0; cout<<"Input a small sentence: " ; cin.getline(str,80); spaces=space_count(str); cout<<"Number of spaces in given input = " < Program to pass by reference character array as a null terminated string to a function using the array notation using [ ]. Passing null terminated string to function using pointer notation #2706 //using array notation #include #include using namespace std; int space_count(char *); int main() { char str[80]; int spaces=0; cout<<"Input a small sentence: " ; cin.getline(str,80); spaces=space_count(str); cout<<"Number of spaces in given input = " < Program to pass by reference character array as a null terminated string to a function using the pointer notation using *. Passing integer array to a function for linear search #2733 #include using namespace std; int pos_in_arr(int [],int,int); int main() { int arr[]={19,20,34,55,99,102,12}; int len=sizeof(arr)/sizeof(arr[0]); int n; cout<<"Find position of which number? " ; cin>>n; int pos=pos_in_arr(arr,len,n); if(pos>0) cout<<"Position of given input = "< Program to pass an integer array, length of array and the member to be found to a function and return the position of the member found. Changing multiple values of integer array passed to a function #2737 #include using namespace std; int even2odd(int [],int); int disp_arr(int [],int); int main() { int arr[]={19,20,34,55,99,102,12}; int len=sizeof(arr)/sizeof(arr[0]); cout<<"-- Array members before change -- "< A program to pass integer array to a function and change many values in it based on a condition. Then reading such values in the calling function. Function returning by reference #2749 #include using namespace std; int& setg(); int g=10; int main() { cout<<"Global var g before change = "< Using function return by reference to modify a global array #2754 #include using namespace std; int& modifyga(int); int ga[]={10,20,30,40,50}; int main() { for(int i=0;i<5;++i) modifyga(i)=ga[i]+1; for(int i=0;i<5;++i) cout< A program that neatly modifies a global array by using the function return by reference technique. Solved Problems About Solved ProblemsXSolved problems are a specially designed set of problems which are usually based on some concept learning code sheets and they do enrich your learning of concepts along. They also provide you confidence to solve real life problems. Solutions to these problems are visible on user's request with press of a button. output writing, pass by ref/pass by value #2652 Write the output of the following code piece. Write the output of the following code piece. ... Char array passing to function #2656 Write a function alpha_count() where a character array is passed as reference and the length of array is passed as value. The output of function should be number of alphabets in the input array. You can use function isalpha() if you wish so. Write a function alpha_count() where a character array is passed as reference and the len ... Output writing – passing string as char pointer #2659 Write output of the following code. Write output of the following code. ... Array to array data #2697 Write output of the following code and explain its working. Write output of the following code and explain its working. ... Output writing function within function with array passing #2746 Dry run the following program carefully and write the output. Dry run the following program carefully and write the output. ... Correcting error in function call by reference #2742 Program given below has some incorrectly written function call, correct the mistake and rewrite the program. Program given below has some incorrectly written function call, correct the mistake and re ... Setting bigger of two values using function returning reference #2757 Write a c++ program using function returning the reference which finds the bigger of two variables passed it and then it sets the bigger variable to 10 while it is called. Show its implementation by writing the main routine also. Write a c++ program using function returning the reference which finds the bigger of two ... First and last digit of an integer in a function and putting at reference location #3018 Write a c++ program using a function with the following prototype – void first_last_digit(int n,int first,int last); In this function pass an integer number as n and then find the first and last digit of n. Then update it on locations first and last passed as reference. Assume values to be passed to demonstrate the working of this function in the main routine. Write a c++ program using a function with the following prototype - void first_l ... Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ... Output Writing – Function Returning reference #5265 Write output of the following code. Assume inclusion of related header files. int &min(int &a, int &b) { if (a<b) return a; else return b; } int main() { int x=2,y=3; min(x,y)=10; cout<<"x-y = "<<(x-y)<<endl; cout<<"y-x = "<<(y-x)<<endl; return 0; } Write output of the following code. Assume inclusion of related header files. int &a ... Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ... Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ... Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ... Output Writing – passing integers as ref and as def value #7699 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void series(int x=10) { for(int i=2;i<=x;i+=2) cout<<i<<" "; cout<<endl; } void modify(int &n) { n*=2; series(n); } int main() { int a=10; cout<<"a="<<a<<endl; modify(a); series(); cout<<"new a="<<a<<endl; return 0; } Write the output of the following C++ program code: Note: Assume all required header file ... Exam Questions About Exam QuestionsXExam Questions are individual questions picked from a real past exam paper that may have appeared in some board/other examinations. Here question and solution will be shown CBSE12A-2018-01D Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ... CBSE12D-2015-01D Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ... CBSE12A-2015-01D Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ... CBSE12A-2019-A01D Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ... Code Sheets:11 Solved Problems:14 Exam Questions:4 Topic Lists Introductory Sessions Beginning to Program Tokens Keyword and Identifiers Data Types Variables and Constants Operators Simple User Input Building Expressions and Formulas Simple Real World Problems Simple If and If Else Multiple-Nested-Ladder of If Else Switch case selection Simple Loops Tricks in Loops - break continue scope Loop Applications - Handling numerals Series printing loops Nested Loops Pattern printing loops Number Varieties and Crunches String Handling (Null Terminated) Strings - string class type Functions (Built-in) Functions - user defined Functions Reference Passing/Returning Arrays Concepts and 1-D Arrays Array Data Management Two dimensional arrays and Matrices Structures Basics Structures passing/returning 2D Array Memory Addressing Display Using IO Manipulation Display Using C Formatting Tricks User Defined Data Types Enumerated Types Preprocessor Directives And Macros Exception Handling Programming Paradigms and OOPs Advantages Abstraction and Encapsulation Polymorphism Inheritance Function Overloading Concepts Function Overloading Varieties Function Overloading Special Cases Defining Classes Creating and Using Class Objects Class Members Accessibility Class Function Types Inline Functions Constant Functions Nesting of Functions Class Members Scope Resolution Static Members in a Class Array of Objects Constructor Concepts Default Constructor Parameterized Constructor Copy Constructor Constructor Overloading Destructors Inheritance Fundamentals Public Derivations Private and Protected Derivations Multiple Inheritance Multi-Level Inheritance Class Nesting Data File Concepts Handling Text Files Handling Binary Files Pointer Concepts Pointer and Arrays Pointers and Functions Object Pointers This Pointer Linked Lists Stacks Queues Back ×
Function Call by Reference and Call by Value comparison #2680 #include using namespace std; void increment(int &); int increase_and_return(int); int main() { int a=10; cout<<"Before referenced function call: a = "< Variable swapping using function call by reference #2685 #include using namespace std; void swap(int &,int &); int main () { int a=10,b=13; cout <<"The original values are : "; cout <<" a = "< Global and Local Function Declaration #2689 #include using namespace std; int action1(int,int); int main() { int action2(int,int); int a=10,b=15; cout< Understanding global and local function declaration using a function declaration above main and another inside the main routine. Passing null terminated string to function using array notation #2701 //using array notation #include #include using namespace std; int space_count(char []); int main() { char str[80]; int spaces=0; cout<<"Input a small sentence: " ; cin.getline(str,80); spaces=space_count(str); cout<<"Number of spaces in given input = " < Program to pass by reference character array as a null terminated string to a function using the array notation using [ ]. Passing null terminated string to function using pointer notation #2706 //using array notation #include #include using namespace std; int space_count(char *); int main() { char str[80]; int spaces=0; cout<<"Input a small sentence: " ; cin.getline(str,80); spaces=space_count(str); cout<<"Number of spaces in given input = " < Program to pass by reference character array as a null terminated string to a function using the pointer notation using *. Passing integer array to a function for linear search #2733 #include using namespace std; int pos_in_arr(int [],int,int); int main() { int arr[]={19,20,34,55,99,102,12}; int len=sizeof(arr)/sizeof(arr[0]); int n; cout<<"Find position of which number? " ; cin>>n; int pos=pos_in_arr(arr,len,n); if(pos>0) cout<<"Position of given input = "< Program to pass an integer array, length of array and the member to be found to a function and return the position of the member found. Changing multiple values of integer array passed to a function #2737 #include using namespace std; int even2odd(int [],int); int disp_arr(int [],int); int main() { int arr[]={19,20,34,55,99,102,12}; int len=sizeof(arr)/sizeof(arr[0]); cout<<"-- Array members before change -- "< A program to pass integer array to a function and change many values in it based on a condition. Then reading such values in the calling function. Function returning by reference #2749 #include using namespace std; int& setg(); int g=10; int main() { cout<<"Global var g before change = "< Using function return by reference to modify a global array #2754 #include using namespace std; int& modifyga(int); int ga[]={10,20,30,40,50}; int main() { for(int i=0;i<5;++i) modifyga(i)=ga[i]+1; for(int i=0;i<5;++i) cout< A program that neatly modifies a global array by using the function return by reference technique. Solved Problems About Solved ProblemsXSolved problems are a specially designed set of problems which are usually based on some concept learning code sheets and they do enrich your learning of concepts along. They also provide you confidence to solve real life problems. Solutions to these problems are visible on user's request with press of a button. output writing, pass by ref/pass by value #2652 Write the output of the following code piece. Write the output of the following code piece. ... Char array passing to function #2656 Write a function alpha_count() where a character array is passed as reference and the length of array is passed as value. The output of function should be number of alphabets in the input array. You can use function isalpha() if you wish so. Write a function alpha_count() where a character array is passed as reference and the len ... Output writing – passing string as char pointer #2659 Write output of the following code. Write output of the following code. ... Array to array data #2697 Write output of the following code and explain its working. Write output of the following code and explain its working. ... Output writing function within function with array passing #2746 Dry run the following program carefully and write the output. Dry run the following program carefully and write the output. ... Correcting error in function call by reference #2742 Program given below has some incorrectly written function call, correct the mistake and rewrite the program. Program given below has some incorrectly written function call, correct the mistake and re ... Setting bigger of two values using function returning reference #2757 Write a c++ program using function returning the reference which finds the bigger of two variables passed it and then it sets the bigger variable to 10 while it is called. Show its implementation by writing the main routine also. Write a c++ program using function returning the reference which finds the bigger of two ... First and last digit of an integer in a function and putting at reference location #3018 Write a c++ program using a function with the following prototype – void first_last_digit(int n,int first,int last); In this function pass an integer number as n and then find the first and last digit of n. Then update it on locations first and last passed as reference. Assume values to be passed to demonstrate the working of this function in the main routine. Write a c++ program using a function with the following prototype - void first_l ... Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ... Output Writing – Function Returning reference #5265 Write output of the following code. Assume inclusion of related header files. int &min(int &a, int &b) { if (a<b) return a; else return b; } int main() { int x=2,y=3; min(x,y)=10; cout<<"x-y = "<<(x-y)<<endl; cout<<"y-x = "<<(y-x)<<endl; return 0; } Write output of the following code. Assume inclusion of related header files. int &a ... Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ... Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ... Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ... Output Writing – passing integers as ref and as def value #7699 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void series(int x=10) { for(int i=2;i<=x;i+=2) cout<<i<<" "; cout<<endl; } void modify(int &n) { n*=2; series(n); } int main() { int a=10; cout<<"a="<<a<<endl; modify(a); series(); cout<<"new a="<<a<<endl; return 0; } Write the output of the following C++ program code: Note: Assume all required header file ... Exam Questions About Exam QuestionsXExam Questions are individual questions picked from a real past exam paper that may have appeared in some board/other examinations. Here question and solution will be shown CBSE12A-2018-01D Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ... CBSE12D-2015-01D Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ... CBSE12A-2015-01D Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ... CBSE12A-2019-A01D Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ... Code Sheets:11 Solved Problems:14 Exam Questions:4 Topic Lists Introductory Sessions Beginning to Program Tokens Keyword and Identifiers Data Types Variables and Constants Operators Simple User Input Building Expressions and Formulas Simple Real World Problems Simple If and If Else Multiple-Nested-Ladder of If Else Switch case selection Simple Loops Tricks in Loops - break continue scope Loop Applications - Handling numerals Series printing loops Nested Loops Pattern printing loops Number Varieties and Crunches String Handling (Null Terminated) Strings - string class type Functions (Built-in) Functions - user defined Functions Reference Passing/Returning Arrays Concepts and 1-D Arrays Array Data Management Two dimensional arrays and Matrices Structures Basics Structures passing/returning 2D Array Memory Addressing Display Using IO Manipulation Display Using C Formatting Tricks User Defined Data Types Enumerated Types Preprocessor Directives And Macros Exception Handling Programming Paradigms and OOPs Advantages Abstraction and Encapsulation Polymorphism Inheritance Function Overloading Concepts Function Overloading Varieties Function Overloading Special Cases Defining Classes Creating and Using Class Objects Class Members Accessibility Class Function Types Inline Functions Constant Functions Nesting of Functions Class Members Scope Resolution Static Members in a Class Array of Objects Constructor Concepts Default Constructor Parameterized Constructor Copy Constructor Constructor Overloading Destructors Inheritance Fundamentals Public Derivations Private and Protected Derivations Multiple Inheritance Multi-Level Inheritance Class Nesting Data File Concepts Handling Text Files Handling Binary Files Pointer Concepts Pointer and Arrays Pointers and Functions Object Pointers This Pointer Linked Lists Stacks Queues Back ×
Variable swapping using function call by reference #2685 #include using namespace std; void swap(int &,int &); int main () { int a=10,b=13; cout <<"The original values are : "; cout <<" a = "< Global and Local Function Declaration #2689 #include using namespace std; int action1(int,int); int main() { int action2(int,int); int a=10,b=15; cout< Understanding global and local function declaration using a function declaration above main and another inside the main routine. Passing null terminated string to function using array notation #2701 //using array notation #include #include using namespace std; int space_count(char []); int main() { char str[80]; int spaces=0; cout<<"Input a small sentence: " ; cin.getline(str,80); spaces=space_count(str); cout<<"Number of spaces in given input = " < Program to pass by reference character array as a null terminated string to a function using the array notation using [ ]. Passing null terminated string to function using pointer notation #2706 //using array notation #include #include using namespace std; int space_count(char *); int main() { char str[80]; int spaces=0; cout<<"Input a small sentence: " ; cin.getline(str,80); spaces=space_count(str); cout<<"Number of spaces in given input = " < Program to pass by reference character array as a null terminated string to a function using the pointer notation using *. Passing integer array to a function for linear search #2733 #include using namespace std; int pos_in_arr(int [],int,int); int main() { int arr[]={19,20,34,55,99,102,12}; int len=sizeof(arr)/sizeof(arr[0]); int n; cout<<"Find position of which number? " ; cin>>n; int pos=pos_in_arr(arr,len,n); if(pos>0) cout<<"Position of given input = "< Program to pass an integer array, length of array and the member to be found to a function and return the position of the member found. Changing multiple values of integer array passed to a function #2737 #include using namespace std; int even2odd(int [],int); int disp_arr(int [],int); int main() { int arr[]={19,20,34,55,99,102,12}; int len=sizeof(arr)/sizeof(arr[0]); cout<<"-- Array members before change -- "< A program to pass integer array to a function and change many values in it based on a condition. Then reading such values in the calling function. Function returning by reference #2749 #include using namespace std; int& setg(); int g=10; int main() { cout<<"Global var g before change = "< Using function return by reference to modify a global array #2754 #include using namespace std; int& modifyga(int); int ga[]={10,20,30,40,50}; int main() { for(int i=0;i<5;++i) modifyga(i)=ga[i]+1; for(int i=0;i<5;++i) cout< A program that neatly modifies a global array by using the function return by reference technique. Solved Problems About Solved ProblemsXSolved problems are a specially designed set of problems which are usually based on some concept learning code sheets and they do enrich your learning of concepts along. They also provide you confidence to solve real life problems. Solutions to these problems are visible on user's request with press of a button. output writing, pass by ref/pass by value #2652 Write the output of the following code piece. Write the output of the following code piece. ... Char array passing to function #2656 Write a function alpha_count() where a character array is passed as reference and the length of array is passed as value. The output of function should be number of alphabets in the input array. You can use function isalpha() if you wish so. Write a function alpha_count() where a character array is passed as reference and the len ... Output writing – passing string as char pointer #2659 Write output of the following code. Write output of the following code. ... Array to array data #2697 Write output of the following code and explain its working. Write output of the following code and explain its working. ... Output writing function within function with array passing #2746 Dry run the following program carefully and write the output. Dry run the following program carefully and write the output. ... Correcting error in function call by reference #2742 Program given below has some incorrectly written function call, correct the mistake and rewrite the program. Program given below has some incorrectly written function call, correct the mistake and re ... Setting bigger of two values using function returning reference #2757 Write a c++ program using function returning the reference which finds the bigger of two variables passed it and then it sets the bigger variable to 10 while it is called. Show its implementation by writing the main routine also. Write a c++ program using function returning the reference which finds the bigger of two ... First and last digit of an integer in a function and putting at reference location #3018 Write a c++ program using a function with the following prototype – void first_last_digit(int n,int first,int last); In this function pass an integer number as n and then find the first and last digit of n. Then update it on locations first and last passed as reference. Assume values to be passed to demonstrate the working of this function in the main routine. Write a c++ program using a function with the following prototype - void first_l ... Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ... Output Writing – Function Returning reference #5265 Write output of the following code. Assume inclusion of related header files. int &min(int &a, int &b) { if (a<b) return a; else return b; } int main() { int x=2,y=3; min(x,y)=10; cout<<"x-y = "<<(x-y)<<endl; cout<<"y-x = "<<(y-x)<<endl; return 0; } Write output of the following code. Assume inclusion of related header files. int &a ... Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ... Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ... Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ... Output Writing – passing integers as ref and as def value #7699 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void series(int x=10) { for(int i=2;i<=x;i+=2) cout<<i<<" "; cout<<endl; } void modify(int &n) { n*=2; series(n); } int main() { int a=10; cout<<"a="<<a<<endl; modify(a); series(); cout<<"new a="<<a<<endl; return 0; } Write the output of the following C++ program code: Note: Assume all required header file ... Exam Questions About Exam QuestionsXExam Questions are individual questions picked from a real past exam paper that may have appeared in some board/other examinations. Here question and solution will be shown CBSE12A-2018-01D Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ... CBSE12D-2015-01D Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ... CBSE12A-2015-01D Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ... CBSE12A-2019-A01D Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ... Code Sheets:11 Solved Problems:14 Exam Questions:4 Topic Lists Introductory Sessions Beginning to Program Tokens Keyword and Identifiers Data Types Variables and Constants Operators Simple User Input Building Expressions and Formulas Simple Real World Problems Simple If and If Else Multiple-Nested-Ladder of If Else Switch case selection Simple Loops Tricks in Loops - break continue scope Loop Applications - Handling numerals Series printing loops Nested Loops Pattern printing loops Number Varieties and Crunches String Handling (Null Terminated) Strings - string class type Functions (Built-in) Functions - user defined Functions Reference Passing/Returning Arrays Concepts and 1-D Arrays Array Data Management Two dimensional arrays and Matrices Structures Basics Structures passing/returning 2D Array Memory Addressing Display Using IO Manipulation Display Using C Formatting Tricks User Defined Data Types Enumerated Types Preprocessor Directives And Macros Exception Handling Programming Paradigms and OOPs Advantages Abstraction and Encapsulation Polymorphism Inheritance Function Overloading Concepts Function Overloading Varieties Function Overloading Special Cases Defining Classes Creating and Using Class Objects Class Members Accessibility Class Function Types Inline Functions Constant Functions Nesting of Functions Class Members Scope Resolution Static Members in a Class Array of Objects Constructor Concepts Default Constructor Parameterized Constructor Copy Constructor Constructor Overloading Destructors Inheritance Fundamentals Public Derivations Private and Protected Derivations Multiple Inheritance Multi-Level Inheritance Class Nesting Data File Concepts Handling Text Files Handling Binary Files Pointer Concepts Pointer and Arrays Pointers and Functions Object Pointers This Pointer Linked Lists Stacks Queues Back ×
Global and Local Function Declaration #2689 #include using namespace std; int action1(int,int); int main() { int action2(int,int); int a=10,b=15; cout< Understanding global and local function declaration using a function declaration above main and another inside the main routine.
Passing null terminated string to function using array notation #2701 //using array notation #include #include using namespace std; int space_count(char []); int main() { char str[80]; int spaces=0; cout<<"Input a small sentence: " ; cin.getline(str,80); spaces=space_count(str); cout<<"Number of spaces in given input = " < Program to pass by reference character array as a null terminated string to a function using the array notation using [ ].
Passing null terminated string to function using pointer notation #2706 //using array notation #include #include using namespace std; int space_count(char *); int main() { char str[80]; int spaces=0; cout<<"Input a small sentence: " ; cin.getline(str,80); spaces=space_count(str); cout<<"Number of spaces in given input = " < Program to pass by reference character array as a null terminated string to a function using the pointer notation using *.
Passing integer array to a function for linear search #2733 #include using namespace std; int pos_in_arr(int [],int,int); int main() { int arr[]={19,20,34,55,99,102,12}; int len=sizeof(arr)/sizeof(arr[0]); int n; cout<<"Find position of which number? " ; cin>>n; int pos=pos_in_arr(arr,len,n); if(pos>0) cout<<"Position of given input = "< Program to pass an integer array, length of array and the member to be found to a function and return the position of the member found.
Changing multiple values of integer array passed to a function #2737 #include using namespace std; int even2odd(int [],int); int disp_arr(int [],int); int main() { int arr[]={19,20,34,55,99,102,12}; int len=sizeof(arr)/sizeof(arr[0]); cout<<"-- Array members before change -- "< A program to pass integer array to a function and change many values in it based on a condition. Then reading such values in the calling function.
Function returning by reference #2749 #include using namespace std; int& setg(); int g=10; int main() { cout<<"Global var g before change = "< Using function return by reference to modify a global array #2754 #include using namespace std; int& modifyga(int); int ga[]={10,20,30,40,50}; int main() { for(int i=0;i<5;++i) modifyga(i)=ga[i]+1; for(int i=0;i<5;++i) cout< A program that neatly modifies a global array by using the function return by reference technique. Solved Problems About Solved ProblemsXSolved problems are a specially designed set of problems which are usually based on some concept learning code sheets and they do enrich your learning of concepts along. They also provide you confidence to solve real life problems. Solutions to these problems are visible on user's request with press of a button. output writing, pass by ref/pass by value #2652 Write the output of the following code piece. Write the output of the following code piece. ... Char array passing to function #2656 Write a function alpha_count() where a character array is passed as reference and the length of array is passed as value. The output of function should be number of alphabets in the input array. You can use function isalpha() if you wish so. Write a function alpha_count() where a character array is passed as reference and the len ... Output writing – passing string as char pointer #2659 Write output of the following code. Write output of the following code. ... Array to array data #2697 Write output of the following code and explain its working. Write output of the following code and explain its working. ... Output writing function within function with array passing #2746 Dry run the following program carefully and write the output. Dry run the following program carefully and write the output. ... Correcting error in function call by reference #2742 Program given below has some incorrectly written function call, correct the mistake and rewrite the program. Program given below has some incorrectly written function call, correct the mistake and re ... Setting bigger of two values using function returning reference #2757 Write a c++ program using function returning the reference which finds the bigger of two variables passed it and then it sets the bigger variable to 10 while it is called. Show its implementation by writing the main routine also. Write a c++ program using function returning the reference which finds the bigger of two ... First and last digit of an integer in a function and putting at reference location #3018 Write a c++ program using a function with the following prototype – void first_last_digit(int n,int first,int last); In this function pass an integer number as n and then find the first and last digit of n. Then update it on locations first and last passed as reference. Assume values to be passed to demonstrate the working of this function in the main routine. Write a c++ program using a function with the following prototype - void first_l ... Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ... Output Writing – Function Returning reference #5265 Write output of the following code. Assume inclusion of related header files. int &min(int &a, int &b) { if (a<b) return a; else return b; } int main() { int x=2,y=3; min(x,y)=10; cout<<"x-y = "<<(x-y)<<endl; cout<<"y-x = "<<(y-x)<<endl; return 0; } Write output of the following code. Assume inclusion of related header files. int &a ... Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ... Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ... Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ... Output Writing – passing integers as ref and as def value #7699 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void series(int x=10) { for(int i=2;i<=x;i+=2) cout<<i<<" "; cout<<endl; } void modify(int &n) { n*=2; series(n); } int main() { int a=10; cout<<"a="<<a<<endl; modify(a); series(); cout<<"new a="<<a<<endl; return 0; } Write the output of the following C++ program code: Note: Assume all required header file ... Exam Questions About Exam QuestionsXExam Questions are individual questions picked from a real past exam paper that may have appeared in some board/other examinations. Here question and solution will be shown CBSE12A-2018-01D Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ... CBSE12D-2015-01D Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ... CBSE12A-2015-01D Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ... CBSE12A-2019-A01D Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ... Code Sheets:11 Solved Problems:14 Exam Questions:4 Topic Lists Introductory Sessions Beginning to Program Tokens Keyword and Identifiers Data Types Variables and Constants Operators Simple User Input Building Expressions and Formulas Simple Real World Problems Simple If and If Else Multiple-Nested-Ladder of If Else Switch case selection Simple Loops Tricks in Loops - break continue scope Loop Applications - Handling numerals Series printing loops Nested Loops Pattern printing loops Number Varieties and Crunches String Handling (Null Terminated) Strings - string class type Functions (Built-in) Functions - user defined Functions Reference Passing/Returning Arrays Concepts and 1-D Arrays Array Data Management Two dimensional arrays and Matrices Structures Basics Structures passing/returning 2D Array Memory Addressing Display Using IO Manipulation Display Using C Formatting Tricks User Defined Data Types Enumerated Types Preprocessor Directives And Macros Exception Handling Programming Paradigms and OOPs Advantages Abstraction and Encapsulation Polymorphism Inheritance Function Overloading Concepts Function Overloading Varieties Function Overloading Special Cases Defining Classes Creating and Using Class Objects Class Members Accessibility Class Function Types Inline Functions Constant Functions Nesting of Functions Class Members Scope Resolution Static Members in a Class Array of Objects Constructor Concepts Default Constructor Parameterized Constructor Copy Constructor Constructor Overloading Destructors Inheritance Fundamentals Public Derivations Private and Protected Derivations Multiple Inheritance Multi-Level Inheritance Class Nesting Data File Concepts Handling Text Files Handling Binary Files Pointer Concepts Pointer and Arrays Pointers and Functions Object Pointers This Pointer Linked Lists Stacks Queues
Using function return by reference to modify a global array #2754 #include using namespace std; int& modifyga(int); int ga[]={10,20,30,40,50}; int main() { for(int i=0;i<5;++i) modifyga(i)=ga[i]+1; for(int i=0;i<5;++i) cout< A program that neatly modifies a global array by using the function return by reference technique.
output writing, pass by ref/pass by value #2652 Write the output of the following code piece. Write the output of the following code piece. ...
Char array passing to function #2656 Write a function alpha_count() where a character array is passed as reference and the length of array is passed as value. The output of function should be number of alphabets in the input array. You can use function isalpha() if you wish so. Write a function alpha_count() where a character array is passed as reference and the len ...
Output writing – passing string as char pointer #2659 Write output of the following code. Write output of the following code. ...
Array to array data #2697 Write output of the following code and explain its working. Write output of the following code and explain its working. ...
Output writing function within function with array passing #2746 Dry run the following program carefully and write the output. Dry run the following program carefully and write the output. ...
Correcting error in function call by reference #2742 Program given below has some incorrectly written function call, correct the mistake and rewrite the program. Program given below has some incorrectly written function call, correct the mistake and re ...
Setting bigger of two values using function returning reference #2757 Write a c++ program using function returning the reference which finds the bigger of two variables passed it and then it sets the bigger variable to 10 while it is called. Show its implementation by writing the main routine also. Write a c++ program using function returning the reference which finds the bigger of two ...
First and last digit of an integer in a function and putting at reference location #3018 Write a c++ program using a function with the following prototype – void first_last_digit(int n,int first,int last); In this function pass an integer number as n and then find the first and last digit of n. Then update it on locations first and last passed as reference. Assume values to be passed to demonstrate the working of this function in the main routine. Write a c++ program using a function with the following prototype - void first_l ...
Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ...
Output Writing – Function Returning reference #5265 Write output of the following code. Assume inclusion of related header files. int &min(int &a, int &b) { if (a<b) return a; else return b; } int main() { int x=2,y=3; min(x,y)=10; cout<<"x-y = "<<(x-y)<<endl; cout<<"y-x = "<<(y-x)<<endl; return 0; } Write output of the following code. Assume inclusion of related header files. int &a ...
Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ...
Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ...
Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ...
Output Writing – passing integers as ref and as def value #7699 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void series(int x=10) { for(int i=2;i<=x;i+=2) cout<<i<<" "; cout<<endl; } void modify(int &n) { n*=2; series(n); } int main() { int a=10; cout<<"a="<<a<<endl; modify(a); series(); cout<<"new a="<<a<<endl; return 0; } Write the output of the following C++ program code: Note: Assume all required header file ...
CBSE12A-2018-01D Output writing – Function – pass by reference #5197 Find and write the output of the following C++ program code: Note : Assume all required header files are already included in the program. void Revert(int &Num, int Last=2) { Last=(Last%2==0)?Last+1:Last-1; for(int C=1; C<=Last; C++) Num+=C; } void main() { int A=20,B=4; Revert(A,B); cout<<A<<"&"<<B<<endl; B--; Revert(A,B); cout<<A<<"#"<<B<<endl; Revert(B); cout<<A<<"#"<<B<<endl; } Find and write the output of the following C++ program code: Note : Assume all required he ...
CBSE12D-2015-01D Output Writing – passing integers as ref and as def value #5834 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program . void Position (int &C1, int C2=3) { C1+=2; C2+=2; //Original paper had this incorrectly written as Y } void main() { int P1=20, P2=4; Position(P1); cout<<P1<<","<<P2<<endl; Position(P2,P1); cout<<P1<<","<<P2<<endl; } Write the output of the following C++ program code: Note: Assume all required header file ...
CBSE12A-2015-01D Output Writing – passing integers as ref and as def value #5935 Write the output of the following C++ program code: Note: Assume all required header files are already being included in the program. void Location(int &X,int Y=4) { Y+=2; X+=Y; } void main() { int PX=l0,PY=2; Location(PY) ; cout<<PX<<","<<PY<<endl ; Location(PX,PY); cout<<PX<<","<<PY<<endl ; } Write the output of the following C++ program code: Note: Assume all required header file ...
CBSE12A-2019-A01D Function arguments as pointer reference – Output writing #6953 Find and write the output of the following C++ program code: Note: Assume all required header files are already included in the program. void Alter(char *S1, char *S2) { char *T; T=S1; S1=S2; S2=T; cout<<S1<<"&"<<S2<<endl; } void main() { charX[]="First", Y[]="Second"; Alter(X,Y); cout<<X<<"*"<<Y<<endl; } Find and write the output of the following C++ program code: Note: Assume all required ...