Q. What will be the result of the following code snippet?

Code:
#include <stdio.h>
void solve() {
    char ch[10] = "abcdefghij";
    int ans = 0;
    for(int i = 0; i < 10; i++) {
        ans += (ch[i] - 'a');
    }
    printf("%d", ans);
}
int main() {
    solve();
	return 0;
}
  • (A) 45
  • (B) 36
  • (C) 20
  • (D) 100
πŸ’¬ Discuss
βœ… Correct Answer: (A) 45

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
255
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Manisha Agrawal
Publisher
πŸ“ˆ
84%
Success Rate