Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

12. Let\'s assume that you want to write records of student (id and name) into a

ID: 3861033 • Letter: 1

Question

12. Let's assume that you want to write records of student (id and name) into a file in binary format. The file should keep records of all items you add to it. Write the statement to open such a file Also write to this file, a record called sL that you have defined and initialized in previous problem. durnFve.open fienave 13- Assume you want to display the fifth How do you e and set its location pointer? Write the statements to open the given file and move the location pointer, then read the file into the structure variable sl daeFve.oenEienene.vus: beg) X'PTY =51 ; 14- Write a statement to open a file in such a way that information will only be writhen to its ANSWER datin ANSWER: .latatie 15- What is the output of the following program? #include using namespace std class TestClass public: TestClass(int x) TestClass0 l cout

Explanation / Answer

Question 14:

Answer: dataFile.open(“info.dat”,ios::out|ios::app);

Question 15:

#include <iostream>

using namespace std;

class TestClass

{

    public:

        TestClass(int x)

        {

            cout<<"x"<<endl;

        }

        TestClass()

        {

            cout<<"Hello"<<endl;

         }

};

int main()

{

    TestClass test(77);

                return 0;

}

Answer:

x

Question 16:

what is the member function to write a single character to a file

Answer: get

Question 20:

Answer:

#include <iostream>

#include <stdio.h>

#include <cstring>

using namespace std;

int main()

{

    char str[80];

    int length, i, vo = 0, dig = 0, upper = 0, lower = 0;

    printf(" Enter a String:");

    scanf("%[^ ]",str);

    length = strlen(str);

    for(i=0; i<length; i++)

    {

        if(str[i] == 'a' || str[i] == 'A' ||

           str[i] == 'e' || str[i] == 'E' ||

           str[i] == 'i' || str[i] == 'I' ||

           str[i] == 'o' || str[i] == 'O' ||

           str[i] == 'u' || str[i] == 'U')

            vo = vo + 1;

        if(str[i] >= '0' && str[i] <= '9')

                dig = dig + 1;

    }

    int j = 0;

    while(str[j] != '')

    {

        if(str[j] >= 'a' && str[j] <= 'z')

            lower = lower + 1;

        if(str[j] >= 'A' && str[j] <= 'Z')

            upper = upper + 1;

        j++;

    }

    printf(" The String is: %s ",str);

printf(" Number of vowels is: %d",vo);

printf(" Number of digits is: %d",dig);

printf(" Number of Lowercase letters is: %d",lower);

printf(" Number of Uppercase letters is: %d",upper);

return 0;

}

OUTPUT

Enter a String:123 Hai Hello How Are You

The String is: 123 Hai Hello How Are You

Number of vowels is: 9

Number of digits is: 3

Number of Lowercase letters is: 12

Number of Uppercase letters is: 5