Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
#define Diff(N1,N2) ((N1>N2)?N1-N2:N2-N1)
This macro definition will give difference of N1 and N2 by using the ternary operator. If N1 is greater than N2, N1-N2 will be returned else N2-N1 will be returned
void main()
{ int A,B,NUM[] = {10,23,14,54,32}; //Integer A, B and a 5 member integer array initialized for(int CNT =4; CNT>0; CNT–) //This loop will run 4 times only
{ A=NUM[CNT]; //Will begin from Last member of array and then reducing further B=NUM[CNT-1]; //This will be Last but one member and then reducing further
cout<<Diff(A,B)<<‘#’; //This will be difference of 5th and 4th, then 4th and 3rd then 3rd and 2nd and then 2nd and 1st member of array. So the output would be 22#40#9#13#
}
}
C. Sir| Created: 5-Dec-2018 | Updated: 22-Mar-2026|CBSE12A-2017