NIELIT O Level Exam

<p>What will be the output of the following code C?</p><pre><span style="font-size: 12.6px;">#include &lt;stdio.h&gt; void solve(){ char ch[5] = "abcde"; int ans=0; for(int i =0; i&lt; 5; i++) { ans += (ch[i] - 'a'); } printf("%d", ans); } int main(){ solve(); return 0; }</span><br></pre>

What will be the output of the following code C?

#include <stdio.h>
 void solve(){
char ch[5] = "abcde";
int ans=0;
for(int i =0; i< 5; i++) {
ans += (ch[i] - 'a');
}
printf("%d", ans);
}
int main(){
solve();
return 0;
}


निम्नलिखित कोड का आउटपुट क्या होगा?

#include <stdio.h>
 void solve(){
char ch[5] = "abcde";
int ans=0;
for(int i =0; i< 5; i++) {
ans += (ch[i] - 'a');
}
printf("%d", ans);
}
int main(){
solve();
return 0;
}

A. 5

B. 20

C. 40

D. 10




Correct Answer is :

D. 10



Explanation


Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad