What will be the output of the following C++ code?
#include <iostream> using namespace std; int main() { char *ptr; char Str[] = “abcdefg”; ptr = Str; ptr += 5; cout << ptr; return 0; } a) fg b) cdef c) defg d) abcd
#include <iostream> using namespace std; int main() { char *ptr; char Str[] = “abcdefg”; ptr = Str; ptr += 5; cout << ptr; return 0; } a) fg b) cdef c) defg d) abcd
#include <iostream> using namespace std; int main() { char arr[20]; int i; for(i = 0; i < 10; i++) *(arr + i) = 65 + i; *(arr + i) = ‘\0’; cout << arr; return(0); } a) ABCDEFGHIJ b) AAAAAAAAAA c) JJJJJJJJ d) AAAAAAJJJJ
#include <iostream> using namespace std; int main() { int a = 5, b = 10, c = 15; int *arr[ ] = {&a, &b, &c}; cout << arr[1]; return 0; } a) 5 b) 10 c) 15 d) it will return some random number
#include <iostream> using namespace std; int main() { int a = 10; if (a < 10) { for (i = 0; i < 10; i++) cout << i; } else { cout << i; } return 0; } a) 0123456789 b) 123456789 c) 0 d) error
#include <iostream> using namespace std; void addprint() { static int s = 1; s++; cout << s; } int main() { addprint(); addprint(); addprint(); return 0; } a) 234 b) 111 c) 123 d) 235
#include <iostream> using namespace std; int g = 100; int main() { int a; { int b; b = 20; a = 35; g = 65; cout << b << a << g; } a = 50; cout << a << g; return 0; } a) 2035655065 b) 2035655035 c) 2035635065 d) 2035645065
#include <iostream> using namespace std; int main() { int i; enum month { JAN = 1, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC }; for (i = MAR; i <= NOV; i++) cout << i; return 0; } a) 01234567891011 b) 123456789101112 c) 34567891011 d) 123456789
#include <iostream> using namespace std; enum colour { green, red, blue, white, yellow, pink }; int main() { cout << green<< red<< blue<< white<< yellow<< pink; return 0; } a) 012345 b) 123456 c) compile time error d) runtime error
#include <iostream> using namespace std; enum test { A = 32, B, C }; int main() { cout << A << B<< C; return 0; } a) 323334 b) 323232 c) 323130 d) 323134
#include <iostream> using namespace std; enum cat { temp = 7 }; int main() { int age = 14; age /= temp; cout << “If you were cat, you would be ” << age << endl; return 0; } a) If you were cat, you would be 5 b) If you were cat, you would … Read more