1.

What is the error in the code?" Char ch; Int vowels=0,others=0; Cin>> ch; While((ch>= ‘A’ && ch <+ ‘Z’) || (ch>=’a’ && ch <= ‘z’)){ Switch(ch) { Case’a’: Case’A’: Case’e’: Case’E’: Case’i’: Case’i’: Case’o’: Case’O’: Case’u’: Case’U’: ++vowels; Break; Default: ++others; }} Cout<< vowels<< ‘\n’<< others;

A. The while loop is an endless loop. Whatever value of ch has in the beginning, will remain the same, as ch is not updated within the loop.
B. There is no need to declare a and A and hence all other vowels gain in switch as it is case insensitive.
C. The switch statement’s two case constants are identical case i and i which is an error
D. More than one is correct from above.
Answer» E.


Discussion

No Comment Found