You are on page 1of 3

10th Aug'20_GRIET'22_ITF1,2_Coding Practice

Test Summary
No. of Sections: 1
No. of Questions: 3
Total Duration: 90 min

Section 1 - Coding

Section Summary
No. of Questions: 3
Duration: 90 min

Additional Instructions:
Data structure

Q1. Learning Structures 3

Complete the implementation of the below two functions which operates on a Student structure.

Student Structure:

struct Student {
  int rollNo;
};

Declarations of the functions:


1. struct Student* convertToStudentArray(int, int*);
2. void printStudentArray(int, struct Student*);

The task is to complete the implementation of the above two functions


1. Function printStudentArray() takes two input argument,
First argument : an integer number denoting the size of the input Student array
Second Argument : the base address of the Student array

-> printStudentArray() must print all Student id's present in the Student array seperated by a single space.

2. Function convertToStudentArray() takes two input argument,


First argument : an integer number denoting the size of the input integer array
Second Argument : the base address of the integer array

-> convertToStudentArray() takes an integer array containing the student id's and converts it to an Student array and returns the
base address of the array.

Explanation / Sample Input and Output:

If the student structure created is like below:


[
  struct Student {
    rollNo: 7
  },
  struct Student {
    rollNo: 13
  },
  struct Student {
    rollNo: 11
  },
}

The output should be printed as: 


7 13 11 

Note: Some part of the code is given complete the program and compile

Sample Input Sample Output

1 536
536

Time Limit: - ms Memory Limit: - kb Code Size: - kb


Q2. Creating Student

Complete the implementation of the given function which operates on the below Student structure.

Node Structure:
---------------
struct Student {
  int rollNo;
  char name[20];
   oat marks;
};

The task is to complete the implementation of the below function declaration

Declaration of the function:

1. struct Student getStudent(int *rollNo, oat *marks, char *name);

Input Format

Function getStudent() takes three input argument:


1. First argument  : An integer pointer pointing to the rollNo of the student
2. Second argument : An oat pointer pointing to the marks of the student
3. Third argument  : An character pointer pointing to the rst character of student name

Output Format

Function getStudent() must do the following:


1. Create a student variable with provided details
2. Return the student variable

Sample Input Sample Output

36 Name: Tony
Tony ID: 36
74.099 Marks: 74.10

Time Limit: - ms Memory Limit: - kb Code Size: - kb

Q3. LinkedList in Reverse

Complete the implementation of the below function which operates on the given Node structure.

Node Structure:
---------------
struct Node {
  int data;
  struct Node *next;
};

The task is to complete the implementation of the below function declaration


Declaration of the function:
----------------------------
1. void printListInReverse(struct Node *head);

Explanation / Sample Input and Output:

Example-1:

If the linked list is like below:


1 -> 2 -> 3 -> 4 -> 5 -> NULL

The output sortStudents() must be: 


5 4 3 2 1 

Example-2:

If the linked list is like below:


1 -> NULL

The output sortStudents() must be: 


Input Format

Function printListInReverse() takes one input argument:


1. First argument : An head pointer of a linked list of Node structure
Output Format

Function printListInReverse() must do the following:


1. Print all the data of the linked list in reverse order
2. The values printed must be seperated by a single space

Constraints

1. 1 <= N <= 100


N = Length of the Linked List

Sample Input Sample Output

6 5 6 6 17 2 36
36 2 17 6 6 5 36 2 17 6 6 5

Time Limit: - ms Memory Limit: - kb Code Size: - kb

You might also like