This document appears to be a laboratory manual for a C programming course. It includes 15 experiments covering topics like arithmetic expressions, quadratic equations, strings, arrays, structures, pointers, and recursion. For each experiment, students are instructed to write algorithms, flowcharts, and C code to solve programming problems. They then test and debug their code. Marks are awarded for the procedure, execution, and viva voce of each experiment.
Describes ARM7-TDMI Processor Instruction Set. Explains classes of ARM7 instructions, syntax of data processing instructions, branch instructions, load-store instructions, coprocessor instructions, thumb state instructions.
Describes ARM7-TDMI Processor Instruction Set. Explains classes of ARM7 instructions, syntax of data processing instructions, branch instructions, load-store instructions, coprocessor instructions, thumb state instructions.
Introduction, Macro Definition and Call, Macro Expansion, Nested Macro Calls, Advanced Macro Facilities, Design Of a Macro Preprocessor, Design of a Macro Assembler, Functions of a Macro Processor, Basic Tasks of a Macro Processor, Design Issues of Macro Processors, Features, Macro Processor Design Options, Two-Pass Macro Processors, One-Pass Macro Processors
The purpose of types:
To define what the program should do.
e.g. read an array of integers and return a double
To guarantee that the program is meaningful.
that it does not add a string to an integer
that variables are declared before they are used
To document the programmer's intentions.
better than comments, which are not checked by the compiler
To optimize the use of hardware.
reserve the minimal amount of memory, but not more
use the most appropriate machine instructions.
Introduction, Macro Definition and Call, Macro Expansion, Nested Macro Calls, Advanced Macro Facilities, Design Of a Macro Preprocessor, Design of a Macro Assembler, Functions of a Macro Processor, Basic Tasks of a Macro Processor, Design Issues of Macro Processors, Features, Macro Processor Design Options, Two-Pass Macro Processors, One-Pass Macro Processors
The purpose of types:
To define what the program should do.
e.g. read an array of integers and return a double
To guarantee that the program is meaningful.
that it does not add a string to an integer
that variables are declared before they are used
To document the programmer's intentions.
better than comments, which are not checked by the compiler
To optimize the use of hardware.
reserve the minimal amount of memory, but not more
use the most appropriate machine instructions.
Bottom of FormCreate your own FunctionFunctionsFor eac.docxAASTHA76
Bottom of Form
Create your own Function
Functions
For each discussion, provide a snipplet of pseudo-code for the Main using an example call to the Function as well as the pseudo-code for the Function.
For each discussion, do the problem you are assigned to as described by the letters below.
Discussion 1 - Using Pseudocode, create a Function that accepts one or more input Integer numbers and returns a float number. You should name your function appropriately as to what it does. Be sure to document your Function with header and in-line comments.
Provide a snipplet of psuedo-code for the Main using an example call to the Function.
Make sure the variable names in the Main are different that in the Function. In the Main, provide the prompts and get the user responses. Then pass the data into the Function. After the call to the Function include a print statements that indicates the returning value from the call to the Function.
Put Discussion 1 - problem no.X in the Subject area.
You are assigned the problem no. below as follows: If your Last Name begins with:
A-B - do no. 1
C-F - do no. 2
G-H - do no. 3
I-K - do no. 4
L - do no. 5
M-P - do no. 6
Q-T - do no. 7
U-Z - do no. 8
1)Calculate the Area of a circle. Input: one number
2)Calculate the Circumference a circle. Input: one number
3)Convert the temperature from Celcius to Farenheit Input: one number
4)Convert the temperature from Farenheit to Celcius. Input: one number
5)Calculate 6 times a number squared. Input: one number
6)Calculate 3 times the (sum of three numbers). Input: three numbers
7)Calculate the average of four numbers. Input: four numbers
8)Calculate 5 times the (difference of two numbers). Input two numbers
You may do additional problems, if you want.
Discussion 2:
Convert Discussion 1 to C-code. Don't for get to prototype your function before the main and to define your function after the main. Put Discussion 2 - problem no.X in the Subject area and submit a .txt (or .c) file for your code.
CMIS 102 Hands-On Lab
Week 6
Overview:
This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, Analysis, Design(program design, pseudocode), Test Plan, and implementation with C code. The example provided uses sequential, repetition, selection statements and two user-defined function.
Program Description:
This program will provide options for a user to calculate the square or cube of a positive Integer input by a user. The program will prompt the user to enter an Integer and then prompt the user if they want to calculate the square of the cube of the number. Based on the inputs of the user, the program will output the square of the cube of the positive integer. The program will then print the Integer and square or cube of the integer based on the user’s original choice. The program will continue to prompt the user for
Integers and their calculation choice until the user enters a negative int ...
This slide notes are more than 10 years old of my teacher Mr Karim Zebari. He uses a brilliant simple language to explain programming principles step by step.
Project 2 the second project involves/tutorialoutletMessanz
FOR MORE CLASSES VISIT
tutorialoutletdotcom
Project 2
The second project involves completing and extending the C++ program that evaluates statements of an
expression language contained in the module 3 case study.
The statements of that expression language consist of an arithmetic expression followed by a list of
assignments. Assignments are separated from the expression and each other by commas. A semicolon
terminates the expression. The arithmetic expressions are fully parenthesized infix expressions
ELE2303 Assign 1 Page 1 ELE2303 Embedded Systems Design.docxjack60216
ELE2303 Assign 1 Page | 1
ELE2303 Embedded Systems Design
Assignment 1 – Gas Monitor Unit Stage 1
Description Marks out of Wtg (%) Due date
Gas Monitor Unit – Stage 1 200 20 28/04/14
Purpose
This assessment is intended to evaluate the student’s capability in selecting and configuring a
microcontroller unit (MCU), designing simple interface hardware and writing subroutines to
operate those interfaces.
Please note – the purpose of studying a ‘design’ course like this, is that you learn how to design
hardware and write programs to solve new problems. This requires you to understand the how
individual parts of the microcontroller function and how to control them with a program. You are
expected to link together pieces of interface circuitry and combine segments of program you
learn about in the course materials, into a structured solution. Do not expect to find a ‘solution’
to this problem on the internet. Expect that you have to create it!
Grading of this assessment
This task will be assessed against the course objectives 1, 2, 3, 4, 6 and 7. This assessment will
be graded (F, C, B, A, HD) using a rubric marking scheme against criteria such as: the
appropriate selection and use of microcomputer hardware; the design of I/O hardware to meet a
specification; implementation of software to meet a specification; quality of documentation
including organisation of ideas and format; spelling, grammar and punctuation. Note - this
course is a communications benchmark course, hence marks will be awarded for the quality of
documentation.
Assignment Requirements
This assessment requires students to meet the requirements the specification below. Select a
suitable microcontroller from the PIC18 family, design simple interface hardware, write
and test some C programs (subroutines) to operate the hardware interface and then document
the hardware and software as a proposed design. Software is to be written in C using the
MPLAB X IDE. You must create an MPLAB X project which may include one or more C
source files. The testing is to be completed using either: the Oshonsoft PIC18 simulator or the
MPLAB X simulator.
There is NO requirement to assemble any hardware, or layout a PCB for this assignment.
The circuit design for the hardware may be drawn using electronics CAD software, OR hand-
drawn and scanned, for inclusion in the documentation. The ‘hardware’ can be successfully
configured and simulated on the Oshonsoft PIC18 simulator or the MPLAB simulator. A few
screen captures of the software under-going testing are to be included in the documentation.
ELE2303 Assign 1 Page | 2
Each student is required to submit:
1. A report in PDF format which includes:
a brief introduction (100 – 150 words) outlining the design requirements based on the
specification.
the hardware design (250 – 300 words) explaining the key elements of the design and
how they meet the specification, plus ...
Jeremiah Yancy - Objectives for Software design and testingJeremiah Yancy
Mr. Jeremiah Yancy possesses extensive experience and industry knowledge in his field and has managed multiple startups from inception to Initial Public Offering.
Explaining on what is a program ,how a program development is done with a study on program development life cycle,Algorithm ,characteristics of an algorithm,few examples
Quality defects in TMT Bars, Possible causes and Potential Solutions.PrashantGoswami42
Maintaining high-quality standards in the production of TMT bars is crucial for ensuring structural integrity in construction. Addressing common defects through careful monitoring, standardized processes, and advanced technology can significantly improve the quality of TMT bars. Continuous training and adherence to quality control measures will also play a pivotal role in minimizing these defects.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSEDuvanRamosGarzon1
AIRCRAFT GENERAL
The Single Aisle is the most advanced family aircraft in service today, with fly-by-wire flight controls.
The A318, A319, A320 and A321 are twin-engine subsonic medium range aircraft.
The family offers a choice of engines
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
Vaccine management system project report documentation..pdfKamal Acharya
The Division of Vaccine and Immunization is facing increasing difficulty monitoring vaccines and other commodities distribution once they have been distributed from the national stores. With the introduction of new vaccines, more challenges have been anticipated with this additions posing serious threat to the already over strained vaccine supply chain system in Kenya.
Democratizing Fuzzing at Scale by Abhishek Aryaabh.arya
Presented at NUS: Fuzzing and Software Security Summer School 2024
This keynote talks about the democratization of fuzzing at scale, highlighting the collaboration between open source communities, academia, and industry to advance the field of fuzzing. It delves into the history of fuzzing, the development of scalable fuzzing platforms, and the empowerment of community-driven research. The talk will further discuss recent advancements leveraging AI/ML and offer insights into the future evolution of the fuzzing landscape.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
C Programming Lab manual 18CPL17
1. Visvesvaraya Technological University
(Jnana Sangama, Machhe, Visvesvaraya Technological University, Belagavi, Karnataka 590018)
BTL INSTITUTE OF TECHNOLOGY & MANAGEMENT
(259/B, Hosur Rd, Bommasandra Industrial Area, Bengaluru, Karnataka 560099)
YEAR: FIRST PROGRAMME: UG COURSE: BE
LABORATORY MANUAL
for
C PROGRAMMING LAB
( 18CPL17/27)
Prepared by :
Mr. Manjunatha Reddy G
Asst. Professor,
Department of CSE.
Department of Computer Science/Mechanical/Electronics & Communication and Civil Engineering
Supplied by: B.T.L.I.T Co-operative Society, Bangalore – 560 099
Phone: 78-33055, 35250, 35251 Telefax: 080-7833831
Student Name : _________________________________________________
USN : 1BT18_____________ Section : __________ Batch No : _______
Department: ________________________________________________
Semester : First / Second Academic Year : 2018-19
2. C PROGRAMMING LABORATORY SYLLABUS
Semester : I/II CIE Marks : 40 SEE Marks : 60 Exam Hours: 03
Course Code : 18CPL17 Credits : 01 Teaching Hours/week (L:T:P): 0:0:2
Course Learning Objectives:
This course (18CPL17/27) will enable students to:
Write flowcharts, algorithms and programs.
Familiarize the processes of debugging and execution.
Implement basics of C programming language.
Illustrate solutions to the laboratory programs.
Descriptions (if any):
The laboratoryshouldbe precededorfollowedbyatutorialtoexplaintheapproach or algorithm being implemented or implemented for the problems given.
Note that experiment 1 is mandatory and written in the joumal.
Questions related withexperiment 1, needto be askedduring viva-voce for all experiments.
Everyexperiment shouldhave algorithmandflowchart be writtenbeforewriting the program.
Code should be traced using minimum two test cases which should berecorded.
It is preferred to implement using Linux and GCC.
Laboratory Programs:
1. Familiarization with computer hardware and programming environment, concept of naming the program files, storing, compilation,
execution and debugging, taking any simple C- code. [Not included in the Lab Exam ]
PART A
2. Develop a program to solve simple computational problems using arithmetic expressions and use of each operator leading to simulation of
a commercial calculator. (No built-in math function)
3. Develop a program to compute the roots of a quadratic equation by accepting the coefficients. Print appropriate messages.
4. Develop a program to find the reverse of a positive integer and check for palindrome or not. Display appropriate messages.
5. An electricity board charges the following rates for the use of electricity: for the first 200 units 80 paisa per unit: for the next 100 units 90
paisa per unit: beyond 300 units Rs 1 per unit. All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more
than Rs 400, then an additional surcharge of 15% of total amount is charged. Write a program to read the name of the user, number of
units consumed and print out the charges.
6. Introduce 1D An-
ay manipulation and implement Binary search.
7. Implement using functions to check whether the given number is prime and display appropriate messages. (No built-in math function)
PART B
8. Develop a program to introduce 2D Array manipulation and implement Matrix multiplication and ensure the rules of multiplication are
checked.
9. Develop a Program to compute Sin(x) using Taylor series approximation. Compare your result with the built- in Library function. Print
both the results with appropriate messages.
10. Write functions to implement string operations such as compare, concatenate, string length. Convince the parameter passing techniques.
11. Develop a program to sort the given set of N numbers using Bubble sort.
12. Develop a program to find the square root of a given number N and execute for all possible inputs with appropriate messages.
Note: Don't use library function sqrt(n).
13. Implement structures to read, write and compute average- marks and the students scoring above and below the average marks for a class
of N students.
14. Develop a program using pointers to compute the sum, mean and standard deviation of all elements stored in an array of n real numbers.
15. Implement Recursive functions for Binary to Decimal Conversion.
Laboratory Outcomes:
The student should be able to:
Write algorithms, flowcharts and program for simple problems.
Correct syntax and logical errors to execute a program.
Write iterative and wherever possible recursive programs.
Demonstrate use of functions, arrays, strings, structures and pointers in problem solving.
Conduct of Practical Examination:
All laboratory experiments, excluding the first, are to be included for practical examination.
Experiment distribution
o For questions having only one part: Students are allowed to pick one experiment from the lot and are given equal opportunity.
o For questions having part A and B: Students are allowed to pick one experiment from part A and one experiment from part B and are given equal
opportunity.
Strictly follow the instructions as printed on the cover page of answer script for breakup of marks
Change of experiment is allowed only once and marks allotted for procedure part to be made zero.
Marks Distribution (Subjected to change in accordance with university regulations)
a) For questions having only one part — Procedure + Execution + Viva-Voce: 15+70+15 =100 Marks
b) For questions having part A and B
i. Part A— Procedure + Execution + Viva = 4 + 21 + 5 = 30 Marks
ii. Part B — Procedure + Execution + Viva = 10 + 49 + 11 = 70 Marks
3. INDEX
Exp
No
Date LaboratoryProgramsinShort
ObtainedMarks
A
/F
P E V Signature
1
PART–A 2 2 21 5
2
3
4
5
6
7
PART–B 4 6 49 11
8
9
10
11
12
13
14
15
A–Algorithms F–Flowchart P–Procedure E–Execution V–Viva
AftertheeachexperimentexecutionstudentmustgetsignaturebytheInchargefacultywithdate.
Thefacultyastoentertheobtainmarksfortheeachexperiment. MaximummarksgivenforPart-A&Part-B
Note:
1. Everyexperiment shouldhave algorithmandflowchart be writtenbeforewriting the program.
2. Code should be traced using minimum two test cases which should berecorded.
ClassInternalEvaluationMarks (FilledbyInchargeFaculty)
Part-A
Exp.No. 2 3 4 5 6 7 Total Average
(Total/6)
Signature
MaxMarks 30 30 30 30 30 30 180
MarksObtain
Part-B
Exp.No. 8 9 10 11 12 13 14 15 Total Average
(Total/8)
Signature
MaxMarks 70 70 70 70 70 70 70 70 560
MarksObtain
CIEMarksObtained [ (Part-A+Part-B)x0.40]
4. 18CPL17/27 C Programming Lab
Program – 1 : Familiarization with computer hardware and programming environment, concept of naming the program files, storing,
compilation, execution and debugging, taking any simple C- code. [Not included in the Lab Exam ]
Generally, the programs created using programming languages like C, C++, Java etc., are written
using high level language like English. But, computer cannot understand the high level language. It
can understand only low level language. So, the program written in high level language needs to be
converted into low level language to make it understandable for the computer. This conversion is
performed using either Interpreter or Compiler.
Popular programming languages like C, C++, Java etc., use compiler to convert high level language
instructions into low level language instructions. Compiler is a program that converts high level
language instructions into low level language instructions. Generally, compiler performs two
things, first it verifies the program errors, if errors are found, it returns list of errors otherwise it
converts the complete code into low level language.
To create and execute C programs in Windows Operating System, we need to install Turbo C
software. We use the following steps to create and execute C programs in Windows OS…
Step 1: Creating Source Code
Source code is a file with C programming instructions in high level language. To create source
code, we use any text editor to write the program instructions. The instructions written in the
source code must follow the C programming language rules. The following steps are used to create
source code file in Windows OS…
Click on Start button
Select Run
Type cmd and press Enter
Type cd c:TCbin in the command prompt and press Enter
Type TC press Enter
Click on File -> New in C Editor window
Type the program
Save it as FileName.c (Use shortcut key F2 to save)
5. 18CPL17/27 C Programming Lab
Step 2: Compile Source Code (Alt + F9)
Compilation is the process of converting high level language instructions into low level language
instructions. We use the shortcut key Alt + F9 to compile a C program in Turbo C.
Compilation is the process of converting high level language instructions into low level language
instructions.
Whenever we press Alt + F9, the source file is going to be submitted to the Compiler. On receiving
a source file, the compiler first checks for the Errors. If there are any Errors then compiler returns
List of Errors, if there are no errors then the source code is converted into object code and stores it
as file with .obj extension. Then the object code is given to the Linker. The Linker combines both
the object code and specified header file code and generates an Executable file with .exe extension.
Step 3: Executing / Running Executable File (Ctrl + F9)
After completing compilation successfully, an executable file is created with .exe extension. The
processor can understand this .exe file content so that it can perform the task specified in the
source file.
We use a shortcut key Ctrl + F9 to run a C program. Whenever we press Ctrl + F9, the .exe file is
submitted to the CPU. On receiving .exe file, CPU performs the task according to the instruction
written in the file. The result generated from the execution is placed in a window called User
Screen.
Step 4: Check Result (Alt + F5)
After running the program, the result is placed into User Screen. Just we need to open the User
Screen to check the result of the program execution. We use the shortcut key Alt + F5 to open the
User Screen and check the result.
Execution Process of a C Program
When we execute a C program it undergoes with following process…
The file which contains c program instructions in high level language is said to be source code.
Every c program source file is saved with .c extension, for example Sample.c.
Whenever we press Alt + F9 the source file is submitted to the compiler. Compiler checks for the
errors, if there are any errors, it returns list of errors, otherwise generates object code in a file
6. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 3
file into object file and generates executable file as Sample.exe. With this compilation process
completes.
Now, we need to Run the executable file (Sample.exe). To run a program we press Ctrl + F9. When
we press Ctrl + F9 the executable file is submitted to the CPU. Then CPU performs the task
according to the instructions written in that program and place the result into UserScreen.
Then we press Alt + F5 to open UserScreen and check the result of the program.
Important Points
C program file (Source file) must save with .c extension.
Compiler converts complete program at a time from high level language to low level
language.
Input to the compiler is .c file and output from the compiler is .exe file, but it also
generates .obj file in this process.
Compiler converts the file only if there are no errors in the source code.
CPU places the result in User Screen window.
Overall Process
Type the program in C editor and save with .c extension (Press F2 to save).
Press Alt + F9 to compile the program.
If there are errors, correct the errors and recompile the program.
If there are no errors, then press Ctrl + F9 to execute / run the program.
Press Alt + F5 to open User Screen and check the result.
Program Development Life Cycle
When we want to develop a program using any programming language, we follow a sequence of steps.
These steps are called phases in program development. The program development life cycle is a set of steps
or phases that are used to develop a program in any programming language.
Generally, program development life cycle contains 6 phases, they are as follows….
Problem Definition
Problem Analysis
Algorithm Development
Coding & Documentation
Testing & Debugging
Maintenance
7. 18CPL17/27 C Programming Lab
1. Problem Definition
In this phase, we define the problem statement and we decide the boundaries of the problem. In this phase
we need to understand the problem statement, what is our requirement, what should be the output of the
problem solution. These are defined in this first phase of the program development life cycle.
2. Problem Analysis
In phase 2, we determine the requirements like variables, functions, etc. to solve the problem. That means
we gather the required resources to solve the problem defined in the problem definition phase. We also
determine the bounds of the solution.
3. Algorithm Development
During this phase, we develop a step by step procedure to solve the problem using the specification given in
the previous phase. This phase is very important for program development. That means we write the
solution in step by step statements.
4. Coding & Documentation
This phase uses a programming language to write or implement actual programming instructions for the
steps defined in the previous phase. In this phase, we construct actual program. That means we write the
program to solve the given problem using programming languages like C, C++, Java etc.,
5. Testing & Debugging
During this phase, we check whether the code written in previous step is solving the specified problem or
not. That means we test the program whether it is solving the problem for various input data values or not.
We also test that whether it is providing the desired output or not.
6. Maintenance
During this phase, the program is actively used by the users. If any enhancements found in this phase, all
the phases are to be repeated again to make the enhancements. That means in this phase, the solution
(program) is used by the end user. If the user encounters any problem or wants any enhancement, then we
need to repeat all the phases from the starting, so that the encountered problem is solved or enhancement
is added.
8. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 5
Program 2 : PART A
Develop a program to solve simple computational problems using arithmetic expressions and use of each operator leading to
simulation of a commercial calculator. (No built-in math function)
Source Code
#include <stdio.h>
#include<strings.h>
#include<ctype.h>
int main()
{
int res,opr,opd, i;
char exp[20] = "5/2+7";
res = exp[0] - '0' ;
for ( i = 1; i < strlen(exp)-1; i += 2)
{
opr = exp[i];
opd = exp[i+1]-'0';
if ( !( isdigit( exp[ i+1 ] ) ) )
opr = -1;
if (opr == '+')
res += opd;
else if (opr == '-')
res -= opd;
else if (opr == '*')
res *= opd;
else if (opr == '/')
res /= opd;
else
{
printf("Invalid Expression");
return 0;
}
}
printf("Result of %s = %d ",exp, res);
return 0;
}
Output :
9. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 6
Program 3 : PART A
Develop a program to compute the roots of a quadratic equation by accepting the coefficients. Print appropriate messages.
Source Code
#include<stdio.h>
#include<math.h>
int main ()
{
float a, b, c, d, r1, r2;
printf ("Enter any three Numbers : ");
scanf ("%f %f %f", &a, &b, &c);
d = b * b - 4 * a * c;
if (d < 0)
{
printf ("n Roots are complex number.n");
printf ("The Roots of quadratic equation are imaginaryn ");
r1 = -b / (2 * a);
r2 = sqrt (abs ((int) d)) / (2 * a);
printf ("n Root1 = %.3f+i%.3f", r1, r2);
printf ("n Root2 = %.3f-i%.3f", r1, r2);
}
else if (d == 0)
{
printf ("n Roots of quadratic equation is equal.n");
r1 = -b / (2 * a);
printf ("n Root of quadratic equation is : %.3f ", r1);
}
else
{
printf ("n Roots of quadratic equation are real numbers.n");
r1 = (-b + sqrt ((int) d)) / (2 * a);
r2 = (-b - sqrt ((int) d)) / (2 * a);
printf ("n Roots of quadratic equation are : %.3f and %.3f", r1,
r2);
}
return 0;
}
Output :
10. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 7
Program 4 : PART A
Develop a program to find the reverse of a positive integer and check for palindrome or not. Display appropriate messages.
Source Code
#include <stdio.h>
int main ()
{
int n, rev = 0, num;
do
{
printf ("nEnter an Positive Integer Number( > 2 digits): ");
scanf ("%d", &n);
}
while (n < 10);
num = n;
while (n != 0)
{
rev = rev * 10 + n % 10;
n /= 10;
}
if (num == rev)
printf ("%d is a palindrome.", num);
else
printf ("%d is not a palindrome.", num);
return 0;
}
Output :
11. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 8
Program 5 : PART A
An electricity board charges the following rates for the use of electricity: for the first 200 units 80 paisa per unit: for the next 100
units 90 paisa per unit: beyond 300 units Rs 1 per unit. All users are charged a minimum of Rs. 100 as meter charge. If the total
amount is more than Rs 400, then an additional surcharge of 15% of total amount is charged. Write a program to read the name
of the user, number of units consumed and print out the charges.
Source Code
#include <stdio.h>
int main ()
{
char name[20];
float unit, amount, scharge = 0.0;
printf ("Enter your name & unit Consumed(>0):");
scanf ("%s %f", name, &unit);
if (unit <= 200)
amount = unit * .80;
else if (unit <= 300)
amount = (unit - 200) * 0.90 + 160;
else if (unit > 300)
amount = (unit - 300) * 1 + 250;
if (amount > 400)
scharge = amount * 0.15;
printf ("n__________________");
printf("nName : %s",name);
printf("nUnit Consumed: %.0f",unit);
printf ("n____________nAmount : %5.2f nSurcharge : %5.2f", amount,
scharge);
printf ("n__________________");
printf ("nAmount Due : %.2f ", amount + scharge);
return 0;
}
Output :
12. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 9
Program 6 : PART A
Introduce 1D An-ay manipulation and implement Binary search.
Source Code
#include <stdio.h>
int main ()
{
int c, first, last, middle, n, search, A[100];
printf ("Enter number of elementsn");
scanf ("%d", &n);
printf ("Enter %d integersn", n);
for (c = 0; c < n; c++)
scanf ("%d", &A[c]);
printf ("Enter value to findn");
scanf ("%d", &search);
first = 0;
last = n - 1;
while (first <= last)
{
middle = (first + last) / 2;
if (A[middle] == search)
{
printf ("%d found at location %d.n", search, middle + 1);
return 0;
}
else if (A[middle] < search)
first = middle + 1; //search in right most part
else
last = middle - 1; //search in left most part
}
if (first > last)
printf ("Not found! %d isn't present in the list.n", search);
return 0;
}
Output :
13. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 10
Program 7 : PART A
Implement using functions to check whether the given number is prime and display appropriate messages. (No built-in math
function).
Source Code
#include <stdio.h>
int isPrime(int n)
{
int i;
for(i=2; i<=n/2; ++i)
{
if(n%i == 0) // condition for non-prime number
{
return 0;
}
}
return 1;
}
int main() // Driver Function
{
int n;
printf("Enter a positive integer: ");
scanf("%d", &n);
// Check prime number
if ( isPrime( n) )
printf("%d is a prime number.n", n);
else
printf("%d is not a prime number.n", n);
return 0;
}
Output :
14. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 11
Program 8 : PART- B
Develop a program to introduce 2D Array manipulation and implement Matrix multiplication and ensure the rules of
multiplication are checked.
Source Code
#include <stdio.h>
int main()
{
printf("Enter number of rows and columns of first matrixn");
scanf("%d%d", &m, &n);
printf("Enter number of rows and columns of second matrixn");
scanf("%d%d", &p, &q);
if (n != p)
{
printf("The matrices can't be multiplied with each other.n");
printf("Error! column of first matrix not equal to row of second.nn");
return 0;
}
printf("Enter elements of first matrixn");
for (c = 0; c < m; c++)
for (d = 0; d < n; d++)
scanf("%d", &first[c][d]);
printf("Enter elements of second matrixn");
for (c = 0; c < p; c++)
for (d = 0; d < q; d++)
scanf("%d", &second[c][d]);
for (c = 0; c < m; c++)
{
for (d = 0; d < q; d++)
{
sum = 0;
for (k = 0; k < p; k++)
{
sum = sum + first[c][k]*second[k][d];
}
multiply[c][d] = sum;
}
}
printf("Product of the matrices:n");
for (c = 0; c < m; c++) {
for (d = 0; d < q; d++)
printf("%dt", multiply[c][d]);
printf("n");
}
return 0;
}
Output :
15. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 12
Program 9 : PART - B
Develop a Program to compute Sin(x) using Taylor series approximation. Compare your result with the built- in Library function.
Print both the results with appropriate messages.
Source Code
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main ()
{
int n, x1;
float accuracy, term, denominator, x, sinx, sinval;
printf ("Enter the value of x (in degrees) n");
scanf ("%f", &x);
x1 = x;
/* Converting degrees to radians */
x = x * (3.142 / 180.0);
sinval = sin (x);
printf ("Enter the accuracy for the result n");
scanf ("%f", &accuracy);
term = x;
sinx = term;
n = 1;
do
{
denominator = 2 * n * (2 * n + 1);
term = -term * x * x / denominator;
sinx = sinx + term;
n = n + 1;
}
while (accuracy <= fabs (sinval - sinx));
printf ("Sum of the sine series = %f n", sinx);
printf ("Using Library function sin(%d) = %fn", x1, sin (x));
return 0;
}
Output :
16. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 13
Program 10 : PART-B
Write functions to implement string operations such as compare, concatenate, string length. Convince the parameter passing
techniques.
Source Code
#include<stdio.h>
int string_length (char *pointer)
{
int c = 0;
while (*(pointer + c) != '0')
c++;
return c;
}
int match_strings (char *Str1, char *Str2)
{
int i = 0;
while (Str1[i] == Str2[i])
{
if (Str1[i] == '0' && Str2[i] == '0')
break;
i++;
}
return Str1[i] - Str2[i];
}
void join_strings (char s1[], char s2[])
{
int i, j;
for (i = 0; s1[i] != '0'; i++);
for (j = 0; s2[j] != '0'; i++, j++)
{
s1[i] = s2[j];
}
s1[i] = '0';
}
int main ()
{
char string1[20], string2[20];
int choice;
printf ("n1. Find Length n2. Concatenate n3. Compare n4.Exitn");
printf ("Enter your choice: ");
scanf ("%d", &choice);
switch (choice)
{
case 1:
printf ("Enter the string: ");
scanf ("%s", string1);
printf ("The length of string is %d", string_length (string1));
break;
case 2:
printf ("Enter two strings: ");
scanf ("%s%s", string1, string2);
join_strings (string1, string2);
printf ("The concatenated string is %s", string1);
break;
17. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 14
case 3:
printf ("Enter two strings: ");
scanf ("%s%s", string1, string2);
if (match_strings (string1, string2) == 0)
{
printf ("They are equal");
}
else
{
printf ("They are not equal");
}
break;
case 4:
return 0;
}
return 0;
}
Output :
18. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 15
Program 11: PART-B
Develop a program to sort the given set of N numbers using Bubble sort.
Source Code
#include <stdio.h>
#define MAXSIZE 10
void main()
{
int array[MAXSIZE];
int i, j, num, temp;
printf("Enter the value of num n");
scanf("%d", &num);
printf("Enter the elements one by one n");
for (i = 0; i < num; i++)
{
scanf("%d", &array[i]);
}
printf("Input array is n");
for (i = 0; i < num; i++)
{
printf("%dn", array[i]);
}
/* Bubble sorting begins */
for (i = 0; i < num; i++)
{
for (j = 0; j < (num - i - 1); j++)
{
if (array[j] > array[j + 1])
{
temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
}
}
}
printf("Sorted array is...n");
for (i = 0; i < num; i++)
{
printf("%dn", array[i]);
}
}
Output :
19. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 16
Program 12 : PART-B
Develop a program to find the square root of a given number N and execute for all possible inputs with appropriate messages.
Note: Don't use library function sqrt(n).
Source Code
#include<stdio.h>
float squareRoot(float n)
{
/*We are using n itself as first estimate This can surely be better */
float x , y = 1, e = 0.000001; /* e decides the accuracy level*/
x = n ;
while(x - y > e)
{
x = (x + y)/2;
y = n/x;
}
return x;
}
/* Driver program to test above function*/
void main()
{
int n = 50;
printf ("Square root of %d is %f", n, squareRoot(n));
getch();
}
Output :
20. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 17
Program 13 : PART-B
Implement structures to read, write and compute average- marks and the students scoring above and below the average marks for
a class of N students..
Source Code
#include<stdio.h>
struct stud
{
int rollno, s1, s2, tot ;
char name[10] ;
float avg ;
} s[10] ;
float compute( struct stud S[], int n )
{
int i;
float sum=0 ;
for ( i = 0 ; i < n ; i++ )
{
sum = sum + S[i].avg ;
}
return (sum/n);
}
void display( struct stud s )
{
printf("%d t %s tt %d t %d t %d t %.2f n", s.rollno,s.name,s.s1,s.s2,s.tot,s.avg);
}
int main()
{
int i, n ;
float mean;
printf("Enter the number of students : ") ;
scanf("%d", &n) ;
for(i = 0 ; i < n ; i++)
{
printf("nEnter the roll number : ") ;
scanf("%d", &s[i].rollno) ;
printf("nEnter the name : ") ;
scanf("%s", s[i].name) ;
printf("nEnter the marks in 2 subjects : ") ;
scanf("%d %d", &s[i].s1, &s[i].s2) ;
s[i].tot = s[i].s1 + s[i].s2 ;
s[i].avg = s[i].tot / 2.0 ;
}
mean = compute( s,n);
printf("nBelow Average Studentsn");
printf("nRoll No. Name ttSub1t Sub2t Totalt Averagenn") ;
for(i = 0 ; i < n ; i++)
{
if( s[i].avg < mean )
display(s[i]);
}
printf("nAbove Average Studentsn");
printf("nRoll No. Name ttSub1t Sub2t Totalt Averagenn") ;
for(i = 0 ; i < n ; i++)
{
if( s[i].avg >= mean )
display(s[i]);
}
return(0) ;
}
Output :
21. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 18
Program 14 : PART-B
Develop a program using pointers to compute the sum, mean and standard deviation of all elements stored in an array of n real
numbers.
Source Code
#include<stdio.h>
#include<math.h>
int main ()
{
float a[20], sum1 = 0, sum2 = 0, mean, var, dev;
int i, n;
printf ("enter no of elen");
scanf ("%d", &n);
printf ("enter array elen");
for (i = 0; i < n; i++)
{
scanf ("%f", a + i);
sum1 = sum1 + *(a + i);
}
mean = sum1 / n;
for (i = 0; i < n; i++)
{
sum2 = sum2 + pow ((*(a + i) - mean), 2);
}
var = sum2 / n;
dev = sqrt (var);
printf ("sum is%fn", sum1);
printf ("mean is%fn", mean);
printf ("variance is%fn", var);
printf ("devn is%fn", dev);
return 0;
}
Output :
22. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 19
Program 15 : PART-B
Implement Recursive functions for Binary to Decimal Conversion..
Source Code
#include <stdio.h>
#include <math.h>
int bin_to_dec(long long int num)
{
if (!(num / 10))
return (num);
return (num % 10 + bin_to_dec (num / 10) * 2);
}
int main()
{
long long n;
printf("Enter a Valid binary number < (10 Digits): ");
scanf("%lld", &n);
printf("%lld in binary = %d in decimal", n, bin_to_dec (n));
return 0;
}
Output :
Algorithms and proper flowcharts will be update soon.
23. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 20
Program 2 : PART A
Develop a program to solve simple computational problems using arithmetic expressions and use of each operator leading to
simulation of a commercial calculator. (No built-in math function)
Logic Flow
24. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 21
Program 3 : PART A
Develop a program to compute the roots of a quadratic equation by accepting the coefficients. Print appropriate messages.
Logic Flow
25. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 22
Program 4 : PART A
Develop a program to find the reverse of a positive integer and check for palindrome or not. Display appropriate messages.
Logic Flow
26. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 23
Program 5 : PART A
An electricity board charges the following rates for the use of electricity: for the first 200 units 80 paisa per unit: for the next 100
units 90 paisa per unit: beyond 300 units Rs 1 per unit. All users are charged a minimum of Rs. 100 as meter charge. If the total
amount is more than Rs 400, then an additional surcharge of 15% of total amount is charged. Write a program to read the name
of the user, number of units consumed and print out the charges.
Logic Flow
27. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 24
Program 6 : PART A
Introduce 1D An-ay manipulation and implement Binary search.
Logic Flow
28. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 25
Program 7 : PART A
Implement using functions to check whether the given number is prime and display appropriate messages. (No built-in math
function).
Logic Flow
29. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 26
Program 8 : PART- B
Develop a program to introduce 2D Array manipulation and implement Matrix multiplication and ensure the rules of
multiplication are checked.
Logic Flow
30. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 27
Program 9 : PART - B
Develop a Program to compute Sin(x) using Taylor series approximation. Compare your result with the built- in Library function.
Print both the results with appropriate messages.
Logic Flow
31. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 28
Program 10 : PART-B
Write functions to implement string operations such as compare, concatenate, string length. Convince the parameter passing
techniques.
Logic Flow
32. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 29
Program 11: PART-B
Develop a program to sort the given set of N numbers using Bubble sort.
Logic Flow
33. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 30
Program 12 : PART-B
Develop a program to find the square root of a given number N and execute for all possible inputs with appropriate messages.
Note: Don't use library function sqrt(n).
Logic Flow
34. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 31
Program 13 : PART-B
Implement structures to read, write and compute average- marks and the students scoring above and below the average marks for
a class of N students..
Logic Flow
35. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 32
Program 14 : PART-B
Develop a program using pointers to compute the sum, mean and standard deviation of all elements stored in an array of n real
numbers.
Logic Flow
36. 18CPL17/27 C Programming Lab
BTLIT CSE P a g e | 33
Program 15 : PART-B
Implement Recursive functions for Binary to Decimal Conversion..
Logic Flow