Explain the logic of each statement of the given code segment.
Streampos orig = aFile.tellp();
aFile.seekp(0, ios::end); (05)
Write a program which prompts the user to enter 10 elements of type int and stores them into an array. Program should display only those elements whose indices are divisible by 2.
Hint: Use pointer to display the array elements whose indices are divisible by 2. (05)
Write the code for a structure called Inventory having the following elements:(03 marks)
• A character array named partName
• An integer named partNumber
• An integer named stock.
Which one of the following is the better approach in terms of memory space occupation and why ? (03 Marks)
1. char *arr[] = {“programming”, “fundamental”, “cs201”};
char arr[3][50] = {“programming”, “fundamental”, “cs201”}; (03)
Write a statement for opening file trans.txt for input; using an ifstream object called inTransaction. (02)
Write the code to access the element at third row and second column of a 2D array uses pointer named arrayptr . (02)
No comments:
Post a Comment