PPS GTU Paper Solution Summer 2022 | 311003

Here, We provide PPS GTU Paper Solution Summer 2022. Read the Full Programming For Problem Solving gtu paper solution given below.

PPS GTU Old Paper Summer 2022 [Marks : 70] : Click Here 

(a) Answer the following questions
Define: Compiler
Justify, 2 and ‘2’ both are not same in C language.
What is the role of sizeof operator in C language?

Definition of Compiler

A compiler is a software program that takes source code written in a high-level programming language and converts it into machine code that can be executed by a computer.


In the C programming language, the number 2 is an integer constant, while the string “2” is a character string constant. These are not the same and cannot be used interchangeably in C. For example, the integer constant 2 can be used in mathematical operations, such as addition and multiplication, while the string “2” cannot. The string “2” must be converted to an integer value before it can be used in such operations.

Role of sizeof Operator:

The sizeof operator in C is a unary operator that returns the size, in bytes, of a data type or a variable. It can be used to determine the memory requirements of a program, to allocate dynamic memory, and to determine the size of arrays and structures. The sizeof operator is particularly useful when writing code that is platform-independent, as it can be used to determine the size of data types that may vary depending on the hardware architecture.

(b) Answer the following questions

Ternary operator can be nested. (True/False)
What do you mean by enumerated data type in C language?
What is the difference between char *p and char p[]?
What do you mean by function prototype?

(c) Answer the following questions

Define Algorithm.
What do you mean by recursion?
What do you mean by program and program control?
What is a pointer?
What is the role of getc( ) and getw() file functions?
Programming needs logic building. Justify
Define Interpreter.

(a) Write the outputs of the following expression:
i) 50 % 2 / 3 + 2
ii) 21 / (int) 2.5 + 3
iii) (1 > 2 ) || ( 2 < 3) && 5 < 1

i) 50 % 2 / 3 + 2

The output of the expression is 2.

ii) 21 / (int) 2.5 + 3

The output of the expression is 13.

iii) (1 > 2 ) || ( 2 < 3) && 5 < 1

The output of the expression is 0.

(b) Write a program to print Fibonacci series.e.g.0, 1, 1, 2, 3, 5, 8, 13.

(c) Explain the working of various bit-wise operators with the example.

[OR] (c) List out all various string functions and describe them with syntax and

(a) Explain ternary (?:) operator in detail with the example.

The ternary operator (also known as the conditional operator) in C is a shorthand way of writing an ifelse statement.

The syntax for the ternary operator is as follows: condition ? expression1 : expression2.

If condition is true, the ternary operator evaluates to expression1, otherwise, it evaluates to expression2.

Here is an example of using the ternary operator to return the larger of two values:

#include <stdio.h>

int main() {
  int a = 5, b = 10;
  int max = (a > b) ? a : b;
  printf("The maximum value is: %d\n", max);
  return 0;

(b) Discuss the need of break and continue statements with example.

(c) Design a flowchart for checking whether a given number is palindrome or not.

(a) What is meant by array of pointers? Explain it with example.

An array of pointers is a data structure in C where each element of the array is a pointer. The elements of the array can point to variables, functions, or any other data type.

Here is an example of declaring and initializing an array of pointers to integers:

#include <stdio.h>

int main() {
  int a = 10, b = 20, c = 30;
  int *ptr[3];
  ptr[0] = &a;
  ptr[1] = &b;
  ptr[2] = &c;
  printf("Value of a: %d\n", *ptr[0]);
  printf("Value of b: %d\n", *ptr[1]);
  printf("Value of c: %d\n", *ptr[2]);
  return 0;

In this example, ptr is declared as an array of 3 pointers to integers. The addresses of the variables a, b, and c are then stored in the elements of the array ptr. The values of a, b, and c can be accessed through the pointers stored in the array by dereferencing them using the * operator.

(b) Write a program to print the triangle shown below.

(c) Draw block diagram of computer system and explain the functions of each
component in detail.

(a) Explain type casting with example.

Type casting refers to converting a variable from one data type to another data type explicitly. This can be achieved using type casting operators. The type casting operator is written in the form of (type_name) expression.

For example, consider the following code:

float f = 10.5;
int i;
i = (int) f;

Here, the value of f is 10.5 which is a float data type. We want to store it in an integer variable i. In order to do so, we use type casting operator (int) to convert f from float to integer. The result will be i = 10, the fractional part of the float value will be truncated.

(b) Compare and contrast goto statement and switch statement with example.

(c) Write a recursive program to find factorial of a given number.

(a) Differentiate function and macro.

DefinitionA self-contained block of code that performs a specific task and returns a valueA preprocessor directive that performs a simple text substitution
Syntaxreturn_type function_name(arguments) { statements; }#define macro_name replacement_text
ExecutionFunction calls are executed at runtimeMacros are expanded by the preprocessor before the program is compiled
ArgumentsFunctions can accept arguments and operate on themMacros can accept arguments but have no type checking or error checking
Return valueFunctions can return a value of any type, or void if there is no return valueMacros do not return a value, they are replaced by their replacement text in the code
ScopeFunctions have their own local scope, and the variables declared within a function are destroyed when the function returnsMacros do not have a scope, and their replacement text is visible to the entire program
OverheadFunctions have some overhead due to function call and return, and local variable allocationMacros are expanded in place and have no overhead, but can result in larger and less readable code if used excessively

(b) Explain while loop and do-while loop with example.

(c) Explain one dimensional array, two dimensional array and multi-dimensional
array with their syntax and example.

(a) Differentiate call by value and call by reference.

Call by ValueCall by Reference
A copy of the actual argument is made and passed to the function.A reference to the actual argument is passed to the function.
Changes made to the argument within the function do not affect the original argument outside the function.Changes made to the argument within the function affect the original argument outside the function.
The argument must be a simple data type, such as an integer or a character.The argument must be a pointer to a simple data type, such as an integer or a character.
Syntax: function_name(argument)Syntax: function_name(&argument)
Example: void swap(int a, int b) { int temp = a; a = b; b = temp; }Example: void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; }

(b) Explain structure within structure with example.

(c) Explain error handling in file system with example.

(a) Define Union in ‘C’ with example.

A union in C is a data structure that allows you to store different data types in the same memory location. Unlike a structure, where each member has its own memory location, all members of a union share the same memory location. The size of a union is equal to the size of its largest member.


union number
    int x;
    float y;
    char z;

int main()
    union number num;
    num.x = 10;
    printf("The value of x is: %d\n", num.x);
    num.y = 10.5;
    printf("The value of y is: %f\n", num.y);
    num.z = 'A';
    printf("The value of z is: %c\n", num.z);
    return 0;

(b) Define dynamic memory allocation. Explain malloc() and calloc().

(c) Explain the following File Handling functions: 1. fseek( ) 2. ftell( ) 3. fread( )
fwrite( ) 5. fscanf( ) 6. fprintf( ) 7.rewind( )

Read More : PPS GTU Paper Solution Winter 2021
Read More : BEE GTU Paper Solution Winter 2021

“Do you have the answer to any of the questions provided on our website? If so, please let us know by providing the question number and your answer in the space provided below. We appreciate your contributions to helping other students succeed.