Skip to study material
CodeBhavya

Programming for Problem Solving

AR25 · I Year I Semester · 2025–2026 · Unit I: Logic Building

← Unit I question index

Marks are suggested practice allocations for short and detailed answers.

QUESTION 01 · Program development

Define a programming language and name two language levels.

2 marks

Answer

A programming language provides symbols and rules for expressing instructions to a computer.

  • Machine language represents instructions the processor can execute.
  • High-level languages, such as C, express operations using readable statements.

QUESTION 02 · Program development

What is a programming language? Compare machine, assembly and high-level languages.

5 marks

Answer in brief

A programming language is a set of words, symbols and rules used to write instructions for a computer.

Types of programming languages

  1. Machine language: Instructions are written as machine codes, usually shown using 0s and 1s. The processor can execute the correct machine code directly. It is difficult for people to read and write.
  2. Assembly language: Short names such as ADD are used instead of binary instructions. An assembler converts assembly code into machine code. The instructions depend on the processor.
  3. High-level language: Instructions are written using readable words and expressions. Examples include C and Python. A suitable translator is needed before or during execution.

Example

To add two numbers in C, we can write total = a + b;. The compiler translates the C instructions for the selected computer. We do not need to write the processor’s binary instructions ourselves. The translated code may contain several machine instructions.

Advantages of high-level languages

  1. Easy to read: Meaningful names and familiar expressions make programs easier to understand.
  2. Easy to maintain: A programmer can find and change the required part more easily.
  3. Better portability: The same source can often be used on different computers when suitable compilers and libraries are available.

Compiler and interpreter

A compiler translates a program into another form before the translated program runs. An interpreter carries out instructions through another program. These are ways of implementing a language. C programs are commonly compiled. A language and a compiler are different: C is a language, while GCC is one compiler that supports it.

Reference tables

↔ Scroll horizontally on a small screen
Levels of programming languages
LevelHow instructions are writtenTranslation and use
Machine languageEncoded processor instructions, commonly represented as binary or hexadecimalExecuted by the matching processor; difficult for people to maintain.
Assembly languageMnemonic instructions such as ADD, with symbolic labelsAn assembler produces machine code for a particular architecture.
High-level languageExpressions, functions and control structures close to human reasoningA compiler or interpreter implements the language. C source is commonly compiled.
↔ Scroll horizontally on a small screen
Translation methods
MethodTypical behaviourWhat to remember
CompilationTranslates a source program into another representation before the resulting program runs.C implementations commonly compile source to native code.
InterpretationExecutes a representation of the program through another program.A language may have more than one implementation strategy.

Key points

  • Machine code is processor-specific.
  • An assembler translates assembly; a compiler can translate C.

QUESTION 03 · Program development

List any four stages of program development.

2 marks

Answer

Four stages are problem analysis, solution design, implementation and testing.

  • Analysis identifies the input, output and limits; design plans the steps.
  • Coding writes the code; testing compares actual output with expected results.

QUESTION 04 · Program development

Explain the stages of program development with an example.

5 marks

Answer in brief

Program development is the process of understanding a problem, planning its solution, writing the program, testing it and maintaining it.

Stages of program development

  1. Problem analysis: Understand what the program must do. Identify the inputs, outputs and limits on the input values.
  2. Solution design: Prepare an algorithm, pseudocode or flowchart. Choose the steps needed to solve the problem.
  3. Coding: Write the planned solution in a programming language such as C. Use suitable variables, operators and statements.
  4. Compilation: Translate the source program. Read the compiler messages and correct syntax mistakes.
  5. Testing and debugging: Run the program with different inputs. Compare its output with the expected result. Find and correct the causes of wrong results.
  6. Documentation and maintenance: Write useful notes about the program. Update it when requirements change or a mistake is found.

Example: average of three marks

Inputs: three marks. Output: their average. First add the marks, then divide the total by 3.0. In C, using 3.0 allows a fractional result when the total is an integer. For marks 60, 75 and 90, the total is 225 and the average is 75.

Testing

Try ordinary values, boundary values and invalid values. If marks must be between 0 and 100, the program should check that rule. Testing finds a failure; debugging finds and fixes its cause. If a change introduces another mistake, test the corrected program again. Successful compilation alone does not prove that the answer is correct.

Reference table

↔ Scroll horizontally on a small screen
Tests for an average-of-three program
CaseInputExpected behaviour
Normal60, 75, 90Average = 75.0
Boundary0, 0, 0Average = 0.0
Fractional result1, 2, 2Approximately 1.6667, not 1
InvalidA mark outside the agreed rangeReject according to the stated requirement.

Diagram or flowchart

Requirements lead to design, implementation, testing and maintenance; failed tests return to implementation.
Program development cycle · Download diagram

Key points

  • State requirements before choosing code.
  • Include boundary tests and an expected result.

QUESTION 05 · Program development

What are compilation and linking?

2 marks

Answer

Compilation checks and translates C source code. Linking combines object files and required library code to make an executable program.

  • The compiler reports errors in the source that it detects.
  • The linker connects references to functions and other code needed by the program.

QUESTION 06 · Program development

How do you create, compile and run a C program? Explain the translation stages.

5 marks

Answer in brief

A C program is created by writing source code, translating it, linking the required code and running the resulting executable file.

Steps to create and run a program

  1. Write the source: Use an editor to write valid C code. Save the file with the .c extension, such as hello.c.
  2. Preprocess: The preprocessor handles instructions such as #include and #define. Header information and macro replacements are prepared.
  3. Compile: The compiler checks the C code and translates it for the selected target. Correct the reported errors.
  4. Assemble: In a usual toolchain, assembly instructions are converted into object code. Some implementations combine these stages.
  5. Link: The linker combines the object files and required library code. It produces an executable program.
  6. Run: The operating system loads the executable. In a hosted C program, execution starts at main.

Object code and executable code

An object file contains translated code, but it may still need code from other files or libraries. An executable is the linked program prepared for the target environment. A successful compilation can still be followed by a linking error, for example when a required function definition is missing.

Types of errors

  1. Syntax error: The code breaks a language rule, such as a missing semicolon. The compiler reports the problem.
  2. Link error: The linker cannot find a required definition or compiled component.
  3. Runtime failure: A problem occurs while the program is running, such as an invalid memory access.
  4. Logical error: The program runs but uses the wrong steps or formula. For example, it subtracts marks instead of adding them.

Compile and run commands

With GCC installed, use the command below. On Linux or macOS, run ./hello. In Windows PowerShell, create hello.exe and run .\hello.exe. Read warnings as well as errors.

gcc -std=c11 -Wall -Wextra -pedantic hello.c -o hello

Reference tables

↔ Scroll horizontally on a small screen
Typical C toolchain stages
StagePurpose
PreprocessingHandles directives such as #include and macro replacement.
CompilationChecks and translates C constructs, commonly into assembly or an intermediate representation.
AssemblyProduces object code from assembly.
LinkingCombines object files and needed library components; resolves external references.
Loading and executionThe operating system prepares the executable to run.
↔ Scroll horizontally on a small screen
Development errors
KindExampleNext action
Syntax or constraint violationA missing semicolon or incompatible declaration.Read the diagnostic and inspect the indicated source region.
Link errorCalling a declared function whose definition is missing.Check the source/object files and libraries supplied to the linker.
Runtime failureAn invalid operation reached during execution.Trace the triggering input and check bounds and preconditions.
Logical errorUsing multiplication instead of addition in a total.Compare the algorithm and actual result with the requirement.

Diagram or flowchart

Source is preprocessed, compiled, assembled and linked to form an executable; the operating system loads it to run.
From source file to running program · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    puts("Hello, CodeBhavya!");
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

Hello, CodeBhavya!

Key points

  • A .c file is source, not a native executable.
  • Warnings deserve attention even when an executable is produced.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • March/April 2023 · Q2(a) · 5 marks

    Write a detailed note on creating and running a program.

    Paper P02 · page 1
  • March/April 2023 · Q1(b) · 1 marks

    What is a syntax error?

    Paper P05 · page 1
  • September 2023 · Q1(a) · 1 marks

    What is a compiler?

    Paper P06 · page 1
View all matching exam references →

QUESTION 07 · Logic building

State any two essential properties of an algorithm.

2 marks

Answer

Definiteness and finiteness are two essential algorithm properties.

  • Definiteness: each step has a clear meaning.
  • Finiteness: the procedure stops after a finite number of steps for every permitted input.

QUESTION 08 · Logic building

Define an algorithm and explain its essential properties.

5 marks

Answer in brief

An algorithm is a finite sequence of clear steps used to solve a problem.

Essential properties

  1. Input: The values needed by the algorithm must be clearly stated. Some algorithms may need no external input.
  2. Output: The result to be produced must be clearly stated.
  3. Definiteness: Every step must be clear. A person following it should not have to guess what to do.
  4. Finiteness: The algorithm must finish after a finite number of steps for every allowed input.
  5. Effectiveness: Each step must be simple enough to carry out using the available operations.

Example: largest of three numbers

Read a, b and c. Set maximum = a. If b is larger than maximum, replace maximum with b. Then compare c with maximum and replace it if needed. Display maximum. For 4, 9 and 2, the result is 9. Each step has a clear action, and the algorithm finishes after two comparisons.

Correctness

An algorithm must give the required result for every allowed input. Check negative numbers and equal values as well as an ordinary example. An algorithm can have clear steps and still use a wrong formula, so clarity alone does not prove correctness.

Time and space complexity

Time complexity describes how the number of operations grows as the input size grows. Space complexity describes the memory needed. Big O is used to describe an upper growth limit. Comparing exactly three numbers takes constant work, O(1). Checking n values one by one takes O(n) time. The best case is the input of a given size that needs the least work; the worst case needs the most work.

Reference table

↔ Scroll horizontally on a small screen
Properties of an algorithm
PropertyMeaningExample for finding a maximum
InputThe permitted starting data is specified.Three comparable numbers.
OutputThe result is specified.Their maximum value.
DefinitenessEach step has an unambiguous meaning.Compare b with the current maximum.
FinitenessThe procedure terminates for every permitted input.Only a fixed number of comparisons is needed.
EffectivenessEach step is basic enough to perform.Assignment and comparison are executable operations.

Key points

  • State the permitted input domain.
  • Finiteness is about termination, not about a particular programming language.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • March/April 2023 · Q1(i) · 2 marks

    What do you mean by time complexity?

    Paper P02 · page 1
  • March/April 2023 · Q1(j) · 3 marks

    Define best-case performance of an algorithm.

    Paper P02 · page 1
  • March/April 2023 · Q11(b) · 2 marks

    What is time complexity?

    Paper P05 · page 2
View all matching exam references →

QUESTION 09 · Logic building

Give two benefits of writing an algorithm before coding.

2 marks

Answer

An algorithm helps plan and review a solution before dealing with programming syntax.

  • It separates the problem-solving steps from a particular language.
  • It makes missing cases or incorrect decisions easier to discuss and trace.

QUESTION 10 · Logic building

Explain the advantages and limitations of algorithms.

5 marks

Answer in brief

An algorithm helps us plan a solution step by step before writing a program. It has several advantages and some limitations.

Advantages of algorithms

  1. Easy to understand: The solution is written as simple, ordered steps. A student can follow one step at a time.
  2. Helps before coding: We can decide the inputs, calculations and output before writing C statements. This reduces confusion while coding.
  3. Independent of a programming language: The same solution can be implemented in C, Python or another language. The syntax changes, but the main steps can remain the same.
  4. Helps find mistakes: We can follow the steps with sample values and check the result. Missing steps and incorrect conditions can be found before coding.
  5. Makes coding easier: Once the steps are clear, each step can be converted into suitable program statements.

Limitations of algorithms

  1. Takes time to prepare: A detailed solution needs careful planning, especially for a large problem.
  2. Can become lengthy: A large problem may need many steps. A long description can become difficult to follow.
  3. Has no single writing format: Different people may describe the same steps differently. The wording must still be clear.
  4. Does not show paths visually: Choices and repeated steps may be easier to see in a flowchart.
  5. Cannot be executed directly: An algorithm written in ordinary language must be converted into a program before the computer can run that program.

Simple example

To add two numbers: read the two values, add them and display the sum. For inputs 8 and 5, the result is 13. These steps can be understood before writing any C code. They can also be used to write a program in another language. The algorithm is useful for planning, but the computer still needs an implementation to execute.

READ a, b
sum ← a + b
OUTPUT sum

Key points

  • Algorithms support reasoning before implementation.
  • Choose enough detail that another person can follow the steps.

QUESTION 11 · Logic building

Which flowchart symbols represent input/output and decisions?

2 marks

Answer

A parallelogram represents input/output; a diamond represents a decision.

  • Label an input/output symbol with an action such as Read n or Print result.
  • Write a condition in a decision diamond and label its outgoing branches, such as Yes and No.

QUESTION 12 · Logic building

What is a flowchart? Explain the standard symbols and drawing guidelines.

5 marks

Answer in brief

A flowchart is a diagram that shows the steps of an algorithm using symbols connected by arrows.

Main flowchart symbols

  1. Start/End: A rounded terminal shows where the algorithm begins or finishes.
  2. Input/Output: A parallelogram shows reading input or displaying a result.
  3. Process: A rectangle shows a calculation or assignment, such as sum = a + b.
  4. Decision: A diamond contains a condition. Its branches are labelled Yes/No or True/False.
  5. Flow line: An arrow shows which step is followed next.
  6. Connector: A small labelled connector joins parts of a chart when a long arrow would make it difficult to read.

Example: even or odd

Start by reading n. Test n % 2 == 0 in a decision diamond. If the answer is Yes, print Even. If it is No, print Odd. Both paths then reach End. For n = 8, the Yes path is followed. For n = 7, the No path is followed.

Advantages

A flowchart makes the order of steps easy to see. It is useful for explaining choices and loops. It also helps us follow the solution using sample values before writing the program.

Drawing rules

  1. Use clear labels: Keep the text inside a symbol short and meaningful.
  2. Label each branch: A decision must show which arrow is followed for each result.
  3. Use arrowheads: The direction of execution must be clear.
  4. Check every path: Make sure the steps reach a valid result or continue through a clearly shown loop.
  5. Avoid crowding: Large flowcharts should be divided into smaller, understandable parts.

Reference table

↔ Scroll horizontally on a small screen
Flowchart symbols
SymbolPurposeExample label
Rounded terminalStart or end of the procedureStart; End
ParallelogramInput or outputRead a, b; Print total
RectangleProcessing or assignmenttotal ← a + b
DiamondA condition with labelled outcomesa > b? Yes / No
ArrowDirection of control flowConnects one step to its possible successor.
Small labelled connectorContinues a path without a long crossing lineMatching labels connect the same path.

Diagram or flowchart

Rounded terminal for start or end, parallelogram for input or output, rectangle for processing, diamond for a decision, and arrows for control flow.
Basic flowchart symbols · Download diagram

Key points

  • A decision chooses a path; a process changes or computes a value.
  • Every arrow must have a meaningful destination.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • March/April 2023 · Q1(a) · 2 marks

    Define a flowchart.

    Paper P02 · page 1
  • March/April 2023 · Q2(b) · 5 marks

    What is a flowchart? Give its symbols and shapes.

    Paper P07 · page 1
  • January/February 2024 · Q3(a) · 4 marks

    What is a flowchart? Explain how it represents algorithms.

    Paper P10 · page 1
View all matching exam references →

QUESTION 13 · Logic building

Define pseudocode and state one advantage.

2 marks

Answer

Pseudocode describes the steps of a solution using simple statements without following the exact syntax of a programming language.

  • It can use words such as READ, IF and PRINT.
  • It helps us check the steps before writing C code.

QUESTION 14 · Logic building

What is pseudocode? Explain its conventions with an example.

5 marks

Answer in brief

Pseudocode is a way of writing an algorithm using simple words and structured statements, without following all the syntax rules of a programming language.

Common statements

  1. READ: Accept an input value. Example: READ number.
  2. Assignment: Store a value. Example: total ← 0. The arrow means assignment in this notation.
  3. IF and ELSE: Choose between actions based on a condition.
  4. WHILE or REPEAT: Carry out a group of steps repeatedly.
  5. OUTPUT: Display the required result.

Example: larger of two numbers

READ a, b
IF a >= b THEN
    larger ← a
ELSE
    larger ← b
END IF
OUTPUT larger

For a = 8 and b = 5, the condition is true and larger becomes 8. If both inputs are 8, choosing either one gives the correct largest value.

Advantages of pseudocode

  1. Easy to read: The writer can focus on the solution instead of semicolons and header files.
  2. Easy to change: Steps can be added or corrected before coding.
  3. Useful for coding: The structured steps can later be converted into C statements.

Writing rules

Write one clear action at a time. Indent statements that belong to a condition or loop. State how a loop ends and whether a boundary is included. Use the same notation throughout. Pseudocode has no single compulsory syntax, but another reader must be able to follow it. It is not a C program and cannot normally be compiled as C without conversion.

Key points

  • Pseudocode communicates logic rather than compilable syntax.
  • Indentation and explicit end markers clarify structure.

QUESTION 15 · Logic building

State two differences between a flowchart and pseudocode.

2 marks

Answer

A flowchart represents logic using a diagram, while pseudocode describes it as structured text.

  • A flowchart uses symbols and arrows; pseudocode uses statements and indentation.
  • A flowchart makes paths visible; pseudocode is usually easier to edit for longer procedures.

QUESTION 16 · Logic building

Differentiate an algorithm, a flowchart and pseudocode.

5 marks

Answer in brief

An algorithm is the step-by-step solution to a problem. A flowchart and pseudocode are two ways of presenting that solution.

Algorithm

An algorithm is usually written as numbered steps. It states what input is needed, what actions must be performed and what result must be produced. It is useful for explaining a short solution in ordinary language.

Flowchart

A flowchart presents the steps as a diagram. Rectangles show processing, diamonds show decisions and arrows show the direction of execution. It is useful when we need to see different choices or repeated paths. Large charts can be difficult to draw and change.

Pseudocode

Pseudocode uses structured text such as READ, IF, WHILE and OUTPUT. It is useful for writing longer logic before choosing the exact C syntax. It is generally easier to edit than a large diagram.

Example: sum of two numbers

The algorithm says: read two numbers, add them and display the sum. Pseudocode writes the same actions using named variables. The flowchart uses Start, input, process, output and End symbols. All three must describe the same calculation.

READ a, b
sum ← a + b
OUTPUT sum

Important difference

The solution itself does not change when its presentation changes. For example, a condition must not become its opposite when it is copied from pseudocode to a flowchart. Check that the starting values, conditions and output agree in every version. None of these ordinary descriptions is automatically an executable C program.

Reference table

↔ Scroll horizontally on a small screen
Three ways to discuss a solution
AspectAlgorithm as numbered stepsFlowchartPseudocode
FormA sequence of precisely written stepsConnected graphical symbolsIndented, structured text
StrengthEasy to introduce in ordinary languageMakes branches and loops visibleScales well to detailed structured logic
EditingSimple for short descriptionsLayout may need rearrangingUsually easy to revise
ExecutionNot directly executableNot directly executableNot directly executable
CorrectnessDepends on the logicDepends on the same logicDepends on the same logic

Key points

  • The algorithm is the logic, rather than a particular drawing format.
  • Different representations must agree on decisions and results.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • January/February 2024 · Q2(b) · 5 marks

    Discuss the importance of flowcharts and pseudocode in designing algorithms.

    Paper P08 · page 1
View all matching exam references →

QUESTION 17 · Worked algorithms

How can the maximum of three values be found using two comparisons?

2 marks

Answer

Set maximum to the first value, then compare the other two values with it in turn.

  • If b > maximum, replace maximum with b.
  • If c > maximum, replace maximum with c. This also handles negative values and ties.

QUESTION 18 · Worked algorithms

Develop an algorithm, pseudocode and flowchart to find the maximum of three numbers.

5 marks

Answer in brief

The maximum of three numbers can be found by keeping the largest value seen so far.

Algorithm

  1. Read the values: Accept a, b and c.
  2. Start with the first value: Set maximum = a.
  3. Compare the second value: If b > maximum, set maximum = b.
  4. Compare the third value: If c > maximum, set maximum = c.
  5. Display the result: The value in maximum is the largest of the three.

Explanation

After the first assignment, maximum contains a. After comparing b, it contains the larger of a and b. After comparing c, it contains the largest of all three. A replacement is needed only when the new value is larger. Equal values do not cause a problem because the question asks for the maximum value.

Example

For a = −4, b = 9 and c = 9, maximum first contains −4. The comparison with b changes it to 9. Since c is not greater than 9, the last comparison leaves it unchanged. The output is 9.

Special cases

The method also works when all values are negative or all are equal. Do not start maximum at zero unless the input rules justify that choice. For inputs −9, −4 and −12, zero would be an incorrect answer. Starting from the first actual value avoids that mistake.

Time and space complexity

The method uses exactly two comparisons, regardless of the input values. Therefore its time complexity is O(1). It uses a fixed number of variables, so its extra space is also O(1). Finding the maximum of n values is a different problem that requires a repeated scan.

Reference tables

↔ Scroll horizontally on a small screen
Trace for -4, 9, 9
StepConditionmaximum
InitialNot yet compared-4
Compare b9 > -4 is true9
Compare c9 > 9 is false9
↔ Scroll horizontally on a small screen
Maximum boundary cases
InputsExpected maximumReason to test
-9, -4, -12-4Detects an incorrect zero initialisation.
6, 6, 26Checks a tied maximum.
3, 3, 33Checks complete equality.
9, 2, 19Checks that the initial candidate can remain unchanged.

Diagram or flowchart

Read a, b, c; set maximum to a; compare b and then c with maximum, replacing it when larger; print maximum and end.
Maximum of three values · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int a = -4, b = 9, c = 9;
    int maximum = a;
    if (b > maximum) { maximum = b; }
    if (c > maximum) { maximum = c; }
    printf("Maximum = %d\n", maximum);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

Maximum = 9

Key points

  • Keep the maximum seen so far.
  • A strict comparison still works when the maximum occurs twice.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • March/April 2023 · Q3(b) · 5 marks

    What is an algorithm? Write an algorithm to find the largest of three numbers.

    Paper P02 · page 1
View all matching exam references →

QUESTION 19 · Worked algorithms

Why is a temporary variable used when swapping two values?

2 marks

Answer

A temporary variable saves the first value before its variable is given a new value.

  • Perform temporary = a; then a = b;.
  • Finish with b = temporary;. Without saving it first, the original value of a would be lost.

QUESTION 20 · Worked algorithms

Develop an algorithm and C program to swap two values using a temporary variable.

5 marks

Answer in brief

Swapping means exchanging the values of two variables. A temporary variable holds one value while the exchange takes place.

Algorithm

  1. Save the first value: Set temporary = a.
  2. Replace the first value: Set a = b.
  3. Restore the saved value: Set b = temporary.
  4. Display a and b: They now contain the exchanged values.

Explanation with an example

Suppose a = 12 and b = −5. First, temporary receives 12. Next, a receives −5. Finally, b receives the saved 12. The final values are a = −5 and b = 12. After the second statement, both a and b briefly contain −5, but the old value 12 is still safe in temporary.

Need for the temporary variable

If we first write a = b, the old value of a is overwritten. We cannot copy it into b afterward unless it was saved. The temporary variable prevents this loss. Assignment copies a value; it does not permanently connect the variables. Changing a later does not automatically change temporary.

Important points

Use a temporary variable of a suitable type. The same three steps work for negative values and equal values. This method is clearer than addition-and-subtraction swapping, which may overflow during an intermediate calculation. If a swap is placed inside a function, additional care is needed to change the caller’s variables; ordinary value parameters are copies.

Time and space complexity

There are three assignments and one extra temporary variable. These do not grow with the input values, so time and extra space are both O(1).

Reference table

↔ Scroll horizontally on a small screen
State during the swap
After statementabtemporary
temporary = a12-512
a = b-5-512
b = temporary-51212

Diagram or flowchart

Save a in temporary, assign b to a, then assign temporary to b; finally print the swapped values.
Swapping with a temporary variable · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int a = 12, b = -5;
    int temporary = a;
    a = b;
    b = temporary;
    printf("a = %d, b = %d\n", a, b);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

a = -5, b = 12

Key points

  • Save a value before overwriting it.
  • The temporary variable should have a compatible type.

QUESTION 21 · Worked algorithms

Define factorial and state the values of 0! and 5!.

2 marks

Answer

For a non-negative integer n, n! is the product from 1 through n; 0! is defined as 1.

  • 0! = 1.
  • 5! = 5 × 4 × 3 × 2 × 1 = 120.

QUESTION 22 · Worked algorithms

Develop an algorithm and flowchart to calculate the factorial of a non-negative integer.

5 marks

Answer in brief

The factorial of a non-negative integer n is the product of the integers from 1 to n. It is written as n!. By definition, 0! = 1.

Algorithm

  1. Read n: Use an integer in the supported range.
  2. Initialise the product: Set factorial = 1 and i = 2.
  3. Multiply: While i <= n, set factorial = factorial × i.
  4. Move to the next factor: Increase i by 1 and repeat the test.
  5. Display factorial: It contains the required product.

Example: 5!

For n = 5, the product starts at 1. Multiplying by 2 gives 2; multiplying by 3 gives 6; multiplying by 4 gives 24; multiplying by 5 gives 120. Thus 5! = 120. Each loop step adds one required factor to the product.

Initial value and boundary cases

The product must start at 1, not 0. A product that starts at zero stays zero after every multiplication. When n is 0 or 1, the loop is not entered and the answer remains 1. Negative inputs are rejected because they are outside this elementary factorial definition.

Range of the program

Factorials grow quickly. The example accepts only 0 through 20 and uses unsigned long long. This type has enough guaranteed range for 20!, but not for every factorial. A larger input needs an overflow check or a different way to store large numbers.

Time and space complexity

The repeated multiplication takes O(n) time in the usual analysis, because the number of loop steps grows with n. Only a few variables are used, so extra space is O(1). The supplied fixed-width program restricts the input to avoid overflow.

Diagram or flowchart

For n from 0 to 20, initialise result to 1 and i to 2; multiply while i is at most n, otherwise print the result. Unsupported n is rejected.
Factorial with a loop · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int n;
    unsigned long long factorial = 1;
    if (scanf("%d", &n) != 1 || n < 0 || n > 20) {
        puts("Unsupported input");
        return 1;
    }
    for (int i = 2; i <= n; ++i) {
        factorial *= (unsigned long long)i;
    }
    printf("%d! = %llu\n", n, factorial);
    return 0;
}

Sample input and output

Input

5

Output

5! = 120

Key points

  • 0! is 1.
  • Check the numeric range before multiplying.

QUESTION 23 · Worked algorithms

Define a prime number. Is 1 prime?

2 marks

Answer

A prime is an integer greater than 1 whose only positive divisors are 1 and itself.

  • 1 is not prime because it does not have two distinct positive divisors.
  • 2 is the smallest prime: its positive divisors are 1 and 2.

QUESTION 24 · Worked algorithms

Develop a correct algorithm and flowchart to test whether an integer is prime.

5 marks

Answer in brief

A prime number is an integer greater than 1 whose only positive divisors are 1 and itself.

Algorithm

  1. Handle small inputs: If n < 2, report Not prime.
  2. Start testing: Set divisor = 2.
  3. Test possible divisors: Continue while divisor <= n / divisor.
  4. Check the remainder: If n % divisor == 0, report Not prime and stop.
  5. Increase divisor: If it does not divide n, test the next integer.
  6. Report Prime: If the tests finish without finding a divisor, n is prime.

Reason for the square-root limit

If n has a factor pair a × b = n, at least one factor is not greater than √n. Otherwise their product would be greater than n. So it is enough to look for a divisor up to and including √n. The program uses divisor <= n / divisor instead of multiplying divisor by itself, to avoid a possible multiplication overflow.

Examples

For n = 29, the values 2, 3, 4 and 5 do not divide it. The number is prime. For n = 49, divisor 7 gives a zero remainder, so 49 is not prime. The boundary must include 7. The values 0 and 1 are not prime, while 2 is prime.

Common mistakes

Testing only divisibility by 2 misses odd composite numbers such as 9 and 25. Stopping before the square-root boundary misses perfect squares such as 49. Also, do not count divisors only up to n/2 and then expect two divisors; that mixes two different methods.

Time and space complexity

In the worst case, about √n possible divisors are checked. Hence time is O(√n), where n is the number being tested. A fixed number of variables is used, so extra space is O(1).

Reference table

↔ Scroll horizontally on a small screen
Important prime-check cases
nKey observationResult
1Below the minimum primeNot prime
2No divisor needs to be testedPrime
4Remainder for divisor 2 is zeroNot prime
49Divisor 7 must be included at the boundaryNot prime
29No divisor from 2 through 5 divides itPrime

Diagram or flowchart

Reject numbers below two, then test divisors starting at two while divisor is at most n divided by divisor. A zero remainder means not prime; exhausting the loop means prime.
Prime checking with a square-root boundary · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int n;
    if (scanf("%d", &n) != 1) {
        puts("Invalid input");
        return 1;
    }
    if (n < 2) {
        puts("Not prime");
        return 0;
    }
    for (int divisor = 2; divisor <= n / divisor; ++divisor) {
        if (n % divisor == 0) {
            puts("Not prime");
            return 0;
        }
    }
    puts("Prime");
    return 0;
}

Sample input and output

Input

49

Output

Not prime

Key points

  • Numbers below 2 are not prime.
  • The square-root boundary is inclusive.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • June 2022 · Q2(a) · 7 marks

    Write a C program to check whether a given number is prime.

    Paper P03 · page 1
View all matching exam references →

QUESTION 25 · Worked algorithms

What does the discriminant tell us about quadratic roots?

2 marks

Answer

For a non-zero leading coefficient, D = b² − 4ac classifies the roots.

  • D > 0: two distinct real roots; D = 0: a repeated real root.
  • D < 0: a complex conjugate pair.

QUESTION 26 · Worked algorithms

Develop an algorithm and flowchart to find the roots of a quadratic equation.

5 marks

Answer in brief

For the equation ax² + bx + c = 0, where a is not zero, the roots are found using the discriminant D = b² − 4ac.

Types of roots

  1. D > 0: There are two different real roots: (−b + √D)/(2a) and (−b − √D)/(2a).
  2. D = 0: There is one repeated real root: −b/(2a).
  3. D < 0: There are two complex roots. Their real part is −b/(2a), and their imaginary magnitude is √(−D)/|2a|. The pair is written as real part ± imaginary magnitude × i.

Algorithm

  1. Read a, b and c: If a is zero, report that the equation is not quadratic.
  2. Calculate D: Use D = b² − 4ac.
  3. Choose the correct formula: Test whether D is positive, zero or negative.
  4. Display the roots: Show the real roots or the complex pair as required.

Example

Let a = 1, b = −3 and c = 2. Then D = 9 − 8 = 1. The roots are (3 + 1)/2 = 2 and (3 − 1)/2 = 1. Checking them in the equation confirms the result: 2² − 3(2) + 2 = 0 and 1² − 3(1) + 2 = 0.

Important points

Check a before dividing by 2a. Do not use the real square-root function on a negative D. In the complex case, calculate √(−D). The program uses small fixed coefficients for a clear example. Floating-point rounding can affect values very close to zero, and the basic formula can lose accuracy for extreme inputs. With GCC, mathematical functions may require the -lm option when linking.

Time and space complexity

The method uses a fixed number of calculations and comparisons. Under the usual fixed-width analysis, time and extra space are O(1).

Reference table

↔ Scroll horizontally on a small screen
Boundary checks
CaseExpected behaviour
a = 0Reject as not quadratic.
D = 0Report the repeated root once.
D < 0Report complex conjugates, not a real sqrt of a negative value.

Diagram or flowchart

Validate the leading coefficient, compute the discriminant, select one of three root cases and finish.
Classifying quadratic roots · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
#include <math.h>
int main(void)
{
    double a = 1.0, b = -3.0, c = 2.0;
    if (a == 0.0) { puts("Not quadratic"); return 1; }
    double d = b*b - 4.0*a*c;
    if (d > 0.0) {
        printf("Roots = %.2f and %.2f\n", (-b+sqrt(d))/(2*a), (-b-sqrt(d))/(2*a));
    } else if (d == 0.0) {
        printf("Repeated root = %.2f\n", -b/(2*a));
    } else {
        printf("Roots = %.2f +/- %.2fi\n", -b/(2*a), sqrt(-d)/fabs(2*a));
    }
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

Roots = 2.00 and 1.00

Key points

  • For ax² + bx + c = 0 with a non-zero, compute D = b² − 4ac; the sign of D determines whether the roots are distinct real, repeated real or complex.
  • Check the discriminant before applying a real square root.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • June 2022 · Q8(a) · 7 marks

    Write an algorithm to find the roots of a quadratic equation.

    Paper P03 · page 1
  • July 2021 · Q8(a) · 7 marks

    Write an algorithm for finding the roots of a quadratic equation.

    Paper P04 · page 1
  • March/April 2023 · Q3(a) · 4 marks

    Write an algorithm to find the roots of a quadratic equation.

    Paper P05 · page 1
View all matching exam references →

QUESTION 27 · Worked algorithms

What are the starting terms and update rule of Fibonacci generation?

2 marks

Answer

The sequence starts with 0 and 1; each later term is the sum of its two previous terms.

  • For seven terms, the output is 0, 1, 1, 2, 3, 5, 8.
  • Save next = a + b before assigning a = b and b = next.

QUESTION 28 · Worked algorithms

Develop an algorithm and flowchart to generate the first n Fibonacci terms.

5 marks

Answer in brief

A Fibonacci sequence begins with 0 and 1. Each later term is the sum of the two previous terms.

Algorithm

  1. Read the count: Accept n, the number of terms required.
  2. Set the starting values: Use a = 0, b = 1 and i = 0.
  3. Print a: It is the next required term. Increase i by 1.
  4. Update the pair if more terms are needed: First calculate next = a + b. Then set a = b and b = next.
  5. Repeat: Continue until exactly n terms have been printed.

Example: first seven terms

The output is 0, 1, 1, 2, 3, 5, 8. After printing 0, the pair becomes 1 and 1. After printing the first 1, it becomes 1 and 2. Each new pair is prepared using the old pair. The count n means the number of terms, not the largest value allowed in the sequence.

Need for the temporary sum

Both old values are needed to calculate the next term. If a is replaced by b before the sum is calculated, the old a is lost. Saving next = a + b first avoids this mistake. The program does not calculate an extra unused term after the last output.

Boundary cases

For n = 0, no terms are printed. For n = 1, only 0 is printed. For n = 2, the result is 0 and 1. Negative counts are invalid. The supplied program accepts counts from 0 to 93 so that the values fit its unsigned long long variables.

Time and space complexity

The loop prints n terms and performs at most n − 1 pair updates. Therefore time is O(n). Only the count, counter and a few sequence values are stored, so extra space is O(1). This is an iterative method using a loop, not a recursive method.

Reference table

↔ Scroll horizontally on a small screen
Boundary checks
CaseExpected behaviour
n = 0Print no values.
n = 1Print only 0.
n = 2Print 0 and 1.
n outside 0–93Reject in this fixed-width example.

Diagram or flowchart

Initialise the pair, output the current value while terms remain, and update the pair only when another output is required.
Generate exactly n Fibonacci terms · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int n;
    if (scanf("%d", &n) != 1 || n < 0 || n > 93) {
        puts("Unsupported input"); return 1;
    }
    unsigned long long a = 0, b = 1;
    for (int i = 0; i < n; ++i) {
        printf("%s%llu", i == 0 ? "" : " ", a);
        if (i + 1 < n) {
            unsigned long long next = a + b;
            a = b; b = next;
        }
    }
    putchar('\n');
    return 0;
}

Sample input and output

Input

7

Output

0 1 1 2 3 5 8

Key points

  • Start with a = 0 and b = 1. Output the current a, then move to the next pair by computing the sum before overwriting either old value.
  • Calculate the next sum before replacing the old pair.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • September/October 2021 · Q1(a) · 7 marks

    What is flow chart? Draw a flowchart to generate Fibonacci sequence up to n numbers.

    Paper P01 · page 1
View all matching exam references →

QUESTION 29 · Worked algorithms

Give the condition for an even integer. Is zero even?

2 marks

Answer

The condition is n % 2 == 0, and zero is even.

  • A zero remainder means n is divisible by 2.
  • Use the zero test for negative inputs too; a negative odd remainder need not be 1.

QUESTION 30 · Worked algorithms

Draw and explain a flowchart to determine whether an integer is even or odd.

5 marks

Answer in brief

An integer is even if it is divisible by 2 without a remainder. Otherwise it is odd.

Algorithm

  1. Read n: Accept an integer.
  2. Test n % 2 == 0: The % operator gives the remainder of integer division.
  3. Print Even: Use this result when the remainder is zero.
  4. Print Odd: Use this result when the remainder is not zero.
  5. End: Only one of the two results is printed.

Explanation

The condition directly checks divisibility by 2. If the remainder is zero, n can be written as 2 multiplied by an integer. In a flowchart, place this condition inside a decision diamond. Label the true branch Yes and the false branch No. Each branch displays its result and reaches End.

Examples

For n = 8, 8 % 2 is 0, so the output is Even. For n = 7, the remainder is 1, so the output is Odd. Zero is even because 0 = 2 × 0. For n = −3, C gives a remainder of −1; it is non-zero, so the number is still correctly reported as Odd.

Important point

Do not test oddness only by n % 2 == 1 when negative inputs are allowed. A negative odd number can give remainder −1. Testing for a zero remainder and using the other branch for Odd handles both signs. The program also checks that reading the input succeeds before using n. Input values must fit int.

Time and space complexity

One remainder and one comparison are enough. There is no loop, so time is O(1). Only a fixed number of variables is required, giving O(1) extra space.

Reference table

↔ Scroll horizontally on a small screen
Boundary checks
CaseExpected behaviour
n = 0Even.
n = −4Even.
n = −3Odd.
Non-numeric inputReject before using n.

Diagram or flowchart

Read n, test whether n modulo two is zero, print the chosen classification and end.
One decision: even or odd · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int n;
    if (scanf("%d", &n) != 1) { puts("Invalid input"); return 1; }
    puts(n % 2 == 0 ? "Even" : "Odd");
    return 0;
}

Sample input and output

Input

-3

Output

Odd

Key points

  • An integer is even when its remainder on division by 2 is zero; otherwise it is odd.
  • Test for a zero remainder, not for remainder equal to one.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • September 2023 · Q1(a) · 2 marks

    Draw a flowchart to find whether a number is even or odd.

    Paper P09 · page 1
View all matching exam references →

QUESTION 31 · Worked algorithms

Write pseudocode to add two numbers.

2 marks

Answer

Read a and b, calculate sum = a + b, and output sum.

  • The numeric representation must support the permitted values and result.
  • For exactly two fixed-width inputs, the work and extra storage are constant.

QUESTION 32 · Worked algorithms

Develop an algorithm and flowchart to find the sum of two numbers.

5 marks

Answer in brief

To find the sum of two numbers, read both values, add them and display the result.

Input and output

Inputs: two numbers a and b. Output: their sum. Choose a numeric type that can hold the allowed values and their result. Use an integer type for whole-number examples or a floating type when fractional inputs are required.

Algorithm

  1. Start: Begin the solution.
  2. Read a and b: Obtain both input values.
  3. Calculate sum: Set sum = a + b.
  4. Display sum: Show the calculated value.
  5. Stop: The required result has been produced.

Pseudocode

READ a, b
sum ← a + b
OUTPUT sum

Example

Let a = 12 and b = 15. After reading the inputs, the addition gives 27. Store 27 in sum and display it. For a = −5 and b = 5, the sum is zero. No decision or repeated calculation is needed for these stated examples.

Flowchart and program

The flowchart contains Start, an input symbol, a processing rectangle for addition, an output symbol and End. The supplied program uses fixed small values so that the output can be checked easily. A program that accepts arbitrary user values must also check input conversion and ensure that the result fits the chosen type. A correct mathematical sum can still be too large for int.

Time and space complexity

The algorithm always performs one addition. Therefore its time is O(1). A fixed number of variables is used, so extra space is O(1). Adding n values would require a repeated step and would take O(n) time.

Reference table

↔ Scroll horizontally on a small screen
Boundary checks
CaseExpected behaviour
0 and 00.
−5 and 50.
12 and 1527.
Unrepresentable signed sumMust be prevented in a general input implementation.

Diagram or flowchart

Start, read two numbers, compute their sum, print the result and end.
Sequence for adding two values · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int a = 12, b = 15;
    int sum = a + b;
    printf("Sum = %d\n", sum);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

Sum = 27

Key points

  • Read the two values, add them using a suitable numeric type, then display the result.
  • The chosen C type must be able to represent the result.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • September 2023 · Q1(j) · 3 marks

    Write an algorithm to find the sum of two numbers.

    Paper P09 · page 1
View all matching exam references →

QUESTION 33 · Worked algorithms

Why initialise maximum from the first value?

2 marks

Answer

Start with the first input value because it is an actual member of the list.

  • Compare each remaining value with the current maximum and update it when larger.
  • Starting with zero would give a wrong answer for a list containing only negative numbers.

QUESTION 34 · Worked algorithms

Develop pseudocode to find the largest value in a given set.

5 marks

Answer in brief

The maximum of a non-empty set can be found by reading each value and updating the current result.

Algorithm

  1. Read n: The count must be at least 1.
  2. Read the first value: Set maximum to this value.
  3. Read each remaining value: If it is greater than maximum, replace maximum.
  4. Display the result: After all values have been checked, output the maximum.

Explanation

The starting value must come from the input. Suppose all values are negative. Starting maximum at zero would give a value that is not even in the input. Starting from the first actual value avoids that mistake. After each new value is checked, the stored result is correct for all values read so far.

Example

For the inputs −8, 3, 3 and −2, maximum starts at −8. Reading 3 changes it to 3. The next 3 and −2 do not change it. Thus the maximum is 3. A repeated maximum is allowed; keeping the current value is sufficient.

Boundary cases

With only one input, that value is the maximum. Equal values do not cause a problem. An empty input is rejected because there is no first value to use. The program accepts 1–100 integers. Each input must fit int. It reads values one at a time, so it does not need an array.

Time and space complexity

Each of n values is read once, with a fixed number of comparisons for each new value. Time is O(n). The program stores only a few counters and result variables, so extra space is O(1). In the flowchart, max and min mean choosing the larger or smaller value; they are mathematical operations, not C library calls used by this program.

Reference table

↔ Scroll horizontally on a small screen
Boundary checks
CaseExpected behaviour
One valueIt is the maximum.
All values negativeInitialisation from input still works.
Repeated equal valuesThe repeated value is retained.
Count zeroReject because the set must be non-empty.

Diagram or flowchart

Read the first value, initialise the candidate values, scan each remaining input and output the result.
Scan a set for its maximum · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int n, value;
    if (scanf("%d", &n) != 1 || n < 1 || n > 100) {
        puts("Unsupported count"); return 1;
    }
    if (scanf("%d", &value) != 1) { puts("Invalid value"); return 1; }
    int maximum = value;
    
    for (int i = 1; i < n; ++i) {
        if (scanf("%d", &value) != 1) { puts("Invalid value"); return 1; }
        if (value > maximum) { maximum = value; }
        
    }
    printf("Maximum = %d\n", maximum);
    return 0;
}

Sample input and output

Input

4
-8 3 3 -2

Output

Maximum = 3

Key points

  • Initialise the maximum from the first actual input, then update the candidate as the remaining values are read.
  • Do not initialise a candidate to zero unless the input domain justifies it.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • March/April 2023 · Q2(a) · 4 marks

    Write pseudocode to find the biggest number in a given set.

    Paper P05 · page 1
View all matching exam references →

QUESTION 35 · Worked algorithms

Why initialise minimum and maximum from the first value?

2 marks

Answer

Start both minimum and maximum with the first input value of the non-empty list.

  • Compare each remaining value with both current results and update them when needed.
  • Starting with zero can give a wrong maximum for all-negative inputs or a wrong minimum for all-positive inputs.

QUESTION 36 · Worked algorithms

Develop an algorithm to find the minimum and maximum in a set.

5 marks

Answer in brief

The minimum and maximum of a non-empty set can be found by reading each value and updating the current result.

Algorithm

  1. Read n: The count must be at least 1.
  2. Read the first value: Set maximum to this value. Also set minimum to this value.
  3. Read each remaining value: If it is greater than maximum, replace maximum. If it is smaller than minimum, replace minimum.
  4. Display the result: After all values have been checked, output the minimum and maximum.

Explanation

The starting value must come from the input. Suppose all values are negative. Starting maximum at zero would give a value that is not even in the input. Starting from the first actual value avoids that mistake. After each new value is checked, the stored result is correct for all values read so far.

Example

For the inputs −8, 3, 3 and −2, maximum starts at −8. Reading 3 changes it to 3. The next 3 and −2 do not change it. Minimum starts at −8 and stays −8. Thus the final minimum is −8 and the maximum is 3.

Boundary cases

With only one input, that value is the minimum and maximum. Equal values do not cause a problem. An empty input is rejected because there is no first value to use. The program accepts 1–100 integers. Each input must fit int. It reads values one at a time, so it does not need an array.

Time and space complexity

Each of n values is read once, with a fixed number of comparisons for each new value. Time is O(n). The program stores only a few counters and result variables, so extra space is O(1). In the flowchart, max and min mean choosing the larger or smaller value; they are mathematical operations, not C library calls used by this program.

Reference table

↔ Scroll horizontally on a small screen
Boundary checks
CaseExpected behaviour
One valueIt is the minimum and maximum.
All values negativeInitialisation from input still works.
Repeated equal valuesThe repeated value is retained.
Count zeroReject because the set must be non-empty.

Diagram or flowchart

Read the first value, initialise the candidate values, scan each remaining input and output the result.
Scan a set for its minimum and maximum · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int n, value;
    if (scanf("%d", &n) != 1 || n < 1 || n > 100) {
        puts("Unsupported count"); return 1;
    }
    if (scanf("%d", &value) != 1) { puts("Invalid value"); return 1; }
    int maximum = value;
    int minimum = value;
    for (int i = 1; i < n; ++i) {
        if (scanf("%d", &value) != 1) { puts("Invalid value"); return 1; }
        if (value > maximum) { maximum = value; }
        if (value < minimum) { minimum = value; }
    }
    printf("Minimum = %d, maximum = %d\n", minimum, maximum);
    return 0;
}

Sample input and output

Input

4
-8 3 3 -2

Output

Minimum = -8, maximum = 3

Key points

  • Initialise the minimum and maximum from the first actual input, then update each candidate as the remaining values are read.
  • Do not initialise a candidate to zero unless the input domain justifies it.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • September 2023 · Q11(a) · 6 marks

    Write an algorithm to find minimum and maximum values in a given set.

    Paper P09 · page 2
View all matching exam references →

QUESTION 37 · C fundamentals

Who developed C? State two characteristics of the language.

2 marks

Answer

Dennis Ritchie developed C at Bell Labs in the early 1970s.

  • C supports structured program organisation through functions and blocks.
  • It provides typed arithmetic, pointers and bit operations for general-purpose and systems programming.

QUESTION 38 · C fundamentals

Describe the background and important characteristics of C.

5 marks

Answer in brief

C is a general-purpose programming language developed by Dennis Ritchie at Bell Labs in the early 1970s.

Background

C developed alongside the Unix operating system. It provided readable programming statements while also allowing work with memory addresses and bits. These features made it useful for system programs as well as general applications.

Main characteristics of C

  1. Structured programming: A solution can be divided into functions and blocks. This makes a large program easier to organise.
  2. Typed variables: Variables have types such as int, char and double. A type describes the values and operations that can be used.
  3. Operators: C provides arithmetic, comparison, logical and bitwise operators.
  4. Pointers: A pointer stores an address. Pointers allow programs to work with other objects through their locations.
  5. Standard library: Headers such as stdio.h provide declarations for useful functions, including input and output functions.
  6. Portability: Source code can often be used on different systems when it follows standard rules and uses suitable libraries.

Applications

C is used in operating systems, embedded systems, compilers and libraries. The language gives the programmer control, but that also means the programmer must check input, array limits, memory use and numeric ranges. Writing a program in C does not automatically make its algorithm efficient.

Important distinction

C is the language; GCC and Clang are implementations that can compile C. The same source may produce different executable files for different systems. Sizes of types can also differ between implementations. These notes use C11-compatible examples for a hosted environment, where standard startup and input/output facilities are available.

Key points

  • C source portability depends on the facilities and assumptions used.
  • Standard library functions need the appropriate declarations.

QUESTION 39 · C fundamentals

What does int main(void) mean in a hosted C program?

2 marks

Answer

It defines main with an int return type and no parameters.

  • Execution of a hosted C program begins at main.
  • Returning 0 indicates successful termination to the host environment.

QUESTION 40 · C fundamentals

Explain the structure of a C program with a complete example.

5 marks

Answer in brief

A simple hosted C program contains header inclusion, the main function, declarations and executable statements.

Parts of a C program

  1. Header inclusion: #include <stdio.h> makes declarations for standard input/output functions available. The directive does not print anything by itself.
  2. Main function: int main(void) defines main with no parameters and an int return value. Execution begins here in the hosted environment.
  3. Braces: Opening and closing braces mark the beginning and end of a block.
  4. Declarations: A declaration introduces a name and its type, such as int first = 8;.
  5. Statements: Statements perform actions. For example, total = first + second; calculates and stores a sum.
  6. Return statement: return 0; reports successful termination to the host environment.

Explanation of the example

The program creates first and second with values 8 and 5. It adds them and stores 13 in total. printf displays that value using %d. The newline moves output to the next line. The program then returns zero.

Comments and punctuation

Comments explain the program and are not executed. Declarations and expression statements normally end in semicolons. A preprocessing directive such as #include does not need a semicolon. Match every opening brace with a closing brace.

Important points

C is case-sensitive, so Printf is not the same name as printf. Use the proper header for a library function. Global variables, macros and helper functions are included only when needed; they are not compulsory sections in every program. A larger program can contain several functions and source files.

Reference tables

↔ Scroll horizontally on a small screen
Parts of the example
PartPurpose
#include <stdio.h>Makes declarations for standard input/output facilities available.
int main(void)Defines main with an int result and no parameters.
{ and }Delimit the function body.
int first = 8;Declares and initialises a local variable.
printf(...)Writes formatted output.
return 0;Indicates successful termination to the host environment.
↔ Scroll horizontally on a small screen
Problems in a first program
MistakeWhy it mattersCorrection
Writing Printf instead of printfC identifiers are case-sensitive.Use the declared function name.
Omitting a closing braceThe block structure becomes invalid.Match every opening brace.
Using void main in these examplesIt is not the standard no-argument hosted form used here.Use int main(void).
Placing a semicolon after every line indiscriminatelyDirectives and block syntax have their own rules.Understand what construct each line belongs to.

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int first = 8;
    int second = 5;
    int total = first + second;
    printf("Total = %d\n", total);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

Total = 13

Key points

  • Use int main(void) for these no-argument hosted examples.
  • Match braces and terminate declarations and expression statements correctly.

QUESTION 41 · C fundamentals

State two practical rules for naming identifiers in C.

2 marks

Answer

Use a letter as the first character of a beginner-style name, followed by letters, digits or underscores; do not use a keyword.

  • total_marks is valid; 2marks and total-marks are not valid single identifiers.
  • Names are case-sensitive: total and Total are different. Avoid reserved underscore patterns.

QUESTION 42 · C fundamentals

What are tokens and identifiers? Explain identifier naming rules in C.

5 marks

Answer in brief

Tokens are the small building blocks of C source code. An identifier is a name given to a variable, function or another program item.

Common token types

  1. Keywords: Words with a fixed language meaning, such as int and while. They cannot be used as ordinary variable names.
  2. Identifiers: Names selected by the programmer, such as total and calculate_sum.
  3. Constants: Values written in the source, such as 25 or 3.5.
  4. String literals: Text written in double quotes, such as "Hello".
  5. Operators and punctuation: Symbols such as +, =, ; and braces help form expressions and statements. C calls these symbols punctuators.

Identifier naming rules

  1. First character: For the simple portable names used here, begin with a letter.
  2. Remaining characters: Use letters, digits and underscores. Spaces and hyphens cannot be part of one identifier.
  3. Case matters: total and Total are different names.
  4. Keywords are not allowed: Do not name a variable int or while.
  5. Avoid reserved names: Do not use leading-underscore patterns in beginner application names.

Examples

total_marks and marks2 are valid names. 2marks is invalid because it begins with a digit. total-marks is read as subtraction, not one name. student count contains two separate names rather than one identifier.

Meaningful names

Choose names that explain the data, such as student_count or total_marks. The source int total = 25; contains the keyword int, identifier total, integer constant 25 and symbols = and ;. Do not memorise an old rule that all C names must have at most eight characters; implementations have limits, but useful names can be longer.

Reference tables

↔ Scroll horizontally on a small screen
Tokens in a declaration
Source fragmentCategoryMeaning
intKeywordA built-in type specifier.
totalIdentifierA name chosen for the object.
=Punctuator/operatorAssignment or initialisation notation in context.
25Integer constantA numeric value written in the source.
;PunctuatorEnds the declaration.
↔ Scroll horizontally on a small screen
Check the name
NameAssessment
total_marksValid beginner-style identifier.
marks2Valid; a digit may follow the first character.
2marksInvalid; begins with a digit.
total-marksParsed as subtraction, not one identifier.
whileA keyword; cannot be your variable name.

Key points

  • Keywords and identifiers are different token categories.
  • Uppercase and lowercase letters are distinct.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • March/April 2023 · Q1(a) · 1 marks

    Give an example of an identifier.

    Paper P05 · page 1
View all matching exam references →

QUESTION 43 · C fundamentals

What does sizeof report? Is int always two bytes?

2 marks

Answer

sizeof reports an object or type size in C bytes, as a value of type size_t.

  • sizeof(char) is always 1; CHAR_BIT gives the number of bits in a C byte.
  • int is not always two bytes. Its size depends on the implementation; inspect it with sizeof(int).

QUESTION 44 · C fundamentals

Explain the basic C data types, their ranges and how to check their sizes.

5 marks

Answer in brief

A data type tells us what kind of value an object can store and which operations can be performed on it.

Basic data types

  1. char: Stores character-sized values. It is commonly used for individual characters and character arrays.
  2. Integer types: short, int, long and long long store whole numbers. Signed forms can represent negative values; unsigned forms represent non-negative values.
  3. Floating types: float, double and long double store approximate values that can include fractions.
  4. Boolean type: In C11, _Bool stores logical values as 0 or 1. The stdbool.h header provides the name bool.
  5. void: Shows the absence of a value, such as a function that returns no result.

Sizes and ranges

Type sizes can differ between implementations. int is not always two bytes, and long double is not always ten bytes. sizeof reports a size in C bytes. sizeof(char) is always 1. CHAR_BIT, from limits.h, tells us how many bits are in a C byte. INT_MIN and INT_MAX give the int limits. Use %zu to print a sizeof result, whose type is size_t.

Enumeration

An enumeration gives names to related integer values. In enum Day { MONDAY, TUESDAY, WEDNESDAY };, the values start at 0 unless other values are specified. Thus TUESDAY has value 1. Names can make the code easier to read than unexplained numbers. Do not assume an enum object always occupies one byte.

Choice of type

Use an integer for a count and a floating type when a fractional result is required. Check the largest allowed value and intermediate calculations. Every fixed-width type has a limited range. A floating type does not store every decimal fraction exactly. Plain char can act as signed or unsigned depending on the implementation; specify the form when that difference matters.

Reference table

↔ Scroll horizontally on a small screen
Common scalar types
Type familyExamplesUse
Characterchar, signed char, unsigned charCharacter-sized values and small integers.
Integershort, int, long, long long and unsigned variantsWhole-number arithmetic.
Floating-pointfloat, double, long doubleApproximate real-number arithmetic.
Boolean_Bool; bool through <stdbool.h> in C11Logical values normalised to 0 or 1.

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
#include <limits.h>
int main(void)
{
    printf("sizeof(char) = %zu C byte\n", sizeof(char));
    printf("CHAR_BIT is at least 8: %d\n", CHAR_BIT >= 8);
    printf("int supports at least -32767..32767: %d\n",
           INT_MIN <= -32767 && INT_MAX >= 32767);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

sizeof(char) = 1 C byte
CHAR_BIT is at least 8: 1
int supports at least -32767..32767: 1

Key points

  • Use sizeof and limits macros to inspect the implementation.
  • A C byte is the unit measured by sizeof.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • September/October 2021 · Q6(a) · 7 marks

    Define data type. Briefly discuss the fundamental data types supported in C.

    Paper P01 · page 1
  • September 2023 · Q1(c) · 1 marks

    Define the enumeration data type in C.

    Paper P06 · page 1
  • January/February 2024 · Q4(a) · 4 marks

    Explain how to define and use an enumeration data type in C.

    Paper P08 · page 1
View all matching exam references →

QUESTION 45 · C fundamentals

Distinguish declaration from initialisation with an example.

2 marks

Answer

A declaration introduces an object and its type; initialisation supplies its starting value.

  • int count; declares count without supplying an initial value.
  • int count = 0; declares and initialises count. An automatic local object needs a valid value before it is read.

QUESTION 46 · C fundamentals

Define a variable. Explain declaration, initialisation and assignment.

5 marks

Answer in brief

A variable is a named object used to store a value. The value of an ordinary modifiable variable can change while the program runs.

Declaration, initialisation and assignment

  1. Declaration: Introduces the name and type. Example: int score;.
  2. Initialisation: Provides a starting value when the object is created. Example: int score = 70;.
  3. Assignment: Stores a new value in an existing variable. Example: score = 75;.

Example

After int score = 70;, score contains 70. If bonus is 5, the statement score = score + bonus; calculates 75 and stores it back in score. The declared type remains int. Only the stored value changes.

Declaration and definition

A declaration gives information about a name. An object definition also provides its storage. For example, a local int count; defines an object even though it does not give it a starting value. extern int shared_count; is an example of a declaration whose definition can be supplied elsewhere. These terms should not be confused with initialisation.

Important points

  1. Initialise before use: An ordinary local automatic variable without an initialiser does not have a useful guaranteed starting value. Give it a valid value before reading it.
  2. Use the correct type: A value must be suitable for the destination type and its range.
  3. Understand const: A const-qualified object cannot be changed through that object.
  4. Use clear names: A name such as total_marks makes the purpose easier to understand.

Reference table

↔ Scroll horizontally on a small screen
Declaration, initialisation and assignment
OperationExamplePurpose
Declarationint total;Introduces total as an int object.
Initialisationint total = 0;Supplies the object’s initial value.
Assignmenttotal = 12;Replaces the value of an existing modifiable object.

Key points

  • An ordinary modifiable variable can change during execution.
  • Initialisation happens as the object is created; assignment happens later.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • March/April 2023 · Q1(b) · 3 marks

    How do you declare a variable?

    Paper P02 · page 1
  • July 2021 · Q1(a) · 7 marks

    Differentiate declaration and definition of a variable, with examples.

    Paper P04 · page 1
View all matching exam references →

QUESTION 47 · C fundamentals

Distinguish a character constant from a string literal.

2 marks

Answer

A character constant uses single quotes; a string literal uses double quotes.

  • 'A' is an ordinary character constant of type int in C.
  • "A" is an array containing A and a terminating null character.

QUESTION 48 · C fundamentals

Explain constants, literals and symbolic constant names in C.

5 marks

Answer in brief

A constant written in the source represents a fixed value. Its form tells the compiler what kind of value it is.

Types of values in source code

  1. Integer constant: A whole number such as 42. Forms such as 42U or 42LL specify an unsigned or long long form.
  2. Floating constant: A value such as 3.5. It has type double by default; 3.5f has type float.
  3. Character constant: A character in single quotes, such as A written as 'A'. An ordinary character constant has type int in C.
  4. String literal: Characters in double quotes, such as "CodeBhavya". A terminating null character marks the end of the string.
  5. Enumeration constant: A named integer value introduced by an enum declaration.

Named constants

A name can explain a value that is used repeatedly. #define MAX_STUDENTS 60 replaces the macro name during preprocessing. const double tax_rate = 0.05; creates a typed object that cannot be modified through that object. These are different mechanisms; const does not automatically make an object an integer constant expression in C.

Character and string example

'A' is a character constant. "A" is a string literal containing A and a null character, so its array size is 2 C bytes. Single quotes and double quotes are not interchangeable.

Important points

Do not try to assign a new value to a literal or modify a string literal. A writable character array initialised from a string literal has its own elements and is different from the literal itself. Use meaningful constant names to avoid repeating unexplained numbers in a program.

Reference table

↔ Scroll horizontally on a small screen
Values written in source
FormExampleMeaning
Integer constant42, 42U, 0x2AWhole-number constant; suffixes and bases affect type and interpretation.
Floating constant3.5, 3.5fdouble by default; f requests float.
Character constant'A', '\n'An ordinary character constant has type int in C.
String literal"CodeBhavya"An array of characters including a terminating null character.
Enumeration constantenum { LIMIT = 10 };Introduces an integer constant name.

Key points

  • A macro replacement and a const object are not the same language feature.
  • The type of a literal depends on its form and suffix.

QUESTION 49 · Input and output

Which scanf formats read float and double values?

2 marks

Answer

Use %f with the address of a float and %lf with the address of a double.

  • For float f, write scanf("%f", &f);.
  • For double d, write scanf("%lf", &d);. Check that one value was assigned before using it.

QUESTION 50 · Input and output

Explain printf and scanf with suitable format specifiers.

5 marks

Answer in brief

Formatted input and output functions read and display values using a format string. They are declared in the stdio.h header.

printf: formatted output

printf displays values on standard output, usually the screen. A format specifier tells it how to display each value. For example, printf("Age = %d", age); displays an integer. For price = 12.5, printf("%.2f", price); displays 12.50. Here .2 requests two digits after the decimal point. It changes the displayed form, not the stored value.

scanf: formatted input

scanf reads values from standard input, usually the keyboard. For int age;, use scanf("%d", &age);. The & operator gives the address where the value must be stored. Check that scanf returns 1 before using this one value. A different result means the required assignment did not succeed. The input must also be within the range of the destination type.

Common format rules

  1. Integer: Use %d for int.
  2. Floating input: Use %f with float * and %lf with double *. For example, scanf("%lf", &price); reads a double.
  3. Floating output: Use %f for a double. A float passed to printf is converted to double automatically.
  4. Character: Use %c for a character.
  5. Long double: Use %Lf for both input and output with the appropriate argument.

Important points

The format specifier and argument type must match. scanf normally needs addresses; printf normally needs the values to display. stdin is standard input, stdout is normal output and stderr is error output. These streams can be redirected to files. A successful input count does not prove that the whole line is valid.

Reference tables

↔ Scroll horizontally on a small screen
Common format specifiers
Value typeprintfscanf
int%d%d with int *
unsigned int%u%u with unsigned int *
long long%lld%lld with long long *
float%f (promoted to double)%f with float *
double%f%lf with double *
long double%Lf%Lf with long double *
char%c%c with char *
size_t%zu%zu with size_t *
↔ Scroll horizontally on a small screen
Standard streams
StreamRoleExample
stdinStandard input, often connected to the keyboard.scanf reads from stdin.
stdoutNormal program output.printf writes to stdout.
stderrDiagnostic/error output.fprintf(stderr, "Invalid input\n");

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    double price;
    if (scanf("%lf", &price) != 1) {
        puts("Invalid input");
        return 1;
    }
    printf("Price = %.2f\n", price);
    return 0;
}

Sample input and output

Input

12.5

Output

Price = 12.50

Key points

  • Match every format to the actual argument type.
  • Check input success before reading the result.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • March/April 2023 · Q3(b) · 5 marks

    Distinguish formatted and unformatted input/output statements.

    Paper P07 · page 1
  • September 2023 · Q2(a) · 3 marks

    Explain stdin, stdout and stderr with examples.

    Paper P09 · page 1
View all matching exam references →

QUESTION 51 · Input and output

Why should getchar’s return value be stored in int?

2 marks

Answer

getchar returns an int containing the character read, or EOF when input ends or an error occurs.

  • Store the result in int so that EOF can be distinguished from a character.
  • Test for EOF before using the result as a character.

QUESTION 52 · Input and output

Explain character input/output and safe whole-line input in C.

5 marks

Answer in brief

Character input/output functions handle individual characters. Line input/output functions handle a string containing a line of text.

Character functions

  1. getchar: Reads one character from standard input. Store its result in int so that the special end-of-input value EOF can be detected.
  2. putchar: Writes one character to standard output. For example, putchar('A'); displays A.

Line functions

  1. fgets: Reads at most one less than the supplied array size and adds a terminating null character when successful. It keeps the newline if it reads one.
  2. puts: Writes a string and then adds a newline.
  3. Header: Include stdio.h before using these functions.

Example

For char name[40];, fgets(name, sizeof name, stdin) reads a line into name if the call succeeds. It can store at most 39 input characters plus the terminating null character. If the line is longer, part of it remains unread. Check that the result is not NULL before using the line.

Important points

Check for EOF before treating a getchar result as a character. Do not use gets: it cannot limit the input size and has been removed from standard C. Functions such as getch from conio.h are not part of standard C. After numeric scanf input, a newline may remain; the next line read may read that newline. Plan the input sequence carefully.

Reference tables

↔ Scroll horizontally on a small screen
Character and line functions
FunctionPurposeImportant detail
getchar()Reads the next input character.Returns int so it can represent an unsigned-char value or EOF.
putchar(ch)Writes one character.Use a character value, not a string pointer.
fgets(buffer, size, stdin)Reads at most size − 1 characters.On success, adds a null terminator; a read newline is retained.
puts(text)Writes a string followed by a newline.Do not add an unwanted second newline.
↔ Scroll horizontally on a small screen
Input requirements
NeedSuitable starting pointExtra responsibility
One next charactergetcharHandle EOF and any whitespace deliberately.
A bounded whole-line segmentfgetsDetect a missing newline if truncation matters.
A numeric tokenChecked formatted input or checked text conversionValidate success and representable range.

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int ch = getchar();
    if (ch == EOF) {
        puts("No character received");
        return 1;
    }
    putchar(ch);
    putchar('\n');
    return 0;
}

Sample input and output

Input

A

Output

A

Key points

  • Store getchar’s result in int so EOF remains distinguishable.
  • Bounded input prevents writing beyond the supplied array.

QUESTION 53 · Operators

Define unary and binary operators with one example each.

2 marks

Answer

A unary operator acts on one operand; a binary operator acts on two.

  • Logical negation !ready is unary.
  • Addition a + b is binary. Minus can have both roles: -x is unary and a - b is binary.

QUESTION 54 · Operators

Classify the operators in C with examples.

5 marks

Answer in brief

An operator is a symbol that tells C to perform an operation on one or more values. The values it works on are called operands.

Types of operators

  1. Arithmetic: +, -, *, / and % perform numeric calculations.
  2. Relational: <, <=, >, >=, == and != compare values.
  3. Logical: &&, || and ! combine or reverse conditions.
  4. Bitwise: &, |, ^, ~, << and >> work with the bits of integers.
  5. Assignment: = stores a value; += and similar forms combine calculation and assignment.
  6. Increment and decrement: ++ adds one and -- subtracts one.
  7. Conditional: ?: selects one of two expressions based on a condition.

Classification by number of operands

  1. Unary: Works on one operand, such as -x or !ready.
  2. Binary: Works on two operands, such as a + b.
  3. Ternary: Works with three operands. The conditional operator is written condition ? value1 : value2.

Example

In total = price * quantity;, * multiplies price and quantity, and = stores the result in total. In age >= 18 && has_id, >= compares age with 18 and && combines the two conditions.

Important points

Do not confuse = with ==: one assigns and the other compares. Likewise & is bitwise AND, while && is logical AND. Parentheses can make grouping clear. Choose types and input values that make the operation valid.

Reference table

↔ Scroll horizontally on a small screen
Operator families
FamilyOperatorsExample
Arithmetic+ − * / %a + b
Relational and equality< <= > >= == !=score >= 40
Logical&& || !valid && ready
Bitwise& | ^ ~ << >>flags & mask
Conditional?:a > b ? a : b
Increment/decrement++ --++count
Assignment= += -= *= /= %= and bitwise compound formstotal += value
Other useful operatorssizeof, casts, comma, address and indirectionsizeof(int)

Key points

  • An operand is the value or expression an operator acts on.
  • Operator purpose and operand count are two different classifications.

QUESTION 55 · Operators

Find the values of 7 / 2 and 7 % 2 in C.

2 marks

Answer

With integer operands, 7 / 2 is 3 and 7 % 2 is 1.

  • Integer division truncates toward zero.
  • The remainder satisfies (7 / 2) × 2 + (7 % 2) = 7. Both operands of % must have integer type.

QUESTION 56 · Operators

Explain arithmetic operators, integer division and the remainder operator.

5 marks

Answer in brief

Arithmetic operators perform addition, subtraction, multiplication, division and remainder calculations.

Operators and examples

  1. Addition (+): 7 + 2 gives 9.
  2. Subtraction (-): 7 - 2 gives 5.
  3. Multiplication (*): 7 * 2 gives 14.
  4. Division (/): 7 / 2 gives 3 when both operands are integers. 7.0 / 2 gives 3.5.
  5. Remainder (%): 7 % 2 gives 1, the remainder after integer division. Both operands must have integer type.

Integer and floating-point division

Integer division discards the fractional part towards zero. Thus -7 / 2 gives -3. If a floating-point operand is present, floating-point division is used after the required conversions. To calculate a fractional average from integers, write (double)total / count with a non-zero count.

Example

For a = 17 and b = 5, a / b is 3 and a % b is 2. The relationship is 17 = 3 * 5 + 2. This explains the difference between quotient and remainder.

Important points

Never divide by zero or use zero as the divisor of %. Keep results within the allowed type range: signed integer overflow has no defined result in C. Integer division must also have a representable result. Floating-point calculations may contain small rounding errors.

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int a = 7, b = 2;
    printf("sum = %d\n", a + b);
    printf("difference = %d\n", a - b);
    printf("product = %d\n", a * b);
    printf("integer division = %d\n", a / b);
    printf("remainder = %d\n", a % b);
    printf("real division = %.1f\n", (double)a / b);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

sum = 9
difference = 5
product = 14
integer division = 3
remainder = 1
real division = 3.5

Key points

  • 7 / 2 and 7.0 / 2 have different results.
  • % is an integer operator.

QUESTION 57 · Operators

What is short-circuit evaluation of &&?

2 marks

Answer

Logical AND evaluates its right operand only when the left operand is non-zero.

  • If the left operand is zero, the overall result is already 0.
  • In d != 0 && n % d == 0, the remainder is evaluated only after d has been found non-zero.

QUESTION 58 · Operators

Explain relational, equality and logical operators with short-circuit evaluation.

5 marks

Answer in brief

Relational operators compare values. Logical operators combine conditions. These operators produce int results: 1 for true and 0 for false.

Relational operators

  1. Less than and greater than: Use < and >. For a = 5 and b = 8, a < b gives 1.
  2. Inclusive comparisons: Use <= and >= when equality is also allowed.
  3. Equality: Use == to test equality and != to test inequality. a == b gives 0 for 5 and 8.

Logical operators

  1. AND (&&): True only when both conditions are true. Example: age >= 18 && has_id.
  2. OR (: |)|True when at least one condition is true. Example: day == 6 || day == 7.
  3. NOT (!): Reverses the truth value. !0 gives 1 and !5 gives 0.

Short-circuit evaluation

For &&, C skips the right condition when the left condition is false. For ||, it skips the right condition when the left condition is true. For example, d != 0 && n % d == 0 checks d first. When d is zero, the remainder operation is skipped, avoiding division by zero in that expression.

Important points

Zero is treated as false; a non-zero value is treated as true. Write x > 0 && x < 10 to test a range. Do not write 0 < x < 10, because C first produces 0 or 1 from the first comparison and then compares that result with 10. Use == for comparison, not =.

Reference table

↔ Scroll horizontally on a small screen
Conditions with a = 5 and b = 8
ExpressionResultReason
a < b15 is less than 8.
a == b0The values differ.
a != b1The values differ.
a > 0 && b > 01Both conditions are true.
a == 0 || b == 00Neither value is zero.
!a0a is non-zero.

Key points

  • Logical operators normalise their result to 0 or 1.
  • Short-circuiting can prevent evaluating an unsafe expression.

QUESTION 59 · Operators

Find 12U & 10U and 12U ^ 10U using their low four bits.

2 marks

Answer

12U & 10U is 8; 12U ^ 10U is 6.

  • 12 is 1100 and 10 is 1010 in the displayed low four bits. AND gives 1000, or 8.
  • XOR sets differing bit positions, giving 0110, or 6.

QUESTION 60 · Operators

Explain bitwise operators with a worked binary example.

5 marks

Answer in brief

Bitwise operators work on individual bits of integer values. Unsigned integers make introductory bit examples easier to understand.

Operators

  1. AND (&): Sets a result bit when both input bits are 1.
  2. OR (: )|Sets a result bit when either input bit is 1.
  3. XOR (^): Sets a result bit when the input bits differ.
  4. Complement (~): Reverses every bit of the promoted operand.
  5. Left shift (<<): Moves bits left and fills the new low positions with zeros for unsigned values.
  6. Right shift (>>): For unsigned values, moves bits right and fills the new high positions with zeros.

Worked example

Use a = 12U and b = 10U. Their low four bits are 1100 and 1010. a & b gives 1000, or 8. a | b gives 1110, or 14. a ^ b gives 0110, or 6. Also, 12U << 1 gives 24 and 12U >> 1 gives 6.

Uses

  1. Flags: Store several yes/no settings in different bits of one integer.
  2. Masks: Select, set or clear required bit positions.
  3. Low-level programming: Work with data formats and hardware interfaces where bit positions matter.

Important points

~12U reverses all bits of unsigned int, not only the four displayed bits. A shift count must be non-negative and smaller than the width of the promoted left operand. Signed shifts have extra restrictions. & and | operate on bits; && and || operate on truth values.

Reference tables

↔ Scroll horizontally on a small screen
Unsigned a = 12 and b = 10
ExpressionLow four bitsDecimal result
a & b10008
a | b111014
a ^ b01106
a << 11100024
a >> 101106
↔ Scroll horizontally on a small screen
Bitwise truth table
a bitb bita & ba | ba ^ b
00000
01011
10011
11110

Diagram or flowchart

For the low four bits of unsigned values 12 (1100) and 10 (1010), AND produces 1000, OR produces 1110 and XOR produces 0110.
Bitwise AND, OR and XOR · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    unsigned int a = 12U, b = 10U;
    printf("AND = %u\n", a & b);
    printf("OR = %u\n", a | b);
    printf("XOR = %u\n", a ^ b);
    printf("left shift = %u\n", a << 1);
    printf("right shift = %u\n", a >> 1);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

AND = 8
OR = 14
XOR = 6
left shift = 24
right shift = 6

Key points

  • A displayed four-bit example does not imply a four-bit C integer type.
  • Use unsigned values for these bit-pattern examples.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • March/April 2023 · Q3(b) · 6 marks

    List bitwise operators and explain each with its precedence and associativity.

    Paper P05 · page 1
  • March/April 2023 · Q2(a) · 5 marks

    Explain bitwise operators in detail.

    Paper P07 · page 1
  • January/February 2024 · Q1(a) · 1 marks

    List bitwise operators in C.

    Paper P08 · page 1
View all matching exam references →

QUESTION 61 · Operators

Write a conditional expression to select the larger of a and b.

2 marks

Answer

a > b ? a : b selects the larger value.

  • A true condition selects a; otherwise it selects b.
  • Only the selected alternative is evaluated. If a and b are equal, selecting b still gives the maximum value.

QUESTION 62 · Operators

Explain the conditional operator ?: with an example.

5 marks

Answer in brief

The conditional operator ?: selects one of two expressions according to a condition. It is also called the ternary operator because it has three operands.

Syntax

condition ? expression_if_true : expression_if_false

First the condition is evaluated. A non-zero condition selects the first alternative. A zero condition selects the second alternative. Only the selected alternative is evaluated.

Example: larger value

Write maximum = a > b ? a : b;. If a = 12 and b = 7, the condition is true and maximum becomes 12. If a = 4 and b = 9, the condition is false and maximum becomes 9. Equal values also give the correct maximum.

Example: even or odd

The expression n % 2 == 0 ? "Even" : "Odd" selects the appropriate string for an integer n. It can be passed to printf or puts. Zero is even because its remainder on division by 2 is zero.

Advantages and important points

  1. Compact form: Useful for a short choice that produces one value.
  2. Readability: Use if-else when the alternatives contain several statements or become difficult to read.
  3. Grouping: Nested conditional operators group from right to left. Add parentheses for clarity.
  4. Types: The alternative expressions must have types permitted by C; C determines a suitable result type.

Diagram or flowchart

Evaluate a greater than b; a true condition selects a, and a false condition selects b; the selected value is assigned to larger.
Choosing a value with ?: · Download diagram

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int a = 15, b = 9;
    int larger = a > b ? a : b;
    printf("Larger = %d\n", larger);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

Larger = 15

Key points

  • ?: is an expression that produces a selected value.
  • Only one alternative expression is evaluated.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • September 2023 · Q3(b) · 4 marks

    What is the ternary operator? Write the syntax of switch-case.

    Paper P09 · page 1 · Combined subquestion: marks apply to its complete wording.
View all matching exam references →

QUESTION 63 · Operators

Differentiate ++x and x++ when their expression value is used.

2 marks

Answer

Prefix ++x gives the updated value; postfix x++ gives the previous value. Both increment x by one.

  • Starting separately with x = 5, y = ++x; leaves y = 6 and x = 6.
  • Starting separately with x = 5, y = x++; leaves y = 5 and x = 6.

QUESTION 64 · Operators

Differentiate prefix and postfix increment and decrement operators.

5 marks

Answer in brief

The increment operator ++ increases a variable by one. The decrement operator -- decreases it by one. Each has a prefix and a postfix form.

Prefix form

The operator is placed before the variable: ++x or --x. The expression gives the updated value. Starting with x = 5, y = ++x; leaves both x and y equal to 6. Starting with x = 5, y = --x; leaves both equal to 4.

Postfix form

The operator is placed after the variable: x++ or x--. The expression gives the previous value while the variable is updated. Starting with x = 5, y = x++; leaves y equal to 5 and x equal to 6. Starting with x = 5, y = x--; leaves y equal to 5 and x equal to 4.

When used alone

As separate statements, ++x; and x++; both increase x by one. Their difference matters when the expression value is used, as in an assignment. The same rule applies to decrement.

Important points

  1. Writable variable: The operand must be something C permits to be changed. A constant such as 5 cannot be incremented.
  2. Valid range: The updated value must fit the type; signed overflow has no defined result.
  3. Separate changes: Do not use i++ + ++i. It changes i without the required ordering and has undefined behaviour, so there is no guaranteed answer.
  4. Clear code: Use separate statements when several updates would be confusing.

Reference table

↔ Scroll horizontally on a small screen
Start with x = 5 for each row
StatementValue assigned to yFinal x
y = ++x;66
y = x++;56
y = --x;44
y = x--;54

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int x = 5;
    int before = x++;
    int after = ++x;
    printf("before = %d\n", before);
    printf("after = %d\n", after);
    printf("x = %d\n", x);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

before = 5
after = 7
x = 7

Key points

  • Prefix and postfix differ when their expression value is used.
  • Use separate statements when sequencing matters.

QUESTION 65 · Operators

What does total += 5 mean?

2 marks

Answer

total += 5 adds 5 to total and stores the result back in total.

  • If total is an int containing 10, total += 5; changes it to 15.
  • The destination must be writable. In compound assignment, the left operand is evaluated only once.

QUESTION 66 · Operators

Explain simple and compound assignment operators.

5 marks

Answer in brief

Assignment operators store a value in a writable object, such as an ordinary variable. The simple assignment operator is =.

Simple assignment

In total = 20;, the value 20 is stored in total. In total = a + b;, the right-hand expression is calculated first and its result is converted to the type of total for storage. The left side must be a valid destination; 20 = total; is invalid.

Compound assignment

  1. +=: total += 5 adds 5 to total.
  2. -=: total -= 5 subtracts 5.
  3. *=: total *= 5 multiplies by 5.
  4. /=: total /= 5 divides by 5 using the relevant arithmetic types.
  5. %=: total %= 5 stores the integer remainder.
  6. Bitwise forms: &=, |=, ^=, <<= and >>= combine a bit operation with assignment.

Worked example

Starting with int total = 10;, total += 5; gives 15. Next, total *= 2; gives 30. Finally, total -= 4; gives 26. For a simple variable, total += 5 has the usual effect of total = total + 5. A compound assignment evaluates its left operand only once.

Important points

= assigns; == compares. Assignment operators group from right to left: a = b = 0 stores zero in b and then a, when their types permit it. Do not divide by zero. Check whether a conversion loses a fraction or whether arithmetic exceeds the type range. A const-qualified object cannot be assigned a new value through that object.

Reference table

↔ Scroll horizontally on a small screen
Assignment forms
FormSimple-variable explanation
x = yStore the converted value of y in x.
x += yAdd y to x and store the result in x.
x -= ySubtract y from x.
x *= yMultiply x by y.
x /= yDivide x by y, respecting the operand types.
x %= yStore the integer remainder.
x &= maskApply bitwise AND and store the result.
x <<= countShift and store the result, subject to valid shift rules.

Key points

  • = assigns; == compares.
  • The stored result is converted to the destination type.

QUESTION 67 · Expressions and conversions

Distinguish an expression from an expression statement.

2 marks

Answer

An expression performs an operation, such as calculating a sum or assigning a value. A semicolon after an expression forms an expression statement.

  • a + b is an expression. a + b; is a statement that discards the calculated sum.
  • total = 5; is an expression statement that stores 5. int total = 5; is a declaration with initialisation.

QUESTION 68 · Expressions and conversions

Define an expression and explain how its type affects the result.

5 marks

Answer in brief

An expression combines values, variables, operators or function calls to perform a calculation or another operation.

Parts of an expression

  1. Operands: The values or objects used, such as a, b and 10.
  2. Operators: The operations performed, such as + or *.
  3. Parentheses: Show the intended grouping, such as (a + b) * 2.

Types and examples

  1. Arithmetic: a + b * 2 calculates a numeric result.
  2. Relational: a > b produces 1 or 0.
  3. Logical: a > 0 && b > 0 tests two conditions.
  4. Assignment: total = 5 stores a value.
  5. Conditional: a > b ? a : b selects a value.

Expression and expression statement

a + b is an expression. Adding a semicolon gives the expression statement a + b;. That statement calculates the sum and discards it. total = a + b; is useful because it stores the result. int total = 5; is a declaration with initialisation, rather than an expression statement.

Evaluation example

For a = 4 and b = 3, a + b * 2 gives 10 because multiplication groups before addition. (a + b) * 2 gives 14. Operand types also matter: 7 / 2 gives 3, whereas 7.0 / 2 gives 3.5. Avoid expressions that change the same variable without the ordering required by C.

Reference table

↔ Scroll horizontally on a small screen
Expression examples
ExpressionWhat it does
a + b * 2Computes an arithmetic value.
score >= 40Produces an int truth value, 0 or 1.
total = 5Stores a value and has the assigned value as its result.
count++Modifies count and supplies its previous value.
printf("Hello")Calls a function; the call also has a return value.

Key points

  • Grouping, types and sequencing all matter.
  • An expression can have a value and also change program state.

QUESTION 69 · Expressions and conversions

Define precedence and associativity with examples.

2 marks

Answer

Precedence determines grouping across operator levels; associativity resolves grouping within one level.

  • 2 + 3 * 4 groups as 2 + (3 * 4), giving 14.
  • 20 / 5 * 2 groups as (20 / 5) * 2, giving 8. Grouping does not generally specify operand evaluation order.

QUESTION 70 · Expressions and conversions

Explain operator precedence and associativity with the correct precedence table.

5 marks

Answer in brief

Precedence and associativity determine how operators and operands are grouped in an expression.

Precedence

Precedence gives the priority between different operator levels. Multiplication has higher precedence than addition. Therefore 2 + 3 * 4 groups as 2 + (3 * 4) and gives 14. Parentheses can change the grouping: (2 + 3) * 4 gives 20.

Associativity

Associativity decides grouping when operators have the same precedence. Multiplication and division group from left to right. Thus 20 / 5 * 2 means (20 / 5) * 2 and gives 8. Assignment groups from right to left, so a = b = 5 means a = (b = 5).

Common priority levels

  1. Unary operations: Operators such as ! and unary minus group before multiplication.
  2. Multiplication level: *, / and % group before addition and subtraction.
  3. Comparison levels: Relational operators group before equality operators.
  4. Logical levels: && groups before ||.
  5. Assignment: Assignment has lower precedence than these arithmetic and logical operators. Refer to the complete table for all levels.

Important distinction

Grouping is not generally the order in which operands run. For example, multiplication grouping does not say which of two function calls runs first in f() * g(). Write separate statements when order matters. Parentheses improve readability but do not make an otherwise invalid multiple update valid.

Reference table

↔ Scroll horizontally on a small screen
C operator grouping, highest level first
LevelOperators or formsAssociativity
1Postfix: () call, [] subscript, . and ->, postfix ++ --Left to right
2Prefix ++ --, unary + -, ! ~, * indirection, & address, sizeof, _Alignof, casts (type)Right to left
3* / %Left to right
4+ -Left to right
5<< >>Left to right
6< <= > >=Left to right
7== !=Left to right
8Bitwise &Left to right
9Bitwise ^Left to right
10Bitwise |Left to right
11Logical &&Left to right
12Logical ||Left to right
13?:Right to left
14= += -= *= /= %= <<= >>= &= ^= |=Right to left
15Comma operator ,Left to right

Key points

  • Multiplication and addition must not share a precedence row.
  • Relational, equality, bitwise and logical levels are distinct.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • September 2023 · Q1(b) · 3 marks

    What are operator precedence rules?

    Paper P09 · page 1
  • January/February 2024 · Q3(b) · 6 marks

    Discuss the role of operator precedence in expression evaluation, with examples.

    Paper P10 · page 1
View all matching exam references →

QUESTION 71 · Expressions and conversions

Evaluate 8 + 12 / 5 * 2 using integer arithmetic.

2 marks

Answer

The result is 12.

  • 12 / 5 gives 2 because both operands are integers.
  • Division and multiplication group left to right: 2 × 2 = 4, then 8 + 4 = 12.

QUESTION 72 · Expressions and conversions

Evaluate C expressions step by step and distinguish grouping from evaluation order.

5 marks

Answer in brief

Expression evaluation means finding an expression’s result by applying its grouping rules, operand types and operator meanings.

Steps

  1. Identify types: Check whether operands are integers or floating-point values.
  2. Check parentheses: Use parentheses to identify explicitly grouped parts.
  3. Apply precedence and associativity: Determine which operands belong to each operator.
  4. Calculate valid operations: Use integer or floating-point arithmetic as required.
  5. Check the result: Make sure division is valid and values stay within the supported range.

Worked example: integer arithmetic

Evaluate 8 + 12 / 5 * 2. Division and multiplication have higher precedence than addition and group left to right. First, 12 / 5 gives 2 because both operands are integers. Next, 2 * 2 gives 4. Finally, 8 + 4 gives 12. Thus the result is 12.

Worked example: floating-point arithmetic

In 8 + 12.0 / 5 * 2, 12.0 is double. The division gives approximately 2.4, multiplication gives approximately 4.8, and addition gives approximately 12.8. Changing an operand type can therefore change the answer.

Important points

Do not assume that all operands are evaluated from left to right. Short-circuit operators provide particular ordering rules, but many operators do not. An expression such as i++ + ++i has undefined behaviour and no guaranteed numeric result. Divide only by a valid non-zero divisor, and avoid signed overflow.

Reference tables

↔ Scroll horizontally on a small screen
Evaluation without ambiguous side effects
ExpressionReasoningResult
8 + 12 / 5 * 212 / 5 = 2; 2 * 2 = 4; 8 + 412 (int)
(8 + 12) / 5 * 220 / 5 = 4; 4 * 28 (int)
5 / 2 + 0.5Integer division gives 2, then convert and add 0.52.5 (double)
5 / 2.0 + 0.5Floating division gives 2.5, then add 0.53.0 (double)
3 < 4 && 9 != 0Both comparisons are true1 (int)
↔ Scroll horizontally on a small screen
Trace 8 + 12 / 5 * 2
SubexpressionTypeResult
12 / 5int divided by int2
(12 / 5) * 2int multiplication4
8 + ((12 / 5) * 2)int addition12

Diagram or flowchart

The root addition combines 8 with a multiplication; that multiplication combines the integer quotient 12 divided by 5 with 2, producing 12 overall.
Expression grouping tree · Download diagram

Key points

  • Integer division happens before a later conversion can preserve a fraction.
  • Undefined behaviour is not a puzzle with one portable numerical answer.

QUESTION 73 · Expressions and conversions

What is implicit type conversion? Give an example.

2 marks

Answer

Implicit type conversion is a conversion performed automatically by C without a written cast.

  • In double value = 5;, integer 5 is converted to double, giving 5.0.
  • A conversion can lose information: converting 3.8 to int discards the fractional part.

QUESTION 74 · Expressions and conversions

Explain implicit type conversion, integer promotions and mixed-type arithmetic.

5 marks

Answer in brief

Implicit type conversion is a conversion performed automatically according to C rules, without writing a cast at that point.

Where conversions occur

  1. Initialisation: In double value = 5;, integer 5 is converted to double.
  2. Assignment: In int count = 3.8;, the fractional part is discarded and count becomes 3.
  3. Mixed arithmetic: In 5 + 2.5, the integer is converted to double and the result is 7.5.
  4. Function arguments: Arguments can be converted to the parameter types. Extra promotion rules apply to functions such as printf.

Integer promotions

Small integer types such as char and short commonly become int before arithmetic. If int cannot represent all values of the original type, the promotion uses unsigned int. This allows many calculations on smaller integer values to use a standard arithmetic type.

Advantages

  1. Convenience: The programmer does not need to write a cast for every permitted conversion.
  2. Mixed calculations: Values of different arithmetic types can be used together according to the language rules.

Limitations and example

Automatic conversion can lose information. Converting 3.8 to int discards .8. Mixing signed and unsigned integers can also produce unexpected comparisons, so check the types. In double average = 7 / 2;, integer division happens first and gives 3; only then is 3 converted to 3.0. Use 7.0 / 2 or convert an operand before division to obtain 3.5.

Reference table

↔ Scroll horizontally on a small screen
Where conversions occur
ContextExampleEffect
Integer promotionA short used in arithmeticOften promotes to int; unsigned int is used when int cannot represent all values.
Mixed arithmeticint + doubleThe integer value is converted for double arithmetic.
Assignmentdouble result = 5;The integer value is converted to double.
Narrowing assignmentint count = 3.9;A representable floating value is truncated toward zero, producing 3.
Variadic function argumentsprintf("%f", a_float)float is promoted to double.

Key points

  • Implicit does not mean harmless or lossless.
  • Signedness matters in comparisons and arithmetic.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • June 2022 · Q1(b) · 8 marks

    Explain different type-conversion techniques with examples.

    Paper P03 · page 1
  • January/February 2024 · Q1(b) · 1 marks

    What is the purpose of type conversion?

    Paper P08 · page 1
  • January/February 2024 · Q1(b) · 3 marks

    What is the need for type conversion? Explain.

    Paper P10 · page 1
View all matching exam references →

QUESTION 75 · Expressions and conversions

Why cast before integer division when a fractional result is needed?

2 marks

Answer

Cast an operand before division to obtain a fractional result from integer values. Casting after integer division cannot restore the discarded fraction.

  • For total = 7 and count = 2, (double)total / count gives 3.5.
  • (double)(total / count) gives 3.0 because 7 / 2 first gives integer 3.

QUESTION 76 · Expressions and conversions

Explain explicit type casting and distinguish casting before and after division.

5 marks

Answer in brief

Explicit type conversion uses a cast written by the programmer. Its syntax is (type) expression.

Purpose of a cast

A cast requests a conversion of an expression value to a specified type. For example, (double)total produces a double value from total. It does not change the declared type of total. Casts are useful when a particular arithmetic type is needed.

Cast before division

Let int total = 7 and count = 2;. In (double)total / count, total becomes 7.0 for the calculation. The division uses floating-point arithmetic and gives 3.5. This is useful when calculating an average from integer totals. The count must be non-zero.

Cast after division

In (double)(total / count), the integer division is performed first. 7 / 2 gives 3. Casting that result produces 3.0. The discarded fraction cannot be restored by a later cast. This is why the position of a cast matters.

Important points

  1. Original variable: A cast produces a converted value; total is still an int containing 7.
  2. Possible loss: Casting 3.8 to int gives 3 when representable.
  3. Range: A cast does not make every value fit the target type. Check the supported range.
  4. Clear purpose: Use a cast when the conversion is intended and understood. It should not be used merely to hide a compiler warning.

Reference table

↔ Scroll horizontally on a small screen
Casting around integer division
ExpressionFirst operationFinal double value
(double)total / countConvert 7 to 7.0; perform floating division3.5
(double)(total / count)Perform integer division 7 / 2 = 3; then convert3.0

C program and output

/* CodeBhavya | PPS AR25 | Learning example */
#include <stdio.h>
int main(void)
{
    int total = 7, count = 2;
    double before = (double)total / count;
    double after = (double)(total / count);
    printf("cast before division = %.1f\n", before);
    printf("cast after division = %.1f\n", after);
    printf("total remains int with value %d\n", total);
    return 0;
}

Sample input and output

This example uses values already written in the program.

Output

cast before division = 3.5
cast after division = 3.0
total remains int with value 7

Key points

  • Casting a value does not redeclare its variable.
  • Place a cast before the operation whose arithmetic type must change.

Related exam questions

Topic matches from the supplied JNTUH papers. Marks below are the printed allocations for those questions.

  • July 2021 · Q2(a) · 5 marks

    State the purpose of type casting and type conversion.

    Paper P04 · page 1
View all matching exam references →