You are on page 1of 8

PRACTICAL– 4

Ques. - There is an IT firm that pays assistants on a commission basis.


The commission is 25% of the monthly gross sale with an additional
amount of Rs. 1200 monthly. Write a C program to compute the
commission and prints it. For example, an assistant made a sale of Rs.
65000.00 in a month. The commission obtained is 25% of 65000 + 1200,
which is Rs. 17450.00

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;

// Input: Monthly gross sale amount


float saleAmount;
printf("Enter the monthly gross sale amount: ");
scanf("%f", &saleAmount);

// Calculating commission
float commission = saleAmount * commissionRate +
additionalAmount;

// Output: Print the commission


printf("The commission obtained is Rs. %.2f\n",
commission);

return 0;
}

V)Output

VI)Observation
 It helps figure out how much money assistants in an IT
company should get as commissions.

 By asking for how much money they made in sales that


month and using fixed values for the commission rate and
extra money, the program was able to find the right
commission.

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

Enrollment no.:22013I04070 Signature


Signature

Given Date: Submit Date:


Remark:
PRACTICAL-5

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;

// Input: Taking two numbers from the user


printf("Enter the first number: ");
scanf("%f", &num1);

printf("Enter the second number: ");


scanf("%f", &num2);

// Performing arithmetic operations and printing


results
printf("Sum: %.2f\n", num1 + num2);
printf("Difference: %.2f\n", num1 - num2);
printf("Product: %.2f\n", num1 * num2);

// Check if the second number is not zero before


division
if (num2 != 0) {
printf("Division: %.2f\n", num1 / num2);
} else {
printf("Division by zero is not possible.\n");
}

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

Enrollment no.:22013I04070 Signature


Signature

Given Date: Submit Date:


Remark:
PRACTICAL-6

Ques:Write a program to display the following patterns. In this


program user will enter the size of the pattern in terms of the rows, and
based on that, the pattern will adjust.

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

Nested loops are loops placed inside one another, allowing


for the execution of inner loop instructions for each iteration
of the outer loop.
In this practical, we utilize nested loops to create different
patterns, each with specific characteristics based on the
user's input. We also use conditional statements to manage
the printing of spaces and numbers/asterisks within the
patterns.

#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;

You might also like