Advertisements
Advertisements
प्रश्न
Evaluate the following expression where prefix and postfix increment and decrement operator is used.
int rd=206, tf=20, yg=3, km=0;
km = rd % tf++ + tf % ++yg ;
System.out.println ("RD=" +rd+ "TF=" +tf+ “YG=" +yg+ "KM=" +km);
मूल्यांकन
Advertisements
उत्तर
First term (rd % tf++):
tf++ (Postfix): Uses the current value of tf (20) for the modulo calculation, then increments tf to 21.
206 % 20 = 6 (remainder of 206 divided by 20).
Second term (tf % ++yg):
++yg (Prefix): Increments yg first (from 3 to 4), then uses it.
Uses the updated value of tf (21). So, 21 % 4 = 1 (remainder of 21 divided by 4).
- km = 6 + 1 = 7
- rd = 206
- tf = 21
- yg = 4
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1: Revision of Class 9 Syllabus - Exercises [पृष्ठ ४५]
