A5 hi b4 strcpyab strncpyab 4 cout b endl 4 should

  • No School
  • AA 1
  • 4

This preview shows page 3 - 4 out of 4 pages.

a[5] = "Hi" , b[4]; strcpy(a,b); // strncpy(a,b, 4); cout << b << endl; #4 Should print out the file to the screen. double n; ifstream infile; infile.open( "Numbers.txt" ); while (!infile.eof) { infile >> n; cout << n << endl; } #5 Should fill a vector with 1, 2, 3, 4, and 5: vector < int > vect1; for ( int i = 0; i < 5; i++) { vect1.push_back = i + 1; } #6 Should output 5: int *a, *b; int c = 3, d = 2; a = &c; b = &d; cout << a + *b << endl; #7 Should output 1 2 3 4 5: int size = 5; int a[size] = { 1, 2, 3, 4, 5 }; for ( int i = 0; i < size; i++) { cout << a[i] << " " ; } cout << endl;
Image of page 3

Subscribe to view the full document.

Find the output: #1 What will output? int size = 5, *arr = new int [size]; for ( int i = 0; i < size; i++) { arr[i] = i * 2; cout << *(arr + i) << endl; } #2 What is the output as is? What if the commented line is run instead? string words[2][3] = { "Hi" , "there" , "how" , "are" , "you" , "doing" }; for ( int i = 0; i < 2; i++) { for ( int j = 0; j < 3; j++) { cout << words[i][j] << " " ; // cout << words[i][j][1] << " "; } } cout << endl; #3 What will the vector have in it if the user enters 5 for the size? vector < int > nums; int size; cout << "Ender the size: " ; cin >> size; for ( int i = 0; i < size; i++) { nums.push_back(i + 1 * 2); } #4 What will output? char a[35] = "c-" , b[28] = "strings are a pain to use." ; strcat(a,b); cout << a << endl;
Image of page 4
  • Fall '19
  • Array, Vector Motors, Variable-length array

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes