Term Project for Section – A2
Group
A21
A22
A23
A24
A25
A26
Student ID
2310031-35
36-40
41-45
46-50
51-55
56-60
Assigned Problem
Q.1
Q.2
Q.3
Q.4
Q.5
Q.6
Submission guidelines
1. Project Report:
Submit a well-structured report that includes a clear objective, problem statement, and a thorough
explanation of the approach taken to solve the problem.
2. Code and Explanation:
Include the complete source code along with detailed explanations of each major section or function,
describing what each part of the code is responsible for.
3. Results and Discussion:
Present and discuss key results, highlighting significant observations, findings, and any challenges faced
during development.
4. Presentation Slides:
Prepare a concise and informative presentation that summarizes the project, methodology, key
outcomes, and conclusions.
Q.1 You
are
tasked
to
simulate
and
analyze
binomial
distributions
in
C.
Write a C program that:
1. Takes the following inputs from the user:
o Number of experiments/trials n (integer, n >= 1).
o Probability of success p (float, 0 < p < 1).
o Number of samples num_samples (integer, num_samples >= 1).
2. Simulates num_samples experiments, each with n independent Bernoulli trials with success
probability p.
3. Counts the number of successes in each experiment.
4. Generates and displays:
o A table showing the number of times each number of successes (from 0 to n) occurred.
o The experimental mean and variance of the distribution.
o The theoretical mean (n*p) and variance (n*p*(1-p)).
5. Finally, display a graphical histogram of success counts using asterisks (*).
Q.2 Write a C program that reads multiple measured quantities and their associated uncertainties, and
calculates the combined uncertainty assuming basic operations (addition, subtraction, multiplication,
or division) between them.
Input:
1. Your program should accept:
o The number of measured variables n (n ≥ 1).
o For each variable:
▪ The measured value (float).
▪ The absolute uncertainty (float).
2. The operation type:
o User will specify the overall type of operation between the variables:
▪ + for addition
▪ - for subtraction
▪ * for multiplication
▪ / for division
Processing and Tasks:
1. For Addition/Subtraction:
o The combined absolute uncertainty (ΔQ) is:
ΔQ = sqrt ( (ΔX₁)² + (ΔX₂)² + ... + (ΔXn)² )
2. For Multiplication/Division:
o The combined relative uncertainty (ΔQ/Q) is:
ΔQ/Q = sqrt ( (ΔX₁/X₁)² + (ΔX₂/X₂)² + ... + (ΔXn/Xn)² )
Then:
ΔQ = (ΔQ/Q) * Q
3. Calculate:
o The result Q by applying the chosen operation sequentially across the variables.
o The combined absolute uncertainty ΔQ.
o The relative uncertainty (as a percentage).
4. Display all results clearly.
Output:
1. Display all the input measured values and their uncertainties.
2. Display the calculated derived quantity Q.
3. Display the combined uncertainty ΔQ.
4. Display the relative uncertainty (percentage).
Q.3 Write a C program that calculates probabilities and related statistics for a Normal Distribution based
on user input.
Input:
1. Ask the user to provide:
o The mean (μ) of the distribution (float).
o The standard deviation (σ) of the distribution (float, σ > 0).
o A value of interest (x) for which the cumulative probability needs to be calculated.
2. Allow the user to choose what they want to compute:
o Option 1: Cumulative Probability P(X≤x)
o Option 2: Cumulative Probability P(X≥x)
o Option 3: Probability between two values P(a≤X≤b)
Processing and Tasks:
1. For a given x, first calculate the z-score:
z = (x - μ) / σ
2. Use an approximation formula for the standard normal cumulative distribution function
(CDF) to find probabilities.
Important:
o You cannot use external libraries like <math.h>'s error function (erf) or any special CDF
functions.
o You must approximate the cumulative probability using a series expansion, table
lookup, or simple approximation formula.
3. Based on the user's choice, compute:
o P(X≤x)
o P(X≥x)=1−P(X≤x)
o P(a≤X≤b)=P(X≤b)−P(X≤a)
Output:
1. Display the mean, standard deviation, and input values clearly.
2. Display the calculated probability up to 4 decimal places.
3. Mention if the input was invalid (like σ ≤ 0, or a > b).
Q.4 Write a C program that reads data from multiple groups, performs a One-Way Analysis of Variance
(ANOVA), and outputs a summary report.
Input:
1. Ask the user:
o Number of groups (minimum 2).
o For each group:
▪ Number of observations (minimum 2).
▪ Enter all the observations (floating-point numbers).
Processing:
You must calculate and report:
• The mean of each group.
• The overall mean (grand mean) considering all observations.
• The variance between the groups.
• The variance within the groups.
• The F-statistic to assess whether there are significant differences between groups.
Output:
1. Display:
o Means of each group.
o Grand mean.
o Sum of Squares between groups.
o Sum of Squares within groups.
o Degrees of Freedom (between groups and within groups).
o Mean Squares (between groups and within groups).
o F-statistic.
2. Show all results clearly, rounding off to 4 decimal places.
Important Constraints:
• Do not use any external libraries (e.g., for statistics).
• Handle invalid inputs gracefully (for example, standard deviation cannot be negative, number of
groups must be at least 2).
• Dynamic memory allocation must be used for storing observations.
• Allow saving the ANOVA summary into a file.
• Allow multiple runs without restarting the program.
Q.5 Write a C program that generates a simple QR code representation for a given text input.
Input:
• The user will enter a string of up to 100 characters (alphanumeric characters only — A-Z, a-z,
0-9).
• The program should check and validate the input (reject special characters).
Processing:
• Convert the input string into binary encoding.
• Based on the binary representation, create a grid (2D array) that visually simulates a QR code.
• Each bit:
o 1 should be represented by a black square (█) or #.
o 0 should be represented by a white space ( ) or ..
• Introduce simple padding/margin around the QR code to make it look clean.
• The program should handle variable input lengths by adjusting the grid size accordingly.
Output:
• Display the generated QR code on the console.
• Each row should be printed line by line, based on the grid data.
• The output should be readable and structured.
Important Constraints:
• You are not allowed to use any external QR code generation libraries.
• You must manually encode the string into a visual format.
• Only standard C libraries are allowed.
• Handle invalid inputs gracefully.
• Allow the user to save the QR code as a text file.
• Add simple error-correction by duplicating critical rows/columns.
• Allow adding a static "finder pattern" (like small squares at corners).
Q.6 Write a C program that implements a simple password protection system for a user.
The program should allow the user to:
1. Create an account with a username and password.
2. Login by providing the correct username and password.
3. Use "Forgot Password" option if they cannot remember their password.
Input Requirements:
1. Account Creation:
o Ask the user to set:
▪ A username (up to 20 characters, only letters and numbers).
▪ A password (at least 6 characters, must include at least one letter and one
number).
o Also ask the user to set a security question and answer for password recovery.
2. Login:
o Prompt the user to enter their username and password.
3. Forgot Password:
o If login fails, give the user an option:
▪ Answer their security question to reset the password.
Processing Logic:
•
•
During login, validate both the username and password.
If login fails:
o Offer the Forgot Password feature.
o If the user answers the security question correctly:
▪ Allow them to set a new password.
• Implement basic security checks:
o Password must follow minimum strength rules.
o Username must match exactly (case sensitive).
• Store all account information temporarily in memory (no file handling required for this
project).
Output Requirements:
• Clear messages:
o "Login Successful."
o "Incorrect Password."
o "Account Created Successfully."
o "Password Updated Successfully."
• In case of any input errors, provide appropriate error messages.
Important Constraints:
• No file storage (all operations must happen during the program’s execution).
• No external libraries for encryption, etc.
• Only standard C libraries allowed.