9. What is the output of following section of a program? int a[10] = {1,2,3,4,5,6,7,8,9,10}; int i = 0, s = 0; while(i<10){ cout<
Something seems wrong, it doesnt compile for me...
That seems like it would output what you want. Does it not?
#include <iostream> using namespace std; int main() { int a[10] = {1,2,3,4,5,6,7,8,9,10}; int i = 0; while(i<10) { cout<<a[i]<<" "; i = i+2; } return 0; } I removed the variable 's' since it wasn't being used but that worked. for me. I think if you copy and paste from here it will mess up the " " portion. So you might have to retype that. ---- By the way are you just trying to print only odd numbers?
Ah, i think it was the quotes i had got wrong before.
Join our real-time social learning platform and learn together with your friends!