My Todays CS201 Paper Shukr Alhmdulillah Acha ho gya
1- Considering the following structure, write the code for initializing the structure and
then displaying the value of each variable. (5)
struct student{
char name[64]; char oourse[128]; int age; int year;
2- Consider the following code segment. What will be the output of the following pro-
gram before and after calling the function updateAge?(5)
void updateAge (int U)
int main(){int age[5] ={10};
cout << “Array elements before passing array to function” << endl
for (int i =0; i <5; i++)
cout << “Array element"<< i+1 << <<age[i] [ << endl
updateAge(age); A
cout << "Array elements after passing array to function" << endl
for (int i =0; i <5; i++)
cout << “Array eIement"<< i+1 << <<age[i] [ << endl
void updateAge(int age[], int size){ age[3] = 20
3- If you are provided two methods for accessing a file; random and sequential.
Which method will you prefer and why? (3)
4- Determine the output of following code segment.(2) i
int x[5] = (2, 4, 5, 7, 1}
int "ptr =&x[2]; cout << ("ptr)++ <<endl ; cout << 'ptr++
5- Write a statement for opening file trans.txt for input; using an ifstream object called
inTransaction.(2)
6- Write a declaration statement for an array of 10 elements of type float. Also initial-
ize first four elements of array to 1.0, 2.0, 3.0 and 4.0.(2)
1- Considering the following structure, write the code for initializing the structure and
then displaying the value of each variable. (5)
struct student{
char name[64]; char oourse[128]; int age; int year;
2- Consider the following code segment. What will be the output of the following pro-
gram before and after calling the function updateAge?(5)
void updateAge (int U)
int main(){int age[5] ={10};
cout << “Array elements before passing array to function” << endl
for (int i =0; i <5; i++)
cout << “Array element"<< i+1 << <<age[i] [ << endl
updateAge(age); A
cout << "Array elements after passing array to function" << endl
for (int i =0; i <5; i++)
cout << “Array eIement"<< i+1 << <<age[i] [ << endl
void updateAge(int age[], int size){ age[3] = 20
3- If you are provided two methods for accessing a file; random and sequential.
Which method will you prefer and why? (3)
4- Determine the output of following code segment.(2) i
int x[5] = (2, 4, 5, 7, 1}
int "ptr =&x[2]; cout << ("ptr)++ <<endl ; cout << 'ptr++
5- Write a statement for opening file trans.txt for input; using an ifstream object called
inTransaction.(2)
6- Write a declaration statement for an array of 10 elements of type float. Also initial-
ize first four elements of array to 1.0, 2.0, 3.0 and 4.0.(2)