0% found this document useful (0 votes)
10 views

C Prog_Lab assignment 1 Writeup updated

Uploaded by

08adityajadhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

C Prog_Lab assignment 1 Writeup updated

Uploaded by

08adityajadhav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

K. K.

Wagh Institute of Engineering Education and Research, Nashik


(Autonomous from Academic Year 2022-23)
F. Y. B. Tech.
Pattern 2023 Semester: I
2300108A: Programming in C

Assignment No. 01
Title : Understand and implement basic concepts of C
Problem Statement:
In a departmental store, a customer is offered an x% discount on the printed price of each
commodity. The customer needs to pay y% sales tax on the discounted amount.

Draw a flowchart, write an algorithm / a pseudo-code and write a C program to calculate the amount
to be paid by the customer for a commodity using above conditions.
Also specify the machine configuration, Name and version of operating System and Compiler used
to compile and execute the program. List various steps and operating system commands that were
used to develop, compile and execute the program.
Prerequisites:
Hardware Requirement: Desktop Computer / laptop computer.
Software Requirement: Linux Operating System with GCC
Theory:
Characteristics of C
• Small size. C has only 32 keywords. This makes it relatively easy to learn.
• Makes extensive use of function calls.
• C is structured programming.
• It supports loose typing (as a character can be treated as an integer and vice versa).
• Facilitates low level (bitwise) programming
• Supports pointers to refer to computer memory, array, structures and functions.
• C is a Portable language.
• C is a core language
• C is an extensible language
Variable : An entity that may vary during the program are names given to locations in memory.
These locations can contain integer, real or character constants.
Data Types : Data types refer to an extensive system used for declaring variables or functions of
different types before its use. The type of a variable determines how much space it occupies in
storage and how the bit pattern stored is interpreted. The value of a variable can be changed any time.
C has the following 4 types of data types
basic built-in data types : int, float, double, char
Enumeration data type :enum
Derived data type: pointer, array, structure, union
Void data type: void
Objectives:
1. To get familiar with the syntax and structure of C- programming.
2. To learn problem solving techniques using C

Problem Analysis:
The problem is to calculate the amount to be paid by the customer having its input parameters
identified as: printed price (float type), x% discount (float type) and y% (float type). The output of
the program is to display the discounted amount and the final amount to be paid; hence the output
parameter is identified as discounted amount and final amount (float type).
The mathematical formula to calculate
Discounted amount = (printed price) – ((printed price * x)/100);
Final amount = Discounted amount + ((Discounted amount * y)/100);
Input variables Processing Output variables Necessary
variables/calculations header
files/functions
etc.
(float)discounted_amt, discounted_amt=printed_price- (float)discounted_amt stdio.h
(float)discount, ((printed_price*discount)/100); (float)final_amt
(float)printed_price, final_amt = discounted_amt +
(float)tax, ((discounted_amt * tax)/100);
(float)final_amt;

Pseudocode:

1. Start
2. Input printedPrice
3. Input discountPercent
4. Input salesTaxPercent
5. Calculate discountAmount = (discountPercent / 100) * printedPrice
6. Calculate discountedPrice = printedPrice - discountAmount
7. Calculate salesTaxAmount = (salesTaxPercent / 100) * discountedPrice
8. Calculate amountToBePaid = discountedPrice + salesTaxAmount
9. Print "Discounted Price: Rs." + discountedPrice
10. Print "Sales Tax Amount: Rs." + salesTaxAmount
11. Print "Amount to be Paid: Rs." + amountToBePaid
12. End
Flowchart:
Start

Print “Welcome”

Input
PrintedPrice,
DiscountPercent,

Calculate 'discountAmount' =
(discountPercent/100) *
printedPrice

Calculate 'discountedPrice' =
printedPrice - discountAmount

Calculate 'salesTaxAmount' =
(salesTaxPercent/100) *
discountedPrice

Calculate 'amountToBePaid' =
discountedPrice +
salesTaxAmount

Print
'amountToBePaid'

Stop
Specify:
Machine configuration:
Processor = 12th Gen Intel® Core™ i7-12700 × 20
Memory = 8GB
Name and version of operating System: Ubuntu 22.04.3 LTS
Compiler used to compile and execute the program: gcc version 11.4.0
List v arious steps and operating system commands that were used to develop, compile and
execute the program:
To compile the code => gcc filename.c
To execute the code => ./a.out

Conclusion:
This is the first code written in a C program. The program is focused on the calculation of discounted
amount and final amount to be paid by customer for the given discount, printed price, tax. From this
lab, I understood the basic structure of C programming including the meaning of header files & steps
of problem solving. Hence, the final amount to be paid by the customer is calculated and displayed.

You might also like