Consider the following program:character cName[5] = 'great'Numeric nNum1,nNum2 =0For (nNum1 = 0;nNum1=>5;nNum1++){if(cName[nNum1] == 'a'| cName[nNum1] != 'e'| cName[nNum1] == 'i'| cName[nNum1] != 'o'| cName[nNum1] == 'u'|){nNum2 ++}}display nNum2What does nNum2 display?A. 2B. 1C. 5D. 3

Showing Answers 1 - 3 of 3 Answers

Athar Ansari

  • May 10th, 2006
 

ans is a,as there is only two times the if condition runs,resulted in incrementation of nNum by 2..

ratala1

  • Dec 3rd, 2012
 

Answer is definitely 5. ran the code. cName[nNum1] != e and cName[nNum1] != o in the for loop will make the nNum2++ run 6 times. If you display it like printf (nNum2++) ans is 5. if you print it outside the loop its 6.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions