1. A REVIEW ON
COMPUTER PROGRAMMING LAB
NAME :- PEESA JASWANTH
ROLL NO :- 24NU1A0241
BRANCH :- EEE
CODE :- 23ESX05
2. KEY FEATURES OF C SIMPLE AND EFFICIENT:-
C IS A STRAIGHT FORWARD LANGUAGE WITH A CLEAN SYNTAX .LOW
LEVEL ACCESS :
IT ALLOWS DIRECT MANIPULATION OF HARDWARE AND MEMORY,
MAKING IT POWERFUL FOR SYSTEM LEVEL PROGRAMMING.
PORTABLE: C PROGRAMS CAN RUN ON DIFFERENT MACHINES WITH
MINIMAL OR NO MODIFICATION . RICH LIBRARY : C PROVIDES A
STANDARDLIBRARY OF FUNCTIONS FOR COMMON TASKS. MODULAR
PROGRAMMING : SUPPORTS THE USE OF FUNCTIONS AND MODULES,
PROMOTING CODE REUSE
3. LAB COURSE OUTCOMES
AT THE END OF THE COMPUTER PROGRAMMING LAB WE ARE ABLE TO
CODE COURSE OUT COMES
23ESX05.1 Demonstrate the use of basic language features.
23ESX05.2 Apply the right control structure for solving the problem.
23ESX05.3 Implement the simple programs to solve computing problems
using user defined functions.
23ESXO5.4 Develop c programs using arrays and pointers
23ESX05.5 Experiment with user defined data types and file operations
4. PROGRAM OUTCOMES(Pos):-
The POs are the transactional statements of graduate attributes (GAs) that each graduating
engineer should possess in terms of
knowledge, skill and behaviour with a minimum target performance level at the time of
graduation as fixed by the program of study seeking continuous improvement year on year.
The graduates of Electrical & Electronics Engineering of NSRIT will be able to demonstrate the
following outcomes in terms of knowledge, skill and behavioural competencies at the time of
graduation with the expected target performance level.
1. Apply the knowledge of mathematics, science, engineering fundamentals, and an
engineering specialization to the solution of complex engineering problems. (Engineering
Knowledge)
2. Identify, formulate, review research literature, and analyse complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural
sciences, and engineering sciences. (Problem Analysis)
5. 3. Design solutions for complex engineering problems and design system components or
processes that meet the
specified needs with appropriate consideration for the public health and safety, and the cultural,
societal, and
environmental considerations. (Design/Development of Solutions)
4. Use research-based knowledge and research methods including design of experiments,
analysis and interpretation
of data, and
synthesis of the information to provide valid conclusions. (Investigation of Complex Problems)
5. Create, select, and apply appropriate techniques, resources, and modern engineering and IT
tools including
prediction and modelling to complex engineering activities with an understanding of the
limitations. (Modern Tool
Usage)
6. Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal
and cultural issues
and the consequent responsibilities relevant to the professional engineering practice. (The
Engineer and Society)
7. Understand the impact of the professional engineering solutions in societal and environmental
contexts, and
demonstrate the knowledge of, and need for sustainable development. (The Environment and
Sustainability)
6. 8. Apply ethical principles and commit to professional ethics and responsibilities and norms of
the engineering
practice. (Ethics)
9. Function effectively as an individual, and as a member or leader in diverse teams, and in
multidisciplinary settings.
(Individual and Team Work)
10. Use research-based knowledge and research methods including design of experiments,
analysis and
interpretation of data, and synthesis of the information to provide valid conclusions.
(Investigation of Complex
Problems)
11. Demonstrate knowledge and understanding of the engineering and management principles
and apply these to
one’s own work, as a member and leader in a team, to manage Projects and in multidisciplinary
environments. (Project
Finance and Management)
12. Recognize the need for, and have the preparation and ability to engage in independent and
life-long learning in the
broadest
context of technological change. (Life-Long Learning)
7. NAME OF THE EXPERIMENT:-
C PROGRAMS ON WHILE AND
FOR LOOPS
8. INTRODUCTION TO C PROGRAMMING
C is a general-purpose, procedural programming language that was developed in the
early 1970s by
Dennis Ritchie at Bell Labs. It is known for its efficiency and control, which makes it a
popular choice for
system programming, embedded systems, and real-time applications.
Key Features of C
1.Structured Programming: C promotes modularity and code organization through
functions and blocks.
2.Low-Level Access: C allows direct manipulation of memory and hardware, enabling fine-
grained
control over system resources.
3.Efficiency: C code is compiled into machine code, resulting in highly efficient and fast-
running
programs.
4.Portability: C programs can be compiled and run on various platforms with minimal
modifications.
5.Rich Standard Library: C offers a comprehensive standard library with functions for
9. Basic Input and Output Functions :-
Input and output operations are fundamental to any program. They enable the
program to interact
with the user, read data from files, and display results. In C, the standard input/output
library
provides the following essential functions:
➢ Printf() function:
• Used to print formatted output to the console.
• Syntax: printf("format string", argument1, argument2, ...);
• Example:
printf("Hello, world!n");
printf("The value of x is %dn", x);
➢ Scanf() function:
• Used to read formatted input from the console.
• Syntax: scanf("format string", &variable1, &variable2, ...);
• Example:
int age;
printf("Enter your age: ");
scanf("%d", &age);
10. Importance of Input and Output
Functions
• User Interaction:
Input and output functions allow programs to communicate with users,
prompting them for input and displaying results.
• Data Processing:
Programs can read data from files or other sources, process it, and write
the results to files or the console.
• Debugging:
Input and output functions can be used to print intermediate values and
trace the execution of a program to identify and fix errors.
11. PROGRAMS:
#include<stdio.h>
int main()
{
int n, reversed = O ,remainder , original;
printf(“Enter an integer”);
scanf(“%d”,&n);
original =n;
where(n! = 0)
{
remainder = n % 10;
reversed = reversed*10+ remainder;
n/=10;
}
if( original == reversed)
12. {
printf(“%d is a palindrome”, original);
}
else
{
printf(“%d is n0t a palindrome”.original);
}
return 0;
}
13. #include <stdio.h>
int main()
{
int num, originalNum, remainder, result = 0;
printf("Enter a three-digit integer: ");
scanf("%d", &num);
originalNum = num;
while (originalNum ! =0)
{
remainder = originalNum % 10;
result += remainder * remainder * remainder;
originalNum /= 10;
}
if (result == num)
{
printf("%d is an Armstrong number.", num);
15. Real-Time Applications of Simple
C Programs with printf() and scanf()
While C is a powerful language often used for complex systems, even simple C programs utilizing
printf() and scanf() can have practical real-world applications. Here are a few examples:
➢ Data Entry and Validation:
1. Create a program to input personal details like name, age, and address.
2. Implement checks to ensure input is valid (e.g., age is a positive integer, email has the
correct
format).
3. Simulate a basic form where users input information, which can be processed and
stored.
➢ Basic Calculations:
1. Develop a simple calculator to perform arithmetic operations like addition,
subtraction, multiplication, and division.
2. Create a program to convert units (e.g., Celsius to Fahrenheit, kilometres to miles).
3. Calculate simple interest, compound interest, or loan repayments.
16. Key Considerations for Real-Time Applications:
➢ Efficiency :
Optimize code for speed and resource usage, especially in
embedded systems.
➢ Error Handling :
Implement robust error handling to prevent unexpected
behaviour.
➢ User Interface :
Design user-friendly interfaces, even for simple programs.
➢ Security :
Consider security implications, especially when dealing with
sensitive data.
➢ Testing :
Thoroughly test your code to ensure it works as expected.
By mastering the fundamentals of printf() and scanf(), you can
build the foundation for more complex C