Practical - 4
Practical - 4
Practical - 4
I)Objective:
To calculate and print the commission earned by an assistant
in an IT firm based on their monthly gross sales.
II)Requirement
Hardware Required:
A computer or device capable of running a C compiler.
Software Required:
A C compiler installed on the computer, such as GCC (GNU
Compiler Collection) or any suitable Integrated
Development Environment (IDE) that supports C
programming.Ex Replit,Online C compliler etc.
III)Theory:
The program calculates the commission earned by an
assistant in an IT firm. The commission is calculated as 25%
of the monthly gross sale amount plus an additional
fixed amount of Rs. 1200. The user is prompted to input the
monthly gross sale amount, and the program calculates the
commission using the given formula.
Here
printf: used to display formatted text output on the
screen.
used to read and store formatted input from the
user.
used to store decimal numbers with single
precision.
%f: format specifier used for decimal values
%.2f: used with printf to display a floating-point value
with two decimal places.
VI)Syntax
#include <stdio.h>
int main() {
// Constants
float commissionRate = 0.25; // 25%
float additionalAmount = 1200.0;
// Calculating commission
float commission = saleAmount * commissionRate +
additionalAmount;
return 0;
}
V)Output
VI)Observation
It helps figure out how much money assistants in an IT
company should get as commissions.
VII)Conclusion
This showed us how technology can make money calculations
in businesses easier and faster. It was a small but cool
example of how computers can be helpful in real life.
Student Summary
Student Faculty
Name:Yogyta Singh Name:Mr Rakesh Kumar
I)Objective:
To create a C program that takes two numbers from the user
and performs arithmetic operations (addition, subtraction,
multiplication, division) on them, printing the results.
II)Requirement
Hardware Required:
A computer or device capable of running a C compiler.
Software Required:
A C compiler installed on the computer, such as GCC (GNU
Compiler Collection) or any suitable Integrated
Development Environment (IDE) that supports C
programming.Ex Replit,Online C compliler etc.
III)Theory
It asks you for two numbers, then it adds them together,
subtracts one from the other, multiplies them, and divides
them if it's possible (when the second number is not zero). It's
like a calculator, but you write the instructions for the
computer to follow. This way, you can quickly get the results
of different math operations using the same program.
IV)Syntax
#include <stdio.h>
int main() {
float num1, num2;
return 0;
}
V)Output
VI)Observation
In this, we learned how to create a program that does math
with numbers. We understood the basics of user input,
arithmetic operations, and logic in programming. Handling
division by zero showed us the importance of dealing with
special cases. Overall, this practice provided a hands-on
introduction to fundamental programming concepts.
Student Summary
Student Faculty
Name:Yogyta Singh Name:Mr Rakesh Kumar
Objective
To create a C program that generates and displays various
patterns based on user input. The program should be able to
produce patterns on user’sinput consisting of
asterisks,
incrementing numbers,
Pascal's Triangle
II)Requirement
Hardware Required:
A computer or device capable of running a C compiler.
Software Required:
A C compiler installed on the computer, such as GCC (GNU
Compiler Collection) or any suitable Integrated
Development Environment (IDE) that supports C
programming.Ex Replit,Online C compliler etc.
Theory
In the C programming language, loops are structures that
enable you to repeat a block of code multiple times. The "for"
loop, "while" loop, and "do-while" loop are key loop types in C.
They allow you to execute instructions repeatedly as long as a
certain condition is true.There are also nested loops
#include <stdio.h>
int main() {
int rows;
// Input: Taking number of rows
from the user
printf("Enter the number of rows: ");
scanf("%d", &rows);
// Pattern 1: Asterisks
printf("Pattern 1:\n");
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
printf("* ");
}
printf("\n");
}
return 0;