⚡ TechVani: AI, Technology, Apps, Coding & Digital World
TechVaniAI • Technology • Apps • Coding • Digital World
HomeAI & TechAppsCodingFree AI ToolsStudent TechSecurityAboutContactPrivacy
TECHVANI // LEARN. BUILD. TEST.

Learn the tech. Build the idea.

Clear study notes, tested lab files and practical guides for coding, AI and digital safety.

Explore Latest →
šŸ¤– AI & TechAI news, tools & guides šŸ“± Apps & ToolsUseful apps & websites šŸ’» CodingProgramming & web development šŸŽ“ Student TechStudy & career technology šŸ” Cyber SecuritySafety & awareness

Latest Posts

Circuit Notebook theme

Exam Notes

šŸ“š BTech CSE Exam Notes

Find Semester 1-8 subjects in one place. Choose a semester and open the notes you need. This is a general study guide, not an official syllabus.

Open Exam Notes →🧪 Open Lab Files →

Exam Numericals & Study Series

Practice CPU scheduling and explore OS and DBMS topics in separate, easy-to-follow parts. New topics will appear in the hub as they are published.

Open Numericals Hub →

Start here and stay in touch

New to TechVani? Start with our free AI tools guide for students. It covers which tools to try and what to check before relying on an answer.

For step-by-step videos, visit SiteSudhar on YouTube.

Join TechVani on WhatsApp

Get new AI tools and coding guides in your WhatsApp Updates tab.

Browse Topics

Popular Posts

TechVani

Semester 1 Labs and Workshop | BTech CSE Practical Guide

Semester 1 - Page 6: Labs and Workshop. A general practical revision guide with 18 numbered topics, answered viva questions, checked examples and three complete C17 programs. It is not an official experiment list or machine operating procedure. Your assigned lab manual and instructor safety instructions determine what you may do.

Evidence rule: keep raw observations, actual code output, units, conditions and limitations. The measurement data on this page is explicitly illustrative. Never replace missing readings with a theory value.

Topic map

  1. Manual, scope and safety before the experiment
  2. Lab record and reproducibility
  3. Algorithm, flowchart and test plan
  4. C build steps and diagnostics
  5. Input, number classification and arithmetic limits
  6. Loops, functions, recursion and prime testing
  7. Arrays, matrices, searching and sorting
  8. Strings, pointers, records and files
  9. Mean, spread and measurement uncertainty
  10. Resolution, zero correction and significant figures
  11. Simple pendulum: length, period and gravity
  12. Graphs, slopes and model checks
  13. Other physics experiments: match the prescribed manual
  14. Low-voltage circuit measurement and meter connections
  15. Workshop drawings, dimensions and fit checks
  16. Tools, rotating machinery and supervised work
  17. Robotics practical: roles, ratings and test conditions
  18. Viva, debugging and submission integrity

1. Manual, scope and safety before the experiment

The assigned lab manual determines assessed experiments, equipment, procedure and record format. This page is a general first-semester guide, not an approved operating procedure. Read hazards, prerequisites, emergency arrangements and permitted materials before starting. Obtain instructor approval for electrical, chemical or mechanical work. Never work on live mains from a web example or operate a machine without training. Stop when equipment, readings or behaviour differ from the expected safe state.

Worked example: Before a low-voltage resistor exercise, identify the source limit, resistor rating, meter terminals and schematic. Ask the instructor to check it before applying power.
Viva question: What takes priority when these notes differ from the lab manual?
Answer: The approved local manual and instructor safety instructions. Resolve the difference before starting work.

2. Lab record and reproducibility

A useful record contains aim, theory, apparatus or software version, method, raw observations, calculations, actual output, result, limitations and references. Record conditions and units. Keep raw values unchanged and show corrections separately. A worked illustration is not evidence that you performed an experiment. Missing data must be marked missing, not replaced with a theory value. Record failures and fixes because they explain what was actually tested.

Worked example: For a program, keep compiler command, warnings, input and observed output. For a measurement, keep trial number, instrument settings and raw reading before the calculated result.
Viva question: Why keep raw readings?
Answer: They allow the calculations to be checked and prevent rounded or interpreted values from being mistaken for observations.
Approved plan + safety + input contractPerform test / record raw observationCalculate + compare + inspect limitsChecked result + uncertainty + recordA failed check leads to a documented new test
Do not skip straight from theory to a claimed result. Keep the observation and the calculation distinct.

3. Algorithm, flowchart and test plan

State the problem and valid input range before coding. Write an algorithm or pseudocode with clear branches and stopping conditions. A flowchart uses conventional input/output, process and decision symbols with labelled paths. Plan normal, boundary and invalid tests before relying on a successful run. Include expected behaviour, then compare actual results. A test that passes only for one convenient value is not enough to establish a general claim.

Worked example: For a calculator, test 8 / 2, 8 / 0, an unsupported operator, malformed input and a non-finite value. Different cases exercise different checks.
Viva question: How does a test plan differ from sample output?
Answer: A test plan states cases and expected behaviour in advance. Sample output records what actually happened for specified inputs.

4. C build steps and diagnostics

C source is preprocessed, compiled and linked into an executable. Syntax errors, linker errors, runtime failures and wrong answers require different investigation. Use warnings as evidence to inspect, not something to silence blindly. The programs below use C17 and strict warnings. Run each as a separate file. Compiler success does not prove absence of undefined behaviour or logic errors; inspect contracts and test paths.

Worked example: Compile with gcc -std=c17 -Wall -Wextra -Wpedantic -Werror file.c -o program. Record the real outcome. A missing function definition can produce a linker error even if its call was syntactically valid.
Viva question: What is the difference between a compiler error and a logic error?
Answer: A compiler error prevents translation; a logic error may compile and run but produce the wrong behaviour.

5. Input, number classification and arithmetic limits

Check whether input conversion succeeded before using a value. State the accepted domain and guard division by zero. Signed integer overflow is not a safe wraparound rule in C. Floating-point results have finite precision and may be non-finite. For even or odd classification, n%2==0 detects even numbers, including negative even values. Do not assume that an arbitrary out-of-range numeric token is safely rejected by scanf; robust general parsing requires a bounded line and range-checked conversion.

Worked example: The calculator accepts representable finite double values and a supported operator. It rejects a zero divisor and a non-finite result. Its input contract is narrower than a general hostile-input parser.
Viva question: Why is checking scanf return value necessary?
Answer: Failed conversion may leave objects without the intended new value. Using them can produce invalid behaviour or misleading results.

6. Loops, functions, recursion and prime testing

Choose loops with clear bounds and write function preconditions. Recursion requires a base case and progress toward it; avoid deep unbounded recursion. Test factorial zero and overflow limits, Fibonacci base cases, digit operations and GCD as appropriate to the assignment. A prime test rejects values below 2 and checks possible divisors up to the square root. For positive integers, d<=n/d avoids the possible overflow of d*d. Existing C core notes provide the checked prime, GCD and factorial implementations.

Worked example: 1 is not prime. For 0 through 10, primes are 2, 3, 5 and 7. Factorial grows quickly, so a finite machine type needs a documented upper bound or checked multiplication.
Viva question: Why can i*i<=n be unsafe for a large integer?
Answer: The multiplication can overflow before the comparison. A mathematically correct bound needs a machine-safe implementation.

7. Arrays, matrices, searching and sorting

Validate count before indexing; for n elements, legal indices are 0 through n-1. Define what an empty input means before finding a minimum or maximum. Matrix addition needs equal dimensions; multiplication needs compatible inner dimensions. Linear search works on unsorted input; binary search needs the stated ordering. A sorting test should check ordering and preservation of the input elements, including duplicates. Do not hide the accepted size limit.

Worked example: The array program accepts 1 to 20 values, each finite and within ±1000000. Input 3 2 4 6 gives sum 12 and mean 4. Count zero is rejected before accessing a[0].
Viva question: Why does a maximum function need a nonempty-array contract?
Answer: There is no first element or maximum to read for an empty array unless the interface defines a separate empty-case result.

8. Strings, pointers, records and files

A C string needs a terminating null character. Use bounded input and document truncation or rejection. Pass unsigned-char values to character classification functions when reading arbitrary byte values. Pointer access needs a valid live object and correct bounds. Structures group records; dynamic allocation requires size checks, failure handling and release. File work requires checking open, read, write and close outcomes as relevant. Practise these with the complete tested C core programs rather than copying fragments without contracts.

Worked example: The vowel program accepts a text line up to 79 characters. It handles spaces, empty lines and a final line without newline. A longer line is rejected rather than silently treated as the complete input.
Viva question: Why is a pointer being non-null not enough to prove safe access?
Answer: It may be dangling, out of bounds, misaligned or otherwise not point to a valid object for that operation.

9. Mean, spread and measurement uncertainty

Repeat measurements to examine variation, but repetition does not remove every bias. The sample mean is sum/n; sample standard deviation uses n-1 for n>1. For independent repeated readings under suitable conditions, uncertainty of the mean from repeatability is s/√n. Instrument calibration, resolution and other effects may add uncertainty. Type A and Type B describe evaluation methods, not a simple synonym for random and systematic error. Do not report only the preferred theoretical answer.

Worked example: Five illustrative periods 2.01, 2.03, 1.99, 2.02 and 2.00 s have mean 2.01 s, sample standard deviation 0.015811 s and repeatability standard uncertainty of the mean 0.007071 s. These are practice values.
Viva question: Does more repetition eliminate a wrong length calibration?
Answer: No. A shared systematic effect may remain in every trial and must be assessed separately.

10. Resolution, zero correction and significant figures

Resolution is an instrument reading increment; accuracy is agreement with a reference, and precision concerns repeated agreement. Inspect zero and calibration under the approved method. Define signed zero error so that corrected reading=observed reading-zero error. Vernier and micrometer least-count methods depend on instrument design; use the actual scale and manual. Round the final reported value to a precision justified by uncertainty, keeping guard digits in intermediate calculation.

Worked example: If an instrument reads +0.02 mm at true zero, an observed 5.34 mm corrects to 5.32 mm under that convention. A 0.01 mm scale step does not prove the instrument is accurate to 0.01 mm.
Viva question: Why keep extra digits during calculation?
Answer: Premature rounding can shift the final value. Round the reported result based on its justified uncertainty and units.

11. Simple pendulum: length, period and gravity

For a simple pendulum at small amplitude, T≈2Ļ€√(L/g). Measure L from pivot to bob center and use the prescribed small-angle release without a push. Time N complete oscillations and use T=t/N. State timing and length uncertainties, air resistance and pivot effects. The formula assumes a suitable simple-pendulum model and small-angle approximation. A long-amplitude swing or an incorrectly measured length can invalidate the simple inference.

Worked example: For L=1.00 m and mean T=2.01 s, g=4Ļ€²L/T²=9.7716 m/s². For 20 oscillations at that period, total time is 40.2 s. These are illustrative calculations, not measured results.
Viva question: Why time many oscillations rather than one?
Answer: A similar start/stop timing error is spread over a larger total interval when computing period, though other errors still remain.
PivotLĪøMeasure L to the bob center
Simple-pendulum model. Use the approved small-angle method; the sketch is schematic, not a measured geometry.

12. Graphs, slopes and model checks

Label axes, units and conditions. Use a table for raw values and a graph to test the model. A best-fit line uses all relevant points under a chosen fitting method; do not join noisy points and call that a fit. State whether the intercept is constrained and why. For pendulum data, T² versus L has ideal slope 4Ļ€²/g. A result should include the fit method and uncertainty where available. Outliers require a documented reason before exclusion.

Worked example: If an illustrative T²-versus-L slope is 4.02 s²/m, g=4Ļ€²/4.02=9.8205 m/s². The unit check is m/s². A slope uncertainty changes the inferred gravity uncertainty.
Viva question: Why not force every graph through the origin?
Answer: The model and measurement process must justify that constraint. An unexamined offset can hide a systematic effect.

13. Other physics experiments: match the prescribed manual

First-year physics labs may include dimensional measurement, optical or electrical experiments, resonance, material properties and instrument calibration. The exact list varies. For every experiment, identify measured quantities, governing relation, calibration, graph or calculation and uncertainty sources. Follow the specified setup, not an invented universal list. Laser or high-voltage equipment requires the approved safety route. Do not look into beams or open protected equipment to obtain a reading.

Worked example: An optics record should distinguish the distance read from the instrument from a calculated wavelength or angle, and state which relation and units produced the result.
Viva question: How should an unfamiliar experiment be prepared?
Answer: Read the approved aim, theory, equipment limits and safety instructions, then ask the instructor about any unclear condition before operating it.

14. Low-voltage circuit measurement and meter connections

Use only the instructor-approved low-voltage setup. Verify wiring with the source off, meter mode, terminals, polarity and range before power is applied. A voltmeter measures across the element, in parallel; an ammeter measures branch current, in series. Never connect a current-mode meter directly across a source. Real meters load a circuit; component tolerance and source behaviour matter. Turn power off before changing connections and discharge stored energy as instructed.

Worked example: An ideal 5 V across 1 kΩ gives 5 mA and 25 mW. A 4.9 mA measured current differs from the ideal estimate by 2% relative to 5 mA; that difference alone does not identify its cause.
Viva question: Why is the ammeter placed in series?
Answer: Its path must carry the branch current being measured. Across a source it can create a low-resistance fault path.

15. Workshop drawings, dimensions and fit checks

A workshop record links the drawing, material, allowed tolerances, tools, procedure and inspection. Read real dimensions rather than measuring a resized screenshot. Check projection convention and identify reference surfaces. Record the approved process and actual fit or measurement. A plan to cut or drill is not a reason to omit a tool-specific safety check. An acceptable-looking part may still fail dimensional tolerance.

Worked example: A shaft from 19.98 to 20.00 mm and a hole from 20.02 to 20.04 mm give clearance from 0.02 to 0.06 mm. Record the actual inspection separately from this design-range calculation.
Viva question: Why must a drawing include tolerances?
Answer: Manufactured dimensions vary; tolerances define the allowed range needed for function, fit and inspection.

16. Tools, rotating machinery and supervised work

Only trained permitted users should operate workshop machines. Use the approved guards, eye protection and material limits. Secure hair and loose clothing and remove jewellery under the local rules. Gloves can create entanglement hazards around rotating machinery; follow the machine-specific instruction rather than treating gloves as universally safe PPE. Keep hands away from moving tools and stop the machine before the permitted inspection or adjustment. Never remove guards or improvise a repair from these notes.

Worked example: The cited lathe training guide requires safety glasses, secure clothing and no gloves during operation. This is a safety example, not permission or a complete operating procedure.
Viva question: Why is generic "wear gloves" advice unsafe at a lathe?
Answer: Rotating parts can catch gloves and pull the hand in. PPE must match the machine-specific risk and approved procedure.

17. Robotics practical: roles, ratings and test conditions

Separate sensor, controller, motor driver, actuator and power supply in the diagram. A controller pin is not a motor supply. Check voltage, current and mechanical limits through the approved low-voltage plan. Record sensor readings and the control rule before movement. Define track, lighting, load, trial count and success criterion. A closed-loop design measures output but still needs timing, gain and stability checks. Stop safely when behaviour is unexpected.

Worked example: For a line-following test, record sensor state, motor command and path outcome over stated conditions. Do not claim outdoor reliability from indoor trials.
Viva question: Why state lighting conditions?
Answer: Many optical sensors depend on ambient light, so unrecorded changes may explain a different result and prevent reproducibility.

18. Viva, debugging and submission integrity

Explain the governing rule, preconditions, error cases, units and limitations in your own words. Show actual compile/run or measurement evidence when asked. A clean report does not justify fabricated results. Cite borrowed code or figures, state your own contribution and remove secrets or personal data from public submissions. Keep source files and raw records so a result can be checked. A failure is useful when its cause and next test are honestly explained.

Worked example: If a program fails an empty input case, record the failure, fix the input contract or handling, then rerun that case and the earlier passing cases. Do not replace the log with an invented success.
Viva question: What should be said if an experiment was not performed?
Answer: State that it was not performed. An example calculation or simulated result must be labelled as such rather than presented as a measurement.

Three complete C17 lab programs

Run one file at a time. Each was compiled with gcc -std=c17 -Wall -Wextra -Wpedantic -Werror file.c -o program. There are 21 checked runs across the normal, boundary and rejection cases. The numeric examples require representable input tokens; the calculator is an ordinary classroom finite-double exercise, not a complete hostile-input parser.

Calculator with checked conversion and zero divisor

Input format is number, operator, number, such as 8 / 2. Supported operators are +, -, * and /. Floating-point results have implementation limits; extreme-input handling is not a claim of a portable arbitrary-precision parser.

#include <stdio.h>
#include <math.h>
int main(void) {
    double a, b, result;
    char op;
    if (scanf("%lf %c %lf", &a, &op, &b) != 3 ||
        !isfinite(a) || !isfinite(b)) {
        puts("Invalid input");
        return 1;
    }
    switch (op) {
        case '+': result = a + b; break;
        case '-': result = a - b; break;
        case '*': result = a * b; break;
        case '/':
            if (b == 0.0) {
                puts("Division by zero");
                return 1;
            }
            result = a / b;
            break;
        default: puts("Invalid operator"); return 1;
    }
    if (!isfinite(result)) {
        puts("Result outside finite range");
        return 1;
    }
    printf("Result: %.3f\n", result);
    return 0;
}

Checked first run input: 8 / 2

Result: 4.000
TestObserved outcomeExit code
8 / 2Result: 4.0000
8 / 0Division by zero1
8 + 2Result: 10.0000
8 ? 2Invalid operator1
badInvalid input1
nan + 2Invalid input1
1e308 * 1e308Result outside finite range1

Bounded array sum, mean, minimum and maximum

Input is count followed by that many numbers. Count must be a representable int from 1 to 20; values must be finite with magnitude at most 1000000. The bound keeps the sum finite in the tested implementation.

#include <stdio.h>
#include <math.h>
int main(void) {
    int n;
    double a[20], sum = 0.0, low, high;
    if (scanf("%d", &n) != 1 || n < 1 || n > 20) {
        puts("Invalid count");
        return 1;
    }
    for (int i = 0; i < n; ++i) {
        if (scanf("%lf", &a[i]) != 1 || !isfinite(a[i]) ||
            fabs(a[i]) > 1000000.0) {
            puts("Invalid value");
            return 1;
        }
        sum += a[i];
    }
    low = high = a[0];
    for (int i = 1; i < n; ++i) {
        if (a[i] < low) low = a[i];
        if (a[i] > high) high = a[i];
    }
    printf("sum=%.3f mean=%.3f min=%.3f max=%.3f\n",
           sum, sum / n, low, high);
    return 0;
}

Checked first run input: 3 2 4 6

sum=12.000 mean=4.000 min=2.000 max=6.000
TestObserved outcomeExit code
3 2 4 6sum=12.000 mean=4.000 min=2.000 max=6.0000
0Invalid count1
21Invalid count1
3 -2 0 2sum=0.000 mean=0.000 min=-2.000 max=2.0000
1 7sum=7.000 mean=7.000 min=7.000 max=7.0000
2 3 badInvalid value1
1 infInvalid value1

Bounded line vowel count

Text-line exercise: accepts up to 79 characters before newline or end-of-file. Handles empty line and spaces, rejects longer lines. Embedded null bytes and arbitrary binary streams are outside this text-input contract.

#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void) {
    char line[80];
    int ch, vowels = 0;
    if (!fgets(line, sizeof line, stdin)) {
        puts("No line");
        return 1;
    }
    if (!strchr(line, '\n') && !feof(stdin)) {
        ch = getchar();
        if (ch != '\n' && ch != EOF) {
            while ((ch = getchar()) != '\n' && ch != EOF) { }
            puts("Line too long");
            return 1;
        }
    }
    line[strcspn(line, "\n")] = '\0';
    for (size_t i = 0; line[i] != '\0'; ++i) {
        int c = tolower((unsigned char)line[i]);
        if (c == 'a' || c == 'e' || c == 'i' ||
            c == 'o' || c == 'u') ++vowels;
    }
    printf("vowels=%d\n", vowels);
    return 0;
}

Checked first run input: Hello World

vowels=3
TestObserved outcomeExit code
Hello Worldvowels=30
empty linevowels=00
AEIOUvowels=50
shortvowels=10
79 charactersvowels=00
80 charactersLine too long1
empty streamNo line1

Illustrative pendulum record and checked calculation

These are invented practice periods for calculation, not a record of an experiment. Assumed length is 1.00 m and each total time covers 20 oscillations. Do not submit this table as your observations.

TrialLength (m)NTotal time (s)T (s)g (m/s²)
11.002040.202.019.7716
21.002040.602.039.5800
31.002039.801.999.9690
41.002040.402.029.6751
51.002040.002.009.8696

Mean period=2.01 s. Sample standard deviation=0.015811 s. Repeatability standard uncertainty of the mean=0.007071 s under independent-repeat assumptions. Gravity calculated from the mean period=9.7716 m/s². Mean of separately calculated gravity values is not exactly the same because the formula is nonlinear. Length and instrument effects are not included in the repeatability figure.

Final submission checklist

  • Correct manual and approved safety procedure, aim and apparatus/software details.
  • Raw readings or source code with actual execution evidence.
  • Units, input limits, normal/boundary/rejection cases and justified precision.
  • Calculations or graphs checked against the raw record.
  • Limitations, uncertainty and failed tests honestly reported.
  • Real references and own contribution identified; no passwords or private data.

Lab resources

Further study and related notes

Use your assigned lab manual for the experiment list and procedure. Read the full topic explanations in the semester notes:

Comments