PPS Q-Bank Unit : 01

1. What is a flow chart? List it’s symbol and its use. Draw a flowchart to add two numbers.

Ans : A flowchart is a visual representation of a process or algorithm, using symbols and arrows to show the sequence of steps and decision points. It helps to visualize the flow of information and actions in a clear and structured manner.

Symbols Of Flowchart :

Flowchart Symbol Name Description 
Process symbol Also known as an “Action Symbol,” this shape represents a process, action, or function. It’s the most widely used symbol in flowcharting. 
 Start/End symbol Also known as the “Terminator Symbol,” this symbol represents the start points, end points, and potential outcomes of a path. Often contains “Start” or “End” within the shape. 
 Input/Output symbol Also referred to as the “Data Symbol,” this shape represents data that is available for input or output as well as representing resources used or generated. While the paper tape symbol also represents input/output, it is outdated and no longer in common use for flowchart diagramming. 
 Decision symbol Indicates a question to be answered — usually yes/no or true/false. The flowchart path may then split off into different branches depending on the answer or consequences thereafter. 
Arrow Shows relationships between different shapes. 

Flowchart for addition of two numbers.

2. Explain any algorithm with its Flow chart. (Any concept could be asked)

Ans :An algorithm is a step-by-step set of instructions for solving a problem. An algorithm is a set of instructions for solving a problem or achieving a goal. It provides a clear and organized way to approach and tackle tasks efficiently.

Example For Algorithm and Flow chart

  1. Start 
  2. Initialize a variable called “sum” to zero (sum = 0). 
  3. Loop for 10 times (i = 1 to 10): 
  • a. Input a number from the user. 
  • b. Add the input number to the “sum” variable. 
  1. End Loop 
  2. Display the value of “sum” as the sum of 10 numbers. 
  3. Stop 

3. Is ‘C Language’ a middle level language? Justify your answer.

Ans : “C is a middle level language” means that C programming language strikes a balance between low-level and high-level languages in terms of abstraction and functionality. It provides a higher level of abstraction than low-level languages like assembly language, making it more human-readable and easier to program. At the same time, C retains low-level features such as direct memory access and bit-level operations, offering fine-grained control over hardware resources. C is efficient, portable, and widely used in system-level programming, embedded systems, and performance-critical applications, making it a versatile language for various types of applications.

4. Compare compiler & Interpreter.

Ans : Compilation vs. Interpretation: A compiler translates the entire source code into machine code before execution, while an interpreter translates and executes the source code line by line during runtime. Output: A compiler generates an executable file, while an interpreter produces output on-the-fly without creating a separate executable file. Performance: Compiled programs are generally faster, while interpreted programs may be slower due to repeated translation and execution at runtime.

5. Draw basic Block diagram of C Program Structure. Briefly explain each.

Ans: Preprocessor Directives: These are statements that start with ‘#’ and provide instructions to the preprocessor.

Main Function: Every C program must have a main function, which serves as the entry point of the program.

Declarations: Declarations define variables and functions before they are used in the main function or other parts of the program.

Statements: Statements are the instructions that make up the logic of the program, including assignments, conditional statements, loops, and other programming constructs.

Comments: Comments provide explanations or documentation within the code, but they are not executed by the compiler.

#include<stdio.h>  
#include<conio.h>  
void main(){ 
    //body  
    getch();  
}

6. Define Following terms: 1) Tokens 2) Keywords 3) Identifiers 4) Variables 5) Constants 6) Compiler 7) Identifiers

Ans : Keywords: Reserved words with special meanings in a programming language. 

Identifiers: User-defined names for variables, functions, or entities in a program.

Variables: Named memory locations to store data during program execution. 

Compiler: Software that translates source code into machine code. 

Operating System: Software that manages and controls computer resources. 

7. Write a short note on data types that C language Supports.

Ans: In programming, a data type is a classification of data that determines the possible values for that type, the operations that can be done on values of that type, and the way that the values of that type are stored in memory.

  • Integer: Used to store whole numbers. Examples include int (usually 32 bits), short (usually 16 bits), and long (usually 64 bits).
int myInt = 42;
  • Floating-Point: Used to store decimal numbers. Examples include float (32 bits) and double (64 bits).
float myFloat = 3.14;
  • Character: Used to store a single character. Examples include char (8 bits) and wchar_t (16 or 32 bits).
char myChar = 'a';
  • Boolean: Used to store true/false values. Examples include bool (true or false) and _Bool (1 or 0).
bool myBool = true;

8. What do you mean by type conversion? Explain its type with example.

Ans: Implicit type conversion, also known as type coercion, is an automatic conversion that occurs when a value of one data type is assigned to a variable of another data type without the programmer explicitly specifying the conversion. For example: 

int num1 = 10;  
float num2 = num1;  	

Explicit type conversion, also known as type casting, is a manual conversion that is explicitly specified by the programmer using casting operators. For example:

float num1 = 10.5;  
int num2 = (int)num1;

9. List all the operators and its type. Explain Relational and Logical operators with example. (Any operator could be asked)

Note : We have explain all operators.

Ans : Arithmetic Operators: Addition (+): Performs addition operation. Subtraction (-): Performs subtraction operation. Multiplication (*): Performs multiplication operation. Division (/): Performs division operation. Modulus (%): Performs modulus (remainder) operation.

int a = 5;  
int b = 3; 
int sum = a + b; // addition  
int diff = a - b; // subtraction  
int product = a * b; // multiplication  
int quotient = a / b; // division  
int remainder = a % b; // modulus 

Relational Operators: 

  • Greater than (>), Less than (<): Compares two values and returns true (1) if the condition is satisfied, otherwise false (0). 
  • Equal to (==), Not equal to (!=): Compares two values for equality and returns true (1) if the condition is satisfied, otherwise false (0). 
  • Greater than or equal to (>=), Less than or equal to (<=): Compares two values for equality and returns true (1) if the condition is satisfied, otherwise false (0). 
int a = 5;  
int b = 3;  
int result1 = a > b; // greater than  
int result2 = a < b; // less than  
int result3 = a == b; // equal to  
int result4 = a != b; // not equal to  
int result5 = a >= b; // greater than or equal to  
int result6 = a <= b; // less than or equal to 

Logical Operators: 

  • Logical AND (&&), Logical OR (||): Perform logical operations on boolean expressions and return true (1) if the condition is satisfied, otherwise false (0). 
  • Logical NOT (!): Negates the value of a boolean expression. 
int x = 5;  
int y = 3;  
int z = 7;  
int result1 = (x > y) && (y < z); // logical AND  
int result2 = (x > y) || (y > z); // logical OR  
int result3 = !(x > y); // logical NOT 

Assignment Operators: 

  • Assignment (=): Assigns a value to a variable. 
  • Addition and assignment (+=), Subtraction and assignment (-=): Performs the operation and assigns the result to a variable in a single step. 
  • Multiplication and assignment (*=), Division and assignment (/=): Performs the operation and assigns the result to a variable in a single step. 
  • Modulus and assignment (%=): Performs the operation and assigns the result to a variable in a single step. 
int a = 5; 
int b = 3;  
a += b; // equivalent to a = a + b; (addition and assignment)  
a -= b; // equivalent to a = a - b; (subtraction and assignment)  
a *= b; // equivalent to a = a * b; (multiplication and assignment)  
a /= b; // equivalent to a = a / b; (division and assignment) 
a %= b; // equivalent to a = a % b; (modulus and assignment) 

increment and Decrement Operators: 

  • Post-increment (i++), Post-decrement (i–): Increases or decreases the value of a variable by 1 after the operation is performed. 
  • Pre-increment (++i), Pre-decrement (–i): Increases or decreases the value of a variable 

10. Explain Operator Precedence and Associativity with example.

Ans : Precedence of an operator is its priority in an expression for evaluation.

The operator with higher precedence is evaluated first and the operator with the least precedence is evaluated last.

Operator precedence is why the expression 5 + 3 * 2 is calculated as 5 + (3 * 2), giving 11, and not as (5 + 3) * 2, giving 16.

We say that the multiplication operator (*) has higher “precedence” or “priority” than the addition operator (+), so the multiplication must be performed first.

Associativity is the left-to-right or right-to-left order for grouping operands to
operators that have the same precedence.

Operator associativity is why the expression 8 – 3 – 2 is calculated as (8 – 3) – 2, giving 3, and not as 8 – (3 – 2), giving 7.

We say that the subtraction operator (-) is “left associative”, so the left subtraction must be performed first.

When we can’t decide by operator precedence alone in which order to calculate an expression, we must use associativity.

11. Explain following functions: 1) scanf 2) printf 3) gets 4) puts 5) getch 6) putch

  • scanf : Reads input from the user, allowing you to specify the format and store the values.
  • printf : Displays output to the user, with options for formatting and printing data.
  • gets : Reads a line of text from the user, but it’s considered unsafe and deprecated.
  • puts : Writes a string to the output, followed by a newline character.
  • getch : Reads a single character directly from the keyboard, without displaying it.
  • putch : Displays a single character on the screen, without moving to the next line.

12. Write a program to swap values of 2 variables (i) with an extra variable and (ii)without using an extra variable.

#include<stdio.h>
#include<conio.h>
void main()
{

  int a,b,c;
  clrscr();
  printf("Enter first value : ");
  scanf("%d", &a);
  printf("Enter second value : ");
  scanf("%d", &b);
  printf("\nbefore swape first value : %d " ,a);
  printf("\nbefore swape second value : %d " ,b);
  c=a;
  a=b;
  b=c;
  printf("\nAfter swap First value : %d " ,a);
  printf("\nAfter swap Second value : %d " ,b);


// Now Without Using third variable

  printf("\nEnter first value : ");
  scanf("%d", &a);
  printf("Enter second value : ");
  scanf("%d", &b);
  printf("\nbefore swape first value : %d " ,a);
  printf("\nbefore swape second value : %d " ,b);
  a=a+b;
  b=a-b;
  a=a-b;
  printf("\nAfter swap First value : %d " ,a);
  printf("\nAfter swap Second value : %d " ,b);
getch();
}

13. Write a program to print the ASCII value of a given character.

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("enter the character;");
scanf("%c" ,&ch);
printf("the ASCII_value is :%d" ,ch);
getch();
}

14. Write a program to enter marks of five subjects of a student and calculate its average and percentage.

#include<stdio.h>
#include<conio.h>
void main()
{
   int a,b,c,d,e,f,g;
   clrscr();
   printf("Marks of English:\n");
   scanf("%d",&a);
   printf("Marks of Maths:\n");
   scanf("%d",&b);
   printf("Marks of Gujarati:\n");
   scanf("%d",&c);
   printf("Marks of computer:\n");
   scanf("%d",&d);
   printf("Marks of science:\n");
   scanf("%d",&e);
   f=a+b+c+d+e;
   printf("AVERAGE:%d\n",f/5);
  g=f/5;
   printf("percentage:%d%\n",g);
   getch();
}

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top