Check if a character array or c-style string is same (Palindrome) when reversed using an independent function.
A simple call by reference demonstration by adding something in the original value itself.
A program that uses both call by reference and call by value in the same program to compare it for better understanding.
Swapping (Interchange) of two variable values using the call by reference technique of function arguments.
Understanding global and local function declaration using a function declaration above main and another inside the main routine.
Program to pass by reference character array as a null terminated string to a function using the array notation using [ ].
Program to pass by reference character array as a null terminated string to a function using the pointer notation using *.
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.
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.
A program to demonstrate returning of a reference data type from the function.
A program that neatly modifies a global array by using the function return by reference technique.
( As In Exam - CBSE12A-2018 )
Find and write the output of the following C++ program code: Note : Assume al
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; }
( As In Exam - CBSE12D-2015 )
Write the output of the following C++ program code: Note: Assume all re
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; }
( As In Exam - CBSE12A-2015 )
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 ; }
( As In Exam - CBSE12A-2019 )
Find and write the output of the following C++ program code:
Note: Ass
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; }
Write the output of the following code piece.
Write a function alpha_count() where a character array is passed as reference
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 output of the following code.
Write output of the following code and explain its working.
Dry run the following program carefully and write the output.
Program given below has some incorrectly written function call, correct the m
Program given below has some incorrectly written function call, correct the mistake and rewrite the program.
Write a c++ program using function returning the reference which finds the b
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 a function with the following prototype –
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 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; }
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; }