given an char array, char_array[100], which one correctly assign “happy” to this array? a. char_array[0] = ‘h’; char_array[1] = ‘a’; char_array[2] = ‘p’; char_array[3] = ‘p’; char_array[4] = ‘y’; b. char_array[0] = ‘h’; char_array[1] = ‘a’; char_array[2] = ‘p’; char_array[3] = ‘p’; char_array[4] = ‘y’; char_array[5] = ‘\0’; c. char_array[0] = “h”; char_array[1] = “a”; char_array[2] = “p”; char_array[3] = “p”; char_array[4] = “y”; char_array[5] = “\0”; d. char_array[1] = ‘h’; char_array[2] = ‘a’; char_array[3] = ‘p’; char_array[4] = ‘p’; char_array[5] = ‘y’; char_array[6] = ‘\0’; 5. given a string variable, string str; str = “Friday”, after doing str.append(“ happy.”), which one is the correct result of string str? a. Fridayhappy. b. happy. Friday c. Friday happy. d. happy.Friday 6. Given the below code, what’s the printed-out result? class Date{ public: int year; Date(int yr); void print(); }; Date:: Date(int yr){year = yr;} int main(){ Date d(2022); d.year = 2099; Date d2(2000); cout << d2.year <
given an char array, char_array[100], which one correctly assign “happy” to this array?
a. char_array[0] = ‘h’; char_array[1] = ‘a’; char_array[2] = ‘p’; char_array[3] = ‘p’; char_array[4] = ‘y’;
b. char_array[0] = ‘h’; char_array[1] = ‘a’; char_array[2] = ‘p’; char_array[3] = ‘p’; char_array[4] = ‘y’; char_array[5] = ‘\0’;
c. char_array[0] = “h”; char_array[1] = “a”; char_array[2] = “p”; char_array[3] = “p”; char_array[4] = “y”; char_array[5] = “\0”;
d. char_array[1] = ‘h’; char_array[2] = ‘a’; char_array[3] = ‘p’; char_array[4] = ‘p’; char_array[5] = ‘y’; char_array[6] = ‘\0’;
5. given a string variable, string str; str = “Friday”, after doing str.append(“ happy.”), which one is the correct result of string str?
a. Fridayhappy.
b. happy. Friday
c. Friday happy.
d. happy.Friday
6. Given the below code, what’s the printed-out result?
class Date{
public:
int year;
Date(int yr);
void print();
};
Date:: Date(int yr){year = yr;}
int main(){
Date d(2022);
d.year = 2099;
Date d2(2000);
cout << d2.year <<endl;
return 0;
}
a. 2099
b.2022
c. 0
d.2000
Step by step
Solved in 2 steps