\n
Subject: Programming for Problem Solving (C)

Unit 1: C Fundamentals.

Comprehensive study guide covering computer basics, algorithms, and core C syntax tailored for JNTUK R23 exams.

High Probability Unit
14 Marks Target

01. Topic Archive

🧠 Core Concept

Computer Overview

Functional units of computer, Input/Output devices, and basic memory organization.

Jump to Notes →
🔥 High Probability

Problem Solving

Algorithms, Flowcharts, and Pseudo-code construction. Guaranteed 7-mark question area.

Jump to Notes →
⭐ Most Expected

C Language Syntax

Data types, Storage classes, Operators, and Input/Output functions in C.

Jump to Notes →

02. Full Notes

Introduction to Computers

A computer is an electronic device that processes data according to set of instructions. In the context of JNTUK exams, you must remember the functional units:

  • Input Unit: Devices like Keyboard, Mouse that help enter data.
  • Central Processing Unit (CPU): The brain. Contains ALU (Arithmetic Logic Unit) and CU (Control Unit).
  • Output Unit: Monitor, Printer displaying results.
  • Memory Unit: Primary (RAM) and Secondary (Hard disk) storage.
🚨 Frequently Asked: Algorithm vs Flowchart

Algorithm & Flowcharts

Algorithm: A step-by-step logical procedure to solve a problem. It should be finite, definite, and effective.

Flowchart: A pictorial representation of an algorithm. Use standard symbols:

Oval
Start/End
Rectangle
Process
Diamond
Decision
Parallelogram
Input/Output

Structure of a C Program

Quick Start: A C program is a collection of sections that tell the compiler how to handle the code. It starts with header files (Link Section), definitions, and global variables, centered around the main() function where execution begins.

A standard C program follows this hierarchy, which is a common 5-mark question:

/* Documentation Section */ #include <stdio.h> // Link Section #define PI 3.14 // Definition Section int a; // Global Declaration int main() { // Main Function /* Executive Block */ printf("Hello JNTUK!"); return 0; }

C Data Types

Quick Start: Data types declare the kind of data a variable stores. C uses int (integers), char (letters), float/double (decimals), and void. Each type has a specific size and format specifier (like %d for int) used in I/O.

C is a statically typed language. Memorize this table:

Type Keyword Size (16-bit) Format
Integer int 2 Bytes %d
Character char 1 Byte %c
Floating Point float 4 Bytes %f
JNTUK R23 Academy Compendium

I. Advanced C Language Mechanics

A curated authoritative reference index covering compiler phases, storage classes, system busses, and logic control paradigms.

1. Functional Computer Hardware Architecture

A computer is an organized collection of functional units operating in mechanical harmony. The CPU orchestrates instructions by communicating with primary and secondary memory storage channels over electrical lines termed System Busses.

  • Data Bus: Transports actual binary operand values between register files, CPU accumulators, and memory blocks. Its width (e.g., 32-bit or 64-bit) determines how many bits the system can fetch simultaneously.
  • Address Bus: Carries the physical address coordinates of memory cells that the CPU wishes to read from or write to. A 32-bit address bus can access up to 4GB ($2^{32}$ locations) of memory space.
  • Control Bus: Transmits timing signals, read/write commands, clock cycles, and interrupt signals to regulate hardware synchronization.

2. Life-Cycle of a C Source Code Execution

C is a compiled language. Solidifying your understanding of how human-written src.c converts into machine-runnable object.exe is critical for both university exams and system development.

Source Code file.c
Preprocessed file.i
Assembly file.s
Executable file.exe
  • Preprocessing (Pre-compilation): Translates lines starting with # (preprocessor directives). It expands macroscopic constants, copies header file definitions directly into the stream, and strips comments. Output: file.i.
  • Compilation: Syntactically parses the preprocessed stream, translating C statements into system-specific Assembly instructions (such as x86 or ARM assembly). Output: file.s.
  • Assembly: Translates assembly-specific Mnemonics into raw binary MACHINE CODE instructions, creating relocatable object files. Output: file.o or file.obj.
  • Linking: Links object files with pre-compiled compiler libraries (like stdio.h code binaries) to resolve reference boundaries, yielding a unified runnable file. Output: file.exe or standard machine files.

3. Byte Representation & Complement Mathematics

How are characters, positive and negative integers, and fractional numbers stored inside memory blocks? JNTUK R23 curriculum demands mastery over these binary schemes.

Integer Sign Conventions

For signed data types, the Most Significant Bit (MSB) acts as the sign flag (0 = positive, 1 = negative). Negative integers are stored using **Two's Complement Representation**, as it simplifies CPU arithmetic logic by allowing addition and subtraction to use the same hardware path.

Representing -5 in 8-bit binary:
Step 1: Write positive 5 => 0000 0101
Step 2: One's Complement (flip bits) => 1111 1010
Step 3: Add 1 => 1111 1011 (This is -5 as a signed integer)

IEEE 754 Floating-Point Standard

Real and decimal values cannot be stored using standard sign flags. Under the IEEE 754 standard, single-precision floats (4 Bytes) partition their 32 bits into three logical components to balance range and precision:

[ Sign Bit (1 bit) ] [ Biased Exponent (8 bits) ] [ Mantissa/Fraction (23 bits) ]

Double-precision decimals utilize 64 bits total, devoting 1 bit to the sign, 11 bits to the exponent, and 52 bits to the mantissa to represent values with a higher degree of precision.

4. Variable Scope, Lifetime & Storage Classes

A storage class defines where a variable is stored (memory or CPU registers), its initial default values, its visibility scope, and its lifetime. This is a common 7-to-10 mark question in university exams.

Storage Class Location Default Value Scope Lifetime
auto RAM Memory Garbage Value Local (Block) Dynamic (Exit of Block)
register CPU Register Garbage Value Local (Block) Dynamic (Exit of Block)
static RAM Memory Zero (0) Local (Block) Global (End of Program)
extern RAM Memory Zero (0) Global (Multi-file) Global (End of Program)

5. Bitwise Operators & Truth Tables

Bitwise operators manipulate the individual bits of an operand directly. These operations are highly efficient and are commonly used in low-level driver development, data encryption, and performance optimization.

Bitwise AND (&):

Output bit is set to 1 only if BOTH input bits are 1.

5 & 3 => 0101 & 0011
Output = 0001 (Decimal 1)
Bitwise OR (|):

Output bit is set to 1 if AT LEAST ONE input bit is 1.

5 | 3 => 0101 | 0011
Output = 0111 (Decimal 7)
Bitwise XOR (^):

Output bit is set to 1 if the input bits are DIFFERENT.

5 ^ 3 => 0101 ^ 0011
Output = 0110 (Decimal 6)

6. High-Yield Code Walkthroughs (JNTUK Likely)

This section includes fully documented, standard C programs that are highly likely to appear on exam question papers, verified for R23 syllabus compliance.

Program A: Roots of Quadratic Equation

Handles imaginary, real, distinct, and single identical root conditions cleanly using <math.h>.

#include <stdio.h> #include <math.h> int main() { double a, b, c, disc, r1, r2, real, imag; printf("Enter coefficients a, b and c: "); scanf("%lf %lf %lf", &a, &b, &c); disc = b * b - 4 * a * c; if (disc > 0) { r1 = (-b + sqrt(disc)) / (2 * a); r2 = (-b - sqrt(disc)) / (2 * a); printf("Roots are real and distinct: Root1 = %.2lf, Root2 = %.2lf\n", r1, r2); } else if (disc == 0) { r1 = r2 = -b / (2 * a); printf("Roots are real and identical: Root1 = Root2 = %.2lf\n", r1); } else { real = -b / (2 * a); imag = sqrt(-disc) / (2 * a); printf("Roots are imaginary: r1 = %.2lf + i%.2lf, r2 = %.2lf - i%.2lf\n", real, imag, real, imag); } return 0; }

Program B: Multi-Action Arithmetic Calculator

Implements an interactive console calculator using the C switch control structure.

#include <stdio.h> int main() { char opt; double n1, n2; printf("Enter operator (+, -, *, /): "); scanf(" %c", &opt); printf("Enter two operands: "); scanf("%lf %lf", &n1, &n2); switch (opt) { case '+': printf("%.1lf + %.1lf = %.1lf\n", n1, n2, n1 + n2); break; case '-': printf("%.1lf - %.1lf = %.1lf\n", n1, n2, n1 - n2); break; case '*': printf("%.1lf * %.1lf = %.1lf\n", n1, n2, n1 * n2); break; case '/': if (n2 != 0.0) { printf("%.1lf / %.1lf = %.1lf\n", n1, n2, n1 / n2); } else { printf("Error! Division by zero is mathematically undefined.\n"); } break; default: printf("Error! Operator is not supported.\n"); } return 0; }

7. Preprocessor Directives & Macro Expansions

Lines that begin with # are direct instructions to the preprocessor (run before the compilation stage). This is another high-probability topic in JNTUK R23 exams.

  • File Inclusion (#include): Tells the preprocessor to replace this line with the entire raw text of the specified file (for example, <stdio.h> contains standard input/output prototypes).
  • Macro Definition (#define): Instructs the preprocessor to replace all occurrences of a macro identifier with a given replacement pattern during preprocessing.
  • Conditional Compilation (#ifdef, #ifndef, #endif): Allows sections of code to be compiled selectively based on whether a specific macro constant has been defined, representing an excellent way to maintain cross-platform codebases.

03. Cheat Sheet

Operators Shortcut

  • Arithmetic + - * / %
  • Relational > < >= <= == !=
  • Logical && || !
  • Assignment = += -= *=
  • Special sizeof() & ,

Decision Making

Syntax for Switch statement (Common Question):

switch(expression) { case 1: // statement; break; case 2: // statement; break; default: // statement; }

04. Exam PYQs

5 Points Question Repeated 4x

Q: Explain the different data types available in C language?

View Solved Answer
10 Points Question Most Likely

Q: Define Algorithm & Flowchart. Differentiate them with a simple example.

View Solved Answer

06. Quick Revision

Memory Hack: Data Types

"Int is 2, Float is 4, Char is 1, Double is 8" (Bytes in 16-bit).

Operator Priority

P-U-A-R-L-A (Parenthesis, Unary, Arithmetic, Relational, Logical, Assignment).

⚡ Exam Mode

1-Day Before Prep Pack

Must Solve Programs

  • Largest of 3 numbers using nested-if
  • Calculator using Switch case
  • Roots of quadratic equation

Critical Theory

Repeated PYQ

Algorithm vs Flowchart symbols (Draw accurately!)

Conceptual

Structure of C Program (Define all sections)

Quick Formulas

// Ternary Operator
(condition) ? true : false;

// Type Cast
(float)sum/count;

Weightage Analysis

Problem Solving Techniques High (7-10M)
C Fundamentals & Syntax Medium (5-7M)
Computer Basics Low (2-4M)

Type Density Heatmap

Theory
Dense
MCQ
Lite
Program
Heavy
PYQ
Hot

Ready for Unit 2?

Explore Full Subject

Login via Dashboard to save your progress, secure your streak, and unlock AI features.

\n
EngiPrepHub Logo

About the Author

EngiPrepHub is an academic initiative aimed at providing high-quality, verified, and structured JNTUK R23 study notes, PYQs, and interactive tools for engineering students. Our materials are reviewed by expert students and engineers to ensure syllabus alignment.