Introduction to C Programming
Content :
Introduction
-Types of programming language
-Machine Language
-Assembly Language
-High Level Language
Introduction to C programming
-Basic Structure of C Program
-Simple program in C programming
You can get more from our website:
www.programmingcampus.com
Introduction to C Programming
Content :
Introduction
-Types of programming language
-Machine Language
-Assembly Language
-High Level Language
Introduction to C programming
-Basic Structure of C Program
-Simple program in C programming
You can get more from our website:
www.programmingcampus.com
This C tutorial covers every topic in C with the programming exercises. This is the most extensive tutorial on C you will get your hands on. I hope you will love the presentation. All the best. Happy learning.
Feedbacks are most welcome. Send your feedbacks to dwivedi.2512@gmail.com. You can download this document in PDF format from the link, http://www.slideshare.net/dwivedi2512/learning-c-an-extensive-guide-to-learn-the-c-language
COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMING
1) Introduction to Computer Programming.
2) Computer, Hierarchy of Computer, Compiler.
3) Interpreter, High level language, Features of C language.
Program
Software
Compiler
Interpreter
Modular programming/Structured Programming
Non structured programming
Need of Programming language
Difference between structured and object oriented programming
Advantages of object oriented programming
This file contains complete information about computer Architecture.
1. What is a computer.
2. Types of computers
3. Block Diagram of Computer.
4 . Processor, Memory
5. Computer Generati
This C tutorial covers every topic in C with the programming exercises. This is the most extensive tutorial on C you will get your hands on. I hope you will love the presentation. All the best. Happy learning.
Feedbacks are most welcome. Send your feedbacks to dwivedi.2512@gmail.com. You can download this document in PDF format from the link, http://www.slideshare.net/dwivedi2512/learning-c-an-extensive-guide-to-learn-the-c-language
COMPUTER PROGRAMMING
INTRODUCTION TO COMPUTER PROGRAMMING
1) Introduction to Computer Programming.
2) Computer, Hierarchy of Computer, Compiler.
3) Interpreter, High level language, Features of C language.
Program
Software
Compiler
Interpreter
Modular programming/Structured Programming
Non structured programming
Need of Programming language
Difference between structured and object oriented programming
Advantages of object oriented programming
This file contains complete information about computer Architecture.
1. What is a computer.
2. Types of computers
3. Block Diagram of Computer.
4 . Processor, Memory
5. Computer Generati
computer application in hospitality Industry, periyar university unit 1admin information
in this presentation b.sc hotel management 1 st year student computer application in hospitality Industry subject is the, this subject under periyar university hotel management 1st year students subject.
computer applicationin hospitality Industry1 periyar university unit1admin information
in this power point periyar university bsc hotel management 1st year students com computer applicationin hospitality Industry-1 sylabus 1st unit topic is there
in this power point periyar university bsc hotel management 1st year students com computer applicationin hospitality Industry-1 sylabus 1st unit topic is there
A computer is an electronic device that takes data and instructions as input, processes the data and produces useful information as output.
First Calculating machine: Abacus means calculating board.
Mechanical device Napier Bones for the purpose of multiplication.
Slide rule for addition, subtraction, multiplication and division.
Pascal’s adding and subtractory machine.
Leibniz’s multiplication and dividing machine.
Charles babbage’s analytical engine.
Mechanical and electrical calculator to perform all type of calculation.
Modern electronic calculator.
||||The compilation and execution process of C can be divided into multiple steps:|||
Preprocessing - Using a Preprocessor program to convert C source code in expanded source code. "#includes" and "#defines" statements will be processed and replaced actually source codes in this step.
Compilation - Using a Compiler program to convert C expanded source to assembly source code.
Assembly - Using a Assembler program to convert assembly source code to object code.
Linking - Using a Linker program to convert object code to executable code. Multiple units of object codes are linked to together in this step.
Loading - Using a Loader program to load the executable code into CPU for execution.
|||Steps to solve a Problem||||
Analyze the problem.
Divide the process used to solve the problem in a series of tasks.
Formulate the algorithm to solve the problem.
Convert the algorithm in computer program.
Write the program in computer.
Input the data.
Program operates on input data.
Result produced.
Send the generated result to output unit to display it to user.
This Slides covers:
Introduction to world of Computers, Basic Structure of Computer System, Computers in Home (Reference, Education & Communications, Entertainment an Digital Media Delivery, Smart Appliances, Home Computers), Computers in Education, Computers in workplace (productivity and decision making, customer services, communications), Computers on the move (Portable and Hand held computers, Self-Service kiosks, GPS Applications), Generation of Computer, Types of Computer (Size and Technology wise), Support Systems - Hardware and Software, Computer Peripherals, Memory Management.
Automobile Management System Project Report.pdfKamal Acharya
The proposed project is developed to manage the automobile in the automobile dealer company. The main module in this project is login, automobile management, customer management, sales, complaints and reports. The first module is the login. The automobile showroom owner should login to the project for usage. The username and password are verified and if it is correct, next form opens. If the username and password are not correct, it shows the error message.
When a customer search for a automobile, if the automobile is available, they will be taken to a page that shows the details of the automobile including automobile name, automobile ID, quantity, price etc. “Automobile Management System” is useful for maintaining automobiles, customers effectively and hence helps for establishing good relation between customer and automobile organization. It contains various customized modules for effectively maintaining automobiles and stock information accurately and safely.
When the automobile is sold to the customer, stock will be reduced automatically. When a new purchase is made, stock will be increased automatically. While selecting automobiles for sale, the proposed software will automatically check for total number of available stock of that particular item, if the total stock of that particular item is less than 5, software will notify the user to purchase the particular item.
Also when the user tries to sale items which are not in stock, the system will prompt the user that the stock is not enough. Customers of this system can search for a automobile; can purchase a automobile easily by selecting fast. On the other hand the stock of automobiles can be maintained perfectly by the automobile shop manager overcoming the drawbacks of existing system.
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.
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/
Courier management system project report.pdfKamal Acharya
It is now-a-days very important for the people to send or receive articles like imported furniture, electronic items, gifts, business goods and the like. People depend vastly on different transport systems which mostly use the manual way of receiving and delivering the articles. There is no way to track the articles till they are received and there is no way to let the customer know what happened in transit, once he booked some articles. In such a situation, we need a system which completely computerizes the cargo activities including time to time tracking of the articles sent. This need is fulfilled by Courier Management System software which is online software for the cargo management people that enables them to receive the goods from a source and send them to a required destination and track their status from time to time.
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
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
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.
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
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.
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
C programming for problem solving
1. C Programming for Problem
Solving
Dr. Anuradha T
Department of Computer Science and
Engineering
PDA College of Engineering, Kalaburagi.
07-06-2019 1
2. Contents
• Generations of Computers
• Computer types
• Bits, bytes and words
• CPU
• Primary and Secondary memory
• Ports and Connection
• Input devices and Output Devices
• Computers in a network
• Network Hardware , Software basics
• Software types
• Basic Structure of C Programming
• Executing a C Programming
• Constant , Variables and Data Types
• Operators and Expressions
• Managing Input and Output operations
• Conditional branching and Loops
07-06-2019 2
3. Generations of Computers
• First Generation (1940-1956): Vaccum tubes as
circuitry and magnetic drums for memory, very big in
size they were taking entire room, produces more heat
like bulbs.
• Relied on ‘machine language’ (which is the most
basic programming language that can be understood
by computers). These computers were limited to
solving one problem at a time.
• Input was based on punched cards and paper tape.
Output came out on print-outs.
• The two notable machines of this era were the
UNIVAC and ENIAC machines
07-06-2019 3
4. • Second Generation(1956–1963): The replacement of
vacuum tubes by transistors saw the advent of the second
generation of computing.
• They were a big improvement over the vacuum tube,
despite still subjecting computers to damaging levels of
heat.
• They were hugely superior to the vacuum tubes, making
computers smaller, faster, cheaper and less heavy on
electricity use.
• They still relied on punched card for input/printouts.
• The language evolved from cryptic binary language to
symbolic (‘assembly’) languages.
• This meant programmers could create instructions in
words. About the same time high level programming
languages were being developed (early versions of
COBOL and FORTRAN). :
07-06-2019 4
5. • Third Generation(1964 – 1971): Integrated Circuits
• Transistors were now being miniaturised and put on silicon
chips (called semiconductors).
• This led to a massive increase in speed and efficiency of these
machines.
• These were the first computers where users interacted using
keyboards and monitors which interfaced with an operating
system.
• This enabled these machines to run several applications at
once using a central program which functioned to monitor
memory.
• As a result of these advances which again made machines
cheaper and smaller.
07-06-2019 5
6. Fourth Generation(1972 – 2010 ) : Microprocessors
• The chip-maker developed the Intel 4004 chip in 1971, which
positioned all computer components (CPU, memory,
input/output controls) onto a single.
• The Intel chip housed thousands of integrated circuits. The
year 1981 saw the first ever computer (IBM) specifically
designed for home use and 1984 saw the MacIntosh
introduced by Apple.
• The increased power of these small computers meant they
could be linked, creating networks.
• Which ultimately led to the development, birth and rapid
evolution of the Internet. During this period the Graphical user
interface (GUI), the mouse and lap-top capability and hand-
held devices were introduced.
07-06-2019 6
7. Fifth Generation(2010 to till dated) – Artificial Intelligence
• Computer devices with artificial intelligence are still in
development, but some of these technologies are beginning to
emerge and be used such as voice recognition.
• AI is a reality made possible by using parallel processing and
superconductors.
• The essence of fifth generation will be using these
technologies to ultimately create machines which can process
and respond to natural language, and have capability to learn
and organise themselves.
07-06-2019 7
8. What is a Computer
• It is a machine which accepts the data, process them
and output results.
• A computer is an electronic machine and understands
1‘s and0’s represents bits i.e binary digits
07-06-2019 8
CPU Output deviceInput Device
Main
Memory
Storage
Peripherals
Fig. 1. Block diagram of Computer
9. Computer types
• Computers can be generally classified by size and power as
follows:
• Workstation: A powerful, single-user computer, a workstation
is like a personal computer, but it has a more powerful
microprocessor and, in general, a higher-quality monitor.
• Minicomputer: A multi-user computer capable of supporting
up to hundreds of users simultaneously.
• Mainframe: A powerful multi-user computer capable of
supporting many hundreds or thousands of users
simultaneously.
• Supercomputer: An extremely fast computer that can perform
hundreds of millions of instructions per second.
07-06-2019 9
10. Bits, Bytes and Words
• Bit
• Byte=8bits
• Word=2bytes=16bits
07-06-2019 10
11. • Bit (Abbreviated as Binary Digit) is defined as a
smallest unit of data on a binary computer or digital
system. It can hold either 0 or 1.
• Bytes is defined as a group of 8 bits is called a byte.
Bits in a byte are represented from 0 to 7.
• Bit 0 is the low order bit or least significant bit.
• Bit 7 is the high order bit or most significant bit.
• Word is a group of 16 bits, bits in a word are numbered
starting from 0 to 15.
07-06-2019 11
13. • The CPU, Buses, Controllers, and Main Memory.
Other sections will examine input devices, output
devices, and secondary memory.
• The computer does its primary work in a part of the
machine we cannot see, a control center that converts
data input to information output called the central
processing unit (CPU), is a highly complex, extensive
set of electronic circuitry that executes stored
program instructions.
• Central processing unit (CPU): The heart of the
computer, this is the component that actually executes
instructions organized in programs ("software")
which tell the computer what to do.
07-06-2019 13
14. • Before an instruction can be executed, program instructions
and data must be placed into memory from an input device or
a secondary storage device.
• The central processing unit performs the following four steps
for each instruction:
• The control unit fetches (gets) the instruction from memory.
• The control unit decodes the instruction (decides what it
means) and directs that the necessary data be moved from
memory to the arithmetic/logic unit. These first two steps
together are called instruction time.
• The arithmetic/logic unit executes the arithmetic or logical
instruction. That is, the ALU is given control and performs the
actual operation on the data.
• Thc arithmetic/logic unit stores the result of this operation in
memory or in a register. Steps 3 and 4 together are called
execution time
07-06-2019 14
15. Primary Memory
• Memory is the brain of the computer which stores
data and information for storing and retrieving.
• Just like a human brain, memory is the storage space
of the computer – like a physical device – that is
capable of storing data or programs temporarily or
permanently.
• Memory is a fundamental component of the computer
that is categorized into primary and secondary
memory.
• Primary memory is the main memory of the computer
which can be directly accessed by the central
processing unit.
•07-06-2019 15
16. • Primary memory, also known as the main memory, is
the area in a computer which stores data and
information for fast access.
• Semiconductor chips are the principle technology used
for primary memory.
• It’s a memory which is used to store frequently used
programs which can be directly accessed by the
processing unit for further processing.
• It’s a volatile memory meaning the data is stored
temporarily and is liable to change or lose in case of
power failure.
• Every application on the computer first loads into the
random access memory (RAM) which makes is faster
to access. The term is more ambiguous, since it also
refers to internal memory such as internal storage
devices.
07-06-2019 16
17. Secondary memory
• Secondary memory refers to the external storage device
which can be used to store data or information permanently.
• It’s a non-volatile memory which means data stays even if
the computer is turned off.
• Data cannot be directly processed by the processing unit in
secondary memory; in fact, it is first transferred into the
main memory and then it’s transferred back to the
processing unit.
• Secondary memory refers to all external storage devices
that are capable of storing high volumes of data such as
hard drives, floppy disks, magnetic tapes, USB flash drives,
CDs, DVDs, etc.
• It’s generally slower than primary memory but can store
substantial amount of data, in the range of gigabytes to
terabytes.
07-06-2019 17
18. Ports and Connections
• Port refers to a hardware port or peripheral port is a
hole or connection found on the front or back of a
computer. a port serves as an interface between the
computer and other computers or peripheral devices.
• In computer terms, a port generally refers to the part
of a computing device available for connection to
peripherals such as input and output devices.
• Computer ports have many uses, to connect
a monitor, webcam, speakers, or other peripheral
devices. On the physical layer, a computer port is a
specialized outlet on a piece of equipment to which
a plug or cableconnects.
07-06-2019 18
19. • Electronically, hardware ports can almost always be
divided into two groups based on the signal transfer:
• Serial ports send and receive one bit at a time via a
single wire pair (Ground and +/-).
• Parallel ports send multiple bits at the same time over
several sets of wires.
• After ports are connected, they typically
require handshaking, where transfer type, transfer
rate, and other necessary information is shared before
data is sent.
07-06-2019 19
20. • Electronically, the several conductors where the port
and cable contacts connect, provide a method to
transfer signals between devices.
• Bent pins are easier to replace on a cable than on a
connector attached to a computer, so it was common
to use connectors for the fixed side of an interface.
07-06-2019 20
21. Input Devices
• An input device sends information to a computer
system for processing, and an output
device reproduces or displays the results of that
processing.
• Input devices only allow for input of data to a
computer and output devices only receive the output
of data from another device.
• Most devices are only input devices or output
devices, as they can only accept data input from a
user or output data generated by a computer.
However, some devices can accept input and display
output, and they are referred to as I/O devices
(input/output devices).
07-06-2019 21
22. • Keyboard and Mouse- Accepts input from a
user and sends that data (input) to the
computer. They cannot accept or reproduce
information (output) from the computer.
• Microphone - Receives sound generated by an
input source, and sends that sound to a
computer.
• Webcam - Receives images generated by
whatever it is pointed at (input) and sends
those images to a compute
07-06-2019 22
23. 07-06-2019 23
Fig.3 Input and Output examples
For example, as you can see in the top half of the image, a keyboard sends
electrical signals, which are received by the computer as input.
Those signals are then interpreted by the computer and displayed, or output, on
the monitor as text or images.
In the lower half of the image, the computer sends, or outputs, data to a printer,
which will print the data onto a piece of paper, also considered output.
24. Output Devices
• An output device is any peripheral that receives data
from a computer, usually for display, projection, or
physical reproduction.
• Monitors and printers are two of the most common
output devices used with a computer.
• Every computer has a monitor or display screen, a sound
card (or on-board sound on the motherboard), and a
video card (or on-board video on the motherboard),
which are all output devices.
• A printer is also very commonly used with computers.
Depending on the type of computer and how the
computer is used, other output devices may be used with
a computer.
07-06-2019 24
26. Computer in Networks
• Two or more computers or communication devices
connected by transmission media and channels and
follow set of rules for communication purposes that
allow users to communicate with each other and share
application
07-06-2019 26
27. Types of Networks
• LAN: Local are network
• WAN: Wide area network
• MAN: Metropolitian network
• Depending on one’s perspective we can classify
networks in different ways based on transmission
media, based on size, based on management
method(peer-to-peer and client-server), based on
topology(bus,Star and Ring)
07-06-2019 27
28. Network Hardware
• Network hardware components or devices like Network interface
card (NIC), hub, switch, routers and gateways.
• Hub is simple and cheap but wastes bandwidth, center of star
network, all nodes receive transmitted packets from hub leads to
more congestion in traffic.
• slow and insecure because all nodes will know the information of all
nodes.
• Switch: replacement of hubs, only the intended nodes receive
transmission. Fast and secure as they use MAC address of each
computer, less congestion.
• Routers: connects two or more MANs together, packets sent to
remote LANs together
• Network is segmented by IP address, connect internal network to the
internet, need to before installation.
• Bridge: connects two or more LANs together, remote packets cross
the LANs whereas other nodes wont cross LANs.
• Gateway: is a node or router is a computer network a key stopping
point for data in its way or from other network, Connets two
dissimilar network.
07-06-2019 28
30. • A program is a set of computer instructions that
perform a particular task.
• That program can be written in assembler, a very low
level computer language, or in a high level, machine
independent language such as the C programming
language.
• An operating system is a special program which
allows the user to run applications such as
spreadsheets and word processors
07-06-2019 30
31. Computer language
Assembly Languages
• The instructions that a CPU fetches from memory and
executes are not at all understandable to human beings. They
are machine codes which tell the computer precisely what to
do.
The C Programming Language and Compiler
• Writing large programs in assembly language is a difficult and
time consuming task.
• It is far better to use a machine independent language like C.
• C allows you to describe programs in terms of their logical
algorithms and the data that they operate on.
• Special programs called compilers read the C program and
translate it into assembly language, generating machine
specific code from it.
07-06-2019 31
32. Linkers
• Linkers are programs that link together several object modules
and libraries to form a single, coherent, program.
• Object modules are the machine code output from an
assembler or compiler and contain executable machine code
and data together with information that allows the linker to
combine the modules together to form a program.
• For example one module might contain all of a program's
database functions and another module its command line
argument handling functions.
07-06-2019 32
33. Software Types
• System software and Application software
• System software: It is defined as a collection of programs
that controls the overall operations and internal working
of the computer system.
• Two types of system software are:
• Operating system: controls the overall activities of a
computer
• Utility programs: are the program that assist in the
smooth functioning of a computer. Help to avoid viirus
attack
• Application software: Set of programs which are used to
perform specific types of jobs like performing calculation,
arranging data in an organized way.
07-06-2019 33
34. Managing input and output operations
• Reading a character
• Writing a character
• Formatted input
• Formatted output
07-06-2019 34
35. • Reading a character:
• Reading a single character from standard input using
getchar function.
• Syntax for variable_name=getchar();
name=getchar();
• Writing a character:
• Writing a single character to the standard output using
putchar function.
• Syntax putchar (variable_name);
answer=‘Y’;
putchar (answer);
07-06-2019 35
36. • Formatted Input: refers to an input data that
has been arranged in a particular format.
• Example: consider the following data
5.72 123 john
• This line contains three pieces of data, first is
read as float, second as int, third as char.
• Reading the formatted data using scanf
function.
scanf(“control string”,arg1,arg2,...argn);
Control string specifies field format in which data has
to be entered and arguments specify the address of
locations where data is stored.07-06-2019 36
37. Formatted output
• printf statement is used for formatted output to print
captions and numerical results on the terminal.
• printf(“control string”, arg1,arg2,…argn);
• Control strings specifies how many args follow their
types are
07-06-2019 37
38. Loops
• while loop: is an entry controlled loop statement. The test condition
is evaluated and if the condition is true, then the body of the loop is
executed.
• while(test condition)
{
body of the loop
}
• do loop: the program proceeds to evaluate the body of the loop first.
At the end of the loop the test condition in the while statement is
evaluated.
• do
{
body of the loop
}
• While(test-condition)
07-06-2019 38
39. • for loop: is another entry-controlled loop that
provides a more concise loop control structure.
The general form is
for( initialization; test-condition; increment)
{
body of the loop
}
Example: for (x=0; x<=9; x++)
07-06-2019 39
40. Branching
• If statement is a decision making statement and is
used to control the flow of execution of statements.
syntax: if(test expression)
{
statement-block;
}
statement-x;
07-06-2019 40
Test
expression
Fig. 5 Two way branching
Entry
True
False
41. If statement
07-06-2019 41
Fig.5. Flowchart for if statement
Example:
If(category= =Sports)
{
marks=marks+bonus_marks;
}
printf(“%d”, marks);
43. Nested if else statement
07-06-2019 43Fig. 7.Flowchart for netsted if else statement
44. Syntax for nested if else statement
if(condition)
{
//Nested if else inside the body of "if" if(condition2)
{
//Statements inside the body of nested "if“
}
else
{
//Statements inside the body of nested "else"
}
}
else
{
//Statements inside the body of "else“
}
07-06-2019 44
45. #include <stdio.h>
int main()
{
int var1, var2;
printf("Input the value of var1:");
scanf("%d", &var1);
printf("Input the value of var2:");
scanf("%d",&var2);
if (var1 != var2)
{
printf("var1 is not equal to var2n");
//Nested if else
if (var1 > var2)
{
printf("var1 is greater than var2n");
}
else {
printf("var2 is greater than var1n");
}
}
else
{ printf("var1 is equal to var2n");
07-06-2019 45
Example
46. Switch statement
switch (variable or an integer expression)
{
case constant:
//C Statements ;
break;
case constant:
//C Statements ;
default:
//C Statements ;
break;
}
07-06-2019 46
47. Example
#include <stdio.h>
int main()
{
int month;
switch(month)
printf(“ enter the value of months from 1-12”);
Scanf(“%d”, &month);
{
case 1:
printf(" January month );
break; //transfers the control out of switch statement
case 2:
printf(“Feb month”,);
break;
case 3:
printf(“March month");
Break;
default: // when no match is found
printf("Default: value not month);
}
return 0;
}
07-06-2019 47
48. Memory
C(High level language)
07-06-2019 48
CPU
ROM
Seconddary
memory
RAM
C- Compiler
Machine
Language
Save the
program
Memory
Disk
During
execution
it goes
from the
secondary
to RAM
CPU reads
from RAM
and
executes the
pgm
Fig. 8. flow of execution of program and how memory is used
49. C Programming
• C is one of the programming and basic language.
• C is a robust language whose rich set of built-in
functions and operators can be used to write any
complex program.
• Important feature of C its ability to extend itself.
• Highly portable, means that C program can be run on
another with little or no moification
07-06-2019 49
50. Basic Structure of C Programming
Sample program #1
#include<stdio.h> // default thing, stdio means standard io
whenever we get instructions with
respect to keyboard and anything to be
printed on the screen
main() //main function is executed when you run the program
{
printf(“n hello worldn”) //printing the statements that are
within “ ”
“n denotes end of line or new line
}
07-06-2019 50
51. Sample C Program #2
#include<stdio.h>
main()
{
int a,b,c; //type declaration
a=10;
b=20;
c=a+b;
printf(“n the sum of %d and %d is %dn”,a,b,c); //this
statement is equivalent to the sum of ____and _____is ___
} %d=10 %d = 20 %d=30
07-06-2019 51
52. Constant, Variable and DataTypes
• Variable ‘a’ is of type integer a
correct wrong
• Variable ‘b’ is of type float b
correct wrong
07-06-2019 52
20 10.5
20.5 30
53. Executing a C Program
• Creating a Program
• Compiling the Program
• Linking the Program with functions that are needed
from c library and
• Executing the program
07-06-2019 53
54. Constants
• Constants in C refer to fixed values that do not
change during the execution of a program
07-06-2019 54
Constants
String
Constants
Character
constants
Numeric Constant
Integer constant
Real
Constants
Single
character
Constants
Fig.9. Types of C Constants
Eg: heights,
temp and
prices
Eg: decimal, octal
and hexadecimal
Eg: ‘5’,’X’ ,‘ ‘ Eg:“Hello”,”1987”
55. Variables
• Variable is a data name that may be used to store a
data value.
• Unlike the constant that remains unchanged during
execution of program.
• Variable may take different values at different times
during execution of a program.
• They must begin with a letter
• Uppercase and lower case letters are significant.
• It should not be a keyword.
• Declaring a variable means it tells the compiler what
the variable name is and it specifies what type of data
the variable will hold.
07-06-2019 55
56. Data Types
C supports three types of data types:
• Primary data types
• Derived data types
• User-defined data types such as Arrays, functions,
structures and pointers.
• All C compilers support five fundamental data types,
namely, integer (int)
• floating point(float)
• double-precision (double)
• void
07-06-2019 56
57. Operators and Expressions
• An operator is a symbol that tells the computer to perform certain
mathematical or logical manipulations. C operators can be classified into a
number of categories.
• Arithmetic operators: + , _, *, /, %
• Relational operators: <, <=, >, >=, = =, !=
• Logical operators: &&, ||, !,
• Assignment operators: ==,=
• Increment and decrement operators: ++, _ _
• Conditional operators and Bitwise operators: ?
07-06-2019 57
58. Expressions
• Arithmetic expressions
• a*b-c
• (m+n)*(x+Y)
• a*b/c
• x/y+c
• Evaluation of expressions using assignment statement
of the form: Variable=expression;
• X=a*b-c;
• Y=b/c*a;
07-06-2019 58
60. Finding the roots of Quadratic equation
• General form of quadratic equation is ax2 +bx+c=0
• Roots=-b±Sqrt(b2-4ac)/2a, where a,b,c are co-efficients.
• If a & b =0 then we get no roots, else if a,b,c are non
zero values. Imaginary roots
• d=b*b-4*a*c if d<0
• If d=0, (roots are equal) roots=-b+√d ,
root1=root2=-b/2a 2a
• If d>0 (distinct) root1=-b/2a, root2=√d/2a
• root1= -b+√d ,
2a root1+iroot2
• root2= = -b-√d ,
2a root1-iroot2
07-06-2019 60
61. Pascal Triangle
• Pascal triangle is a triangular array of binomial
coefficients.
• How to implement pascal triangle in c.
• Basically we will figureout number of spaces in each
row.
• Formula for no of spaces=number
i.e number of rows –nth row-1
07-06-2019 61