0% found this document useful (0 votes)
8 views

PPL ISE 1 - QB ans

The document provides a comprehensive overview of computer fundamentals, including definitions of computers, input devices, software types, and programming paradigms. It also covers algorithms, flowcharts, C programming basics, data types, operators, and variable scope. Additionally, it includes examples of C programs for various calculations and concepts.

Uploaded by

1.maths.care
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

PPL ISE 1 - QB ans

The document provides a comprehensive overview of computer fundamentals, including definitions of computers, input devices, software types, and programming paradigms. It also covers algorithms, flowcharts, C programming basics, data types, operators, and variable scope. Additionally, it includes examples of C programs for various calculations and concepts.

Uploaded by

1.maths.care
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Answers For PPL Question Bank For ISE-1

NOTE – This PDF is not 100% Accurate , Refer as your Quick Revision

1. What is a Computer? Describe the various types of computers.

A computer is an electronic device that processes data according to a set of instructions called a program. It
consists of hardware (physical components) and software (programs).

Types of computers:

• Personal Computers (PCs): Desktop and laptop computers used for personal tasks.
• Servers: Powerful computers that provide services to multiple users over a network.
• Supercomputers: High-performance computers used for complex calculations and simulations.
• Mainframes: Large, powerful computers used by organizations for critical tasks.
• Microcontrollers: Small computers embedded in devices like microwaves and cars.

2. What are input devices? Mention and explain any two input devices.

Input devices are hardware components that allow users to enter data into a computer.

Two examples:

• Keyboard: A common input device used to enter text and commands.


• Mouse: A pointing device used to control the cursor on the screen and interact with objects.

3. What is software? Explain different types of software.

Software is a collection of programs and data that tells a computer what to do.

Types of software:

• System Software: Manages the computer's hardware and resources (e.g., operating systems, device
drivers).
• Application Software: Performs specific tasks for users (e.g., word processors, web browsers,
games).
basic computer structure diagram
4. Basic Structure of a Computer
The primary components are:

• Input Units: Accept data and instructions from


• the user (e.g., keyboard, mouse).
• Output Units: Display results and information
• (e.g., monitor, printer).
• Central Processing Unit (CPU): The "brain" of
• the computer, responsible for processing data and
• instructions.
• Memory: Stores data and instructions temporarily
• RAM) or permanently (ROM).
• Storage Devices: Store data and programs for
• long-term use (e.g., hard drives, SSDs).
5. Influences on Language Design

Language design is influenced by various factors:


• Programming paradigms: Functional, procedural, object-oriented, etc.
• Hardware architecture: The underlying hardware can influence language features.
• Target applications: The intended use cases shape language design.
• Readability, maintainability, and efficiency: These are key considerations.

6. Different Language Categories

• Low-level languages: Close to machine code (e.g., assembly language).


• High-level languages: More human-readable (e.g., C, Python, Java).

7. Programming Paradigms

• Procedural: Focuses on procedures and functions.


• Object-oriented: Organizes code into objects with properties and methods.
• Functional: Treats computation as the evaluation of mathematical functions.
• Logical: Uses logical reasoning to solve problems.

8. Programming Domains

• System programming: Writing system software (e.g., operating systems).


• Application programming: Developing applications for users (e.g., games, web apps).
• Scientific computing: Using computers for scientific calculations and simulations.
• Web development: Creating websites and web applications.
• Artificial intelligence: Developing intelligent systems.

9. Language Evaluation Criteria

• Readability: How easy is the language to understand?


• Writability: How easy is it to write code in the language?
• Reliability: How reliable is the language's compiler or interpreter?
• Efficiency: How efficiently does code written in the language execute?
• Portability: How easily can code written in the language be ported to different platforms?

10. Algorithm to Find Sum and Average of Three Numbers

1. Start
2. Input three numbers: num1, num2, num3
3. Calculate sum: sum = num1 + num2 + num3
4. Calculate average: average = sum / 3
5. Print sum and average
6. End

11. Algorithm to Find Area and Perimeter of a Triangle

1. Start
2. Input three sides of the triangle: side1, side2, side3
3. Calculate perimeter: perimeter = side1 + side2 + side3
4. Calculate semi-perimeter: s = perimeter / 2
5. Calculate area: area = sqrt(s * (s - side1) * (s - side2) * (s - side3))
6. Print area and perimeter
7. End
12. Algorithm to Find the Largest of 3 Numbers

1. Start
2. Input three numbers: num1, num2, num3
3. If num1 > num2 and num1 > num3
o Print num1 as the largest
4. Else if num2 > num1 and num2 > num3
o Print num2 as the largest
5. Else
o Print num3 as the largest
6. End

13. Flowchart and Symbols

A flowchart is a visual representation of an algorithm. Common symbols include:

• Start/End: Oval
• Process: Rectangle
• Input/Output: Parallelogram
• Decision: Diamond
• Flowline: Arrow

Opens in a new window venngage.com


flowchart with different symbols

14. Flowchart and C Program for Simple Interest

Opens in a new window cprogrampracticals.blogspot.com


flowchart for simple interest calculation
C
#include <stdio.h>

int main() {
float principal, rate, time, interest;

printf("Enter principal amount: ");


scanf("%f", &principal);

printf("Enter
rate of interest: ");
scanf("%f", &rate);

printf("Enter time period: ");


scanf("%f", &time);

interest = (principal * rate * time) / 100;

printf("Simple interest = %.2f", interest);

return 0;
}

12. Basic Structure of a C Program

A C program typically consists of the following parts:

1. Preprocessor Directives: These lines begin with # and instruct the preprocessor to modify the
source code before compilation. Common directives include #include to include header files and
#define to define macros.
2. Main Function: This is the entry point of the program. Every C program must have a main()
function.
3. Function Definitions: These are user-defined functions that perform specific tasks.

Example:

C
#include <stdio.h>

int main() {
printf("Hello, world!\n");
return 0;
}
Use code with caution.

13. Tokens in C

Tokens are the smallest individual units of a C program. The main types of tokens are:

• Keywords: Reserved words with special meanings (e.g., int, float, if, else).
• Identifiers: Names given to variables, functions, and other entities (e.g., age, calculateArea).
• Constants: Fixed values that cannot be changed during program execution (e.g., 10, 3.14).
• Operators: Symbols used to perform operations (e.g., +, -, *, /).
• Punctuators: Special characters used to separate different parts of the program (e.g., ;, {}, (), []).

14. Identifiers (Variables)

An identifier is a name given to a variable, function, or other entity. It must follow these rules:

• It must start with a letter (uppercase or lowercase) or an underscore (_).


• Subsequent characters can be letters, digits, or underscores.
• It cannot be a keyword.
• It is case-sensitive.
15. Valid/Invalid Identifiers

• num2: Valid
• $num1: Invalid (starts with a special character)
• +add: Invalid (starts with an operator)
• a_2: Valid
• 199_space: Invalid (starts with a digit)
• _apple: Valid
• #12: Invalid (starts with a special character)

16. Definitions

• Variables: Memory locations used to store data that can change during program execution.
• Constants: Fixed values that cannot be changed during program execution.
• Associativity: The order in which operators of the same precedence are evaluated (left-to-right or
right-to-left).
• Precedence: The priority of operators, determining the order in which they are evaluated.

17. Operators in C

C supports a wide range of operators:

• Arithmetic Operators: +, -, *, /, %
• Relational Operators: ==, !=, <, >, <=, >=
• Logical Operators: &&, ||, !
• Bitwise Operators: &, |, ^, ~, <<, >>
• Assignment Operators: =, +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=
• Increment/Decrement Operators: ++, --
• Conditional Operator: ?:
• Comma Operator: ,
• Sizeof Operator: sizeof

18. Types of Operators

See the explanation in question 17.

19. Assignment Statement

An assignment statement assigns a value to a variable. General form:

C
variable_name = expression;

20. Basic Data Types in C

• int: Stores integer values (e.g., 10, -5).


• float: Stores floating-point numbers (e.g., 3.14, -2.5).
• double: Stores double-precision floating-point numbers (more precise than float).
• char: Stores a single character (e.g., 'a', 'z').

21. C Program to Compute Sizes of Data Types

C
#include <stdio.h>
int main() {
printf("Size of int: %zu bytes\n", sizeof(int));
printf("Size of float: %zu bytes\n", sizeof(float));
printf("Size of double: %zu bytes\n", sizeof(double));
printf("Size of char: %zu byte\n", sizeof(char));

return
0;
}

22. Formatted Input/Output Functions

• printf(): Used to print formatted output to the console.


• scanf(): Used to read formatted input from the console.

Example:

C
#include <stdio.h>

int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("Your age is %d\n", age);

return 0;
}

23. C Program to Find the Area and Perimeter of a Circle

C
#include <stdio.h>

#define PI 3.14159

int main() {
float radius, area, perimeter;

printf("Enter the radius of the circle: ");


scanf("%f", &radius);

area = PI * radius * radius;


perimeter = 2 * PI * radius;

printf("Area
of the circle = %.2f sq. units\n", area);
printf("Perimeter of the circle = %.2f units\n", perimeter);

return 0;
}

24. C Program to Find the Area and Perimeter of a Rectangle

C
#include <stdio.h>

int main() {
float length, width, area, perimeter;

printf("Enter the length of the rectangle: ");


scanf("%f", &length);

printf("Enter the width of the rectangle: ");


scanf("%f", &width);

area = length * width;


perimeter = 2 * (length + width);

printf("Area of the rectangle = %.2f


sq. units\n", area);
printf("Perimeter of the rectangle = %.2f units\n", perimeter);

return 0;
}

25. C Program to Calculate Simple Interest

C
#include <stdio.h>

int main() {
float principal, rate, time, interest;

printf("Enter the principal amount: ");


scanf("%f", &principal);

printf("Enter the rate of interest: ");


scanf("%f", &rate);

printf("Enter the time period:


");
scanf("%f", &time);

interest = (principal * rate * time) / 100;

printf("Simple interest = %.2f\n", interest);

return 0;
}

26. C Program to Find the Largest of Three Numbers Using Ternary Operator

C
#include <stdio.h>

int main() {
int num1, num2, num3, largest;

printf("Enter three numbers: ");


scanf("%d %d %d", &num1, &num2, &num3);

largest = (num1 > num2) ? (num1 > num3 ? num1 : num3) : (num2 > num3 ? num2 :
num3);

printf("The largest number


is %d\n", largest);

return
0;
}
27. C Program to Display the ASCII Value of a Character

C
#include <stdio.h>

int main() {
char ch;

printf("Enter a character: ");


scanf("%c", &ch);

printf("The ASCII value of %c is %d\n", ch, ch);

return 0;

28. Algorithm, Flowchart, and C Program to Swap Two Numbers Using a Third Variable

Algorithm:

1. Start
2. Input two numbers: num1, num2
3. Declare a temporary variable: temp
4. Assign num1 to temp: temp = num1
5. Assign num2 to num1: num1 = num2
6. Assign temp to num2: num2 = temp
7. Print the swapped numbers: num1, num2
8. End

Flowchart:

Opens in a new window www.youtube.com


flowchart to swap two numbers using a third variable

C Program:

C
#include <stdio.h>

int main() {
int num1, num2, temp;

printf("Enter two numbers: ");


scanf("%d %d", &num1, &num2);
printf("Before swapping: num1 = %d, num2 = %d\n", num1, num2);

temp = num1;
num1 = num2;
num2 = temp;

printf("After swapping: num1 = %d, num2 = %d\n", num1, num2);

return
0;
}

29. Local and Global Variables

• Local Variables: Declared within a function or block of code. They are only accessible within that
specific scope.
• Global Variables: Declared outside of any function. They are accessible from any part of the
program.

Example:

C
#include <stdio.h>

int global_var = 10; // Global variable

int main() {
int local_var = 20; // Local variable

printf("Global variable: %d\n", global_var);


printf("Local variable: %d\n", local_var);

return 0;
}

30. Scope and Lifetime of Variables

• Scope: The region of the program where a variable is accessible.


• Lifetime: The duration for which a variable exists in memory.

For local variables:

• Scope: Within the function or block where they are declared.


• Lifetime: From the point of declaration to the end of the block.

For global variables:

• Scope: Throughout the entire program.


• Lifetime: From the point of declaration to the end of the program.

31. Storage Classes

Storage classes determine the scope and lifetime of variables. The main storage classes in C are:

• auto: Default storage class for local variables.


• static: Used to declare static variables, which retain their values between function calls.
• extern: Used to declare global variables that are accessible from other files.
• register: Used to suggest to the compiler to store variables in registers for faster access.

32. Mixed Mode Assignment

Mixed mode assignment involves assigning a value of one data type to a variable of another data type. The
compiler performs implicit type conversion in many cases. However, it's important to be aware of potential
loss of precision or unexpected behavior.

Example:

C
int x = 10;
float y = 3.14;

x = y; // Implicit conversion from float to int, losing decimal part

33. Differentiations

Syntax & Semantics


Feature Syntax Semantics
The meaning and interpretation
Definition The rules that govern the structure of a language.
of language constructs.
Focus Form Meaning
Understanding the meaning of
Example Correct punctuation and capitalization.
a sentence.
Role in Ensures code does what it is
Ensures code is written correctly.
Programming intended to do.
Without correct syntax, code will not compile. Without
Importance correct semantics, code may not produce the desired
results.
Export to Sheets

b) Input Devices vs. Output Devices


Feature Input Devices Output Devices
Purpose To input data into a computer. To output data from a computer.
Examples Keyboard, mouse, scanner, microphone. Monitor, printer, speaker, projector.
Interaction User provides input. Computer displays or produces output.
Role in Essential for user interaction with the Essential for displaying results and
Computing computer. information.
Many different types, each with a specific Many different types, each with a specific
Types
purpose. purpose.
Export to Sheets

c) Compiler vs. Interpreter


Feature Compiler Interpreter
Translates entire source code into machine Executes source code line by line without
Process
code before execution. creating an executable file.
Speed Generally faster execution. Generally slower execution.
Output Executable file. No executable file.
Error
Identifies errors before execution. Identifies errors during execution.
Handling
Examples C, C++, Java. Python, JavaScript, Ruby.
Export to Sheets

d) Assembler vs. Compiler


Feature Assembler Compiler
Input Language Assembly language. High-level language.
Output Language Machine code. Machine code.
Level of Abstraction Low-level. High-level.
Complexity More complex to use. Less complex to use.
Portability Less portable. More portable.
Export to Sheets

e) High-Level Language vs. Low-Level Language


Feature High-Level Language Low-Level Language
Readability More readable. Less readable.
Abstraction High level of abstraction. Low level of abstraction.
Portability More portable. Less portable.
Examples Python, Java, C++. Assembly language, machine code.
Complexity Easier to learn and use. More difficult to learn and use.
Export to Sheets

f) Flowchart vs. Algorithm


Feature Flowchart Algorithm
Format Visual representation. Textual representation.
Focus Process flow. Step-by-step instructions.
Clarity Can be easier to understand visually. Can be more precise and detailed.
Creation Requires drawing tools. Can be written in plain text.
Use Cases Planning and design. Implementation and documentation.
Export to Sheets

g) Pseudocode vs. Algorithm


Feature Pseudocode Algorithm
Format Natural language and programming constructs. More formal and structured.
Level of Detail Less detailed. More detailed.
Purpose High-level planning. Detailed implementation.
Clarity Can be easier to understand for non-programmers. More precise and unambiguous.
Use Cases Early stages of design. Later stages of development.
Export to Sheets

h) Variables vs. Constants


Feature Variable Constant
A named storage location that can hold a
A named storage location that holds a fixed value
Definition value that can change during program
that cannot change during program execution.
execution.
Keyword var, let (in some languages). const (in many languages).
Mutability Mutable. Immutable.
Storing input values, intermediate Storing fixed values like mathematical constants,
Use Cases
calculations, and results. configuration settings, and default values.
Example age, price, name. PI, MAX_VALUE, DEFAULT_COLOR.
Export to Sheets

i) System Software vs. Application Software


Feature System Software Application Software
Manages hardware and
Purpose Performs specific tasks for users.
resources.
Operating systems, device
Examples Word processors, web browsers, games.
drivers, utilities.
Directly interacts with
Interaction Interacts with system software and user.
hardware.
Role in Essential for basic computer
Provides functionality for specific tasks.
Computing operations.
Requires knowledge of Requires knowledge of programming languages and
Development
system architecture. application development frameworks.
Export to Sheets

j) Global Variable vs. Local Variable


Feature Global Variable Local Variable
Accessible only within the function or block
Scope Accessible from anywhere in the program.
where it is declared.
Exists only during the execution of the
Lifetime Exists throughout the program's execution.
function or block.
Can be modified from anywhere, potentially
Impact Less likely to cause unintended side effects.
leading to unintended side effects.
Best Use sparingly, as overuse can make code harder Use more frequently, as they promote
Practices to understand and maintain. modularity and code organization.
Example A variable declared outside of any function. A variable declared inside a function.

34. Solving Expressions

$a. x = a-b/3+c*2-1, where, a = 9, b =12, and c=3.$


x=9−12/3+3∗2−1 x=9−4+6−1 x=10

$b. 10-3%8+6/4$

10−3 10−3+1+1 9

$c. 17-8/4*2+3- ++a$

a=2 17−8/4∗2+3−++a 17−2∗2+3−3 17−4+3−3 13

$d. 3*(2*x + 1)/x, where x=3.$

3∗(2∗3+1)/3 3∗7/3 7

$e. What is the output of the following code?$

C
#include <stdio.h>
#include <stdio.h>
void main() {
int x, a, b, c;
a = 2;
b = 4;
c = 5;
x = a-- + b++ - ++c;
printf("x: %d",x);
getch();
}

x=a−−+b++−++c x=2+4−6 x=0

$`f. What is the output of the following: #include <stdio.h> #include <stdio.h> int a=30; // global variable
void main() { int b; // local variable
printf("Value of a : %d",a); a=10, b=20; printf("Value of a : %d",a); printf("Value of b : %d",b); getch(); }

<span class="math-inline">Value of a \: 30</span>


<span class="math-inline">Value of a \: 10</span>
<span class="math-inline">Value of b \: 20</span>

$`g. What is the output of the following:


#include <stdio.h>
#include <stdio.h>
void main() {
const int a=10;
printf("%d",a);
a=20;
getch();
}

This code will produce a compilation error because you are trying to assign a new value to a constant
variable.

34. Solving Expressions


a. x = a-b/3+c*2-1, where, a = 9, b =12, and c=3.
x = 9 - 12/3 + 3*2 - 1
= 9 - 4 + 6 - 1
= 10
b. 10-3%8+6/4
= 10 - 3 + 1.5
= 8.5

c. 17-8/4*2+3- ++a

Assuming a is initially 0:

= 17 - 2 * 2 + 3 - 1 (because ++a increments a before using it)


= 17 - 4 + 3 - 1
= 15

d. 3*(2*x + 1)/x, where x=3.


= 3 * (2*3 + 1) / 3
= 3 * 7 / 3
= 7

e. Output of the code:

C
#include <stdio.h>
#include <stdio.h>
void main() {
int x, a, b, c;
a = 2;
b = 4;
c = 5;
x = a-- + b++ - ++c;
printf("x: %d",x);
getch();
}

Output: x: 0

Explanation:

1. a-- is 2, and a becomes 1.


2. b++ is 4, and b becomes 5.
3. ++c is 6, and c becomes 6.
4. x = 2 + 4 - 6 = 0

f. Output of the code:

C
#include <stdio.h>
#include <stdio.h>
int a=30; // global variable
void main() {
int b; // local variable
printf("Value of a : %d",a);
a=10, b=20;
printf("Value of a : %d",a);
printf("Value of b : %d",b);
getch();
}

Output:
Value of a : 30
Value of a : 10
Value of b : 20

g. Output of the code:

C
#include <stdio.h>
#include <stdio.h>
void main() {
const int a=10;
printf("%d",a);
a=20;
getch();
}

This code will result in a compilation error because you cannot modify the value of a const variable.

You might also like