SlideShare a Scribd company logo
1 of 40
J N N College of Engineering
Dept. Information Science and Engineering
Course In-charge
Girish Mantha
Asst. Professor
ISE Dept
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 1
C Programming for Problem Solving – 18CPS13
C Programming Laboratory - 18CPL17
BE-1st Sem, Chemistry Cycle
C PROGRAMMING FOR PROBLEM SOLVING
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 2
Course Objectives
CO1 Understand the basics of computer hardware and software
CO2 Understand the problem solving techniques using C programming constructs
CO3 Develop programs in C language based on modular programming
CO4 Implement the programs in C language based on the concepts of structures, pointers
and preprocessor directives.
Theory :
At the end of Course students should be able to:
C PROGRAMMING FOR PROBLEM SOLVING
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 3
Course Objectives
Lab :
At the end of Course students should be able to:
CO1 Identify different components of a computer
CO2 Develop different programming constructs for problem solving using C language
CO3 Use modular programming concepts to develop solutions to a problem
CO4 Develop program in C language based on concepts of structure and pointers
C PROGRAMMING FOR PROBLEM SOLVING
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 4
Evaluation
Pattern
CIE Marks = 40 (30 marks from test, 10 marks for Assignment)
SEE Marks = 60 ( SEE exam will conducted for 100 marks and reduced to 60)
MODULE-1
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 5
Syllabus
Introduction to computer hardware and Software: Computer generations,
computer types, bits, bytes, and words, CPU, primary, secondary memory, ports
and connections , input & output devices, computers in networks, network
hardware, software basics and software types.
Overview of C: Basic structure of C program, executing C program. Constant,
variable and datatypes, operators and expressions. (RBT Levels: L1 & L2)
MODULE-1 : Introduction to computer hardware and Software
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 6
INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE:
Computer generations :
First Generation computers
Time Period : 1951 to 1959
Technology : Vacuum Tubes
Size : Very Large System
Processing : Very Slow
Characterized By:-
 Magnetic Drums
 Magnetic Tapes
 Difficult to program
 Used machine language & assembly language
MODULE-1 : Introduction to computer hardware and Software
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 7
INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE:
Computer generations :
Second Generation computers
Time Period : 1959 to 1963
Technology : Transistors
Size : Smaller
Processing : Faster
Characterized By:-
 Magnetic Cores
 Magnetic Disk
 Used high level language
 Easier to program
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 8
INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE:
Computer generations :
Third Generation computers
Time Period : 1963 to 1975
Technology : ICs (Integrated Circuits)
Incorporated many transistors & electronic
circuits on a single chip
Size : Smaller as compared to 2nd
generation computers
Processing : Faster than 2nd generation
computers
Characterized By:-
Minicomputers accessible by multiple users
from remote terminals.
MODULE-1 : Introduction to computer hardware and Software
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 9
INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE:
Computer generations :
Fourth Generation computers
Time Period : 1975 till now
Technology : VLSI (Very Large Scale Integration)
Incorporated many millions of transistors
& electronic circuits on a single chip
Size : Small as compared to first generation
computer
Processing : Faster than third generation computer
Characterized By:-
 The personal computer and user friendly micro-
programs, very fast processor chip high level
language, OOP (Object Oriented Programming)
MODULE-1 : Introduction to computer hardware and Software
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 10
INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE:
Computer generations :
Fifth Generation computers
Time Period : present and Future Technology
Technology : Artificial Intelligence
Size : Micro and Nano size
Processing : Faster than Fourth generation computer
Characterized By:-
 Artificial Intelligence
MODULE-1 : Introduction to computer hardware and Software
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 11
COMPUTER AND COMPUTER TYPES
Computer : Computer is an electronic device for storing and processing data, typically in binary form, according to
instructions given to it in a variable program.
Classification based on working technology :
 Analog computers
 Digital computers
 Hybrid computers
Classification based on size, usage and speed :
 Super Computers
 Mainframe computers
 Mini Computers
 Micro computers
 Small & Embedded computers
MODULE-1 : Introduction to computer hardware and Software
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 12
COMPUTER MEMORY SYSTEM
Computer : Computer is an electronic device for storing and processing data, typically in binary form, according to
instructions given to it in a variable program.
BITS
Computer memory stores everything in terms of bits, zero’s and ones’s. (1/0).
BYTES
Group of 8 bits are called as 1 byte. Similarly group of 1028 Bytes are called 1KB and so on.
PRIMARY & SECONDARY MEMORY
Physical memory in CPU is differentiated as primary and secondary memory.
MODULE-1 : Introduction to computer hardware and Software
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 13
DIFFERENCES BETWEEN PRIMARY AND SECONDARY MEMORY
SR.NO. PRIMARY MEMORY SECONDARY MEMORY
1. Primary memory is temporary. Secondary memory is permanent.
2.
Primary memory is directly accessible by
Processor/CPU.
Secondary memory is not directly accessible by the
CPU.
3.
Nature of Parts of Primary memory varies,
RAM- volatile in nature. ROM- Non-volatile.
It’s always Non-volatile in nature.
4.
Primary memory devices are more expensive
than secondary storage devices.
Secondary memory devices are less expensive when
compared to primary memory devices.
5.
The memory devices used for primary
memory are semiconductor memories.
The secondary memory devices are magnetic and
optical memories.
6.
Primary memory is also known as Main
memory or Internal memory.
Secondary memory is also known as External memory
or Auxiliary memory.
7.
Examples: RAM, ROM, Cache memory, PROM,
EPROM, Registers, etc.
Examples: Hard Disk, Floppy Disk, Magnetic Tapes,
etc.
MODULE-1 : Introduction to computer hardware and Software
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 14
CENTRAL PROCESSING UNIT(CPU)
MODULE-1 : Introduction to computer hardware and Software
A central processing unit (CPU) is the electronic circuitry within a
computer that carries out the instructions of a computer program by
performing the basic arithmetic, logical, control and input/output
(I/O) operations specified by the instructions.
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 15
PORTS & CONNECTIONS
MODULE-1 : Introduction to computer hardware and Software
A port is a physical docking point using which an external device can be connected to the computer.
1. Serial Port – to connect mouse
2. Parallel Port – Scanner and Printers
3. PS/2 Port - to connect old computer keyboard and mouse
4. Universal Serial Bus (or USB) Port - It can connect all kinds of external USB devices
5. VGA Port - Connects monitor to a computer's video card
6. Power Connector - Connects to the computer's power cable
7. Firewire Port - Transfers large amount of data at very fast speed.
8. Modem Port - Connects a PC's modem to the telephone network.
9. Ethernet Port - Connects to a network and high speed Internet.
10. Game Port - Connect a joystick to a PC
11. Digital Video Interface, DVI port - Connects Flat panel LCD monitor to the computer's high-end video graphic
cards.
12. Sockets - connect the microphone and speakers to the sound card of the computer.
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 16
COMPUTERS IN NETWORK
MODULE-1 : Introduction to computer hardware and Software
Types of Network
1. Personal Area Network (PAN)
2. Local Area Network (LAN)
3. Wireless Local Area Network (WLAN)
4. Campus Area Network (CAN)
5. Metropolitan Area Network (MAN)
6. Wide Area Network (WAN) Storage
7. System-Area Network (also known as SAN)
8. Passive Optical Local Area Network (POLAN)
9. Enterprise Private Network (EPN)
10. Virtual Private Network (VPN)
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 17
COMPUTERS IN NETWORK
MODULE-1 : Introduction to computer hardware and Software
Networking Hardware
1. Network Cables - Network cables are the transmission media to transfer data from one device to another.
2. Routers - is a connecting device that transfers data packets between different computer networks.
3. Repeaters, Hubs, and Switches - Connects network devices together so that they can function as a single
segment.
4. Bridges - Connects two separate Ethernet network segments. It forwards packets from the source network to the
destined network.
5. Gateways - Connects entirely different networks that work upon different protocols. It is the entry and the exit
point of a network and controls access to other networks.
6. Network Interface Cards - NIC is a component of the computer to connect it to a network. Network cards are of
two types: Internal network cards and external network cards.
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 18
COMPUTERS IN NETWORK
MODULE-1 : Introduction to computer hardware and Software
Software’s and types :
Software is a collection of data, programs, procedures, instructions, and documentation that
perform various predefined tasks on a computer system. They enable users to interact with the
computer
Types
1. System Software
System software aids the user and the hardware to function and interact with each other. Basically, it is software to manage computer hardware
behavior so as to provide basic functionalities that are required by the user.
a. Operating Systems
b. Device Drivers
c. Firmware
d. Programming Language Translators
e. Utility
1. Application Software
Application software also known as end-user programs or productivity programs are software that helps the user in completing tasks such as doing
online research, jotting down notes, setting an alarm, designing graphics, keeping an account log, doing calculations or even playing games.
a. Word processors
b. Database software
c. Multimedia software
d. Education and Reference Software
e. Graphics Software
f. Web Browsers
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 19
MODULE-1 : OVERVIEW OF ‘C’
Problem Solving in C
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 20
Basic Concepts of C Program. Example :
/* This is Documentation Section */
Program to Print Hello World on the
terminal */
#include <stdio.h>
void main()
{
/* This is how comments are implemented in C
to comment out a block of text */
// or like this for a single line comment
printf( "Hello Worldn" ) ;
}
MODULE-1 : OVERVIEW OF ‘C’
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 21
Steps in Executing a C Program Executing a C program involves following steps :
1. Creating a C Program
2. Compiling the C Program
3. Linking the program Executing the C program.
MODULE-1 : OVERVIEW OF ‘C’
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 22
Properties of C Programming Language.
C language became popular because of the following reasons.
• C is a robust language, which consists of number of built-in functions and operators can be used to write any complex
program
• Programs written in c are executed fast compared to other languages.
• C language is highly portable
• C language is well suited for structured programming.
• C is a simple language and easy to learn.
MODULE-1 : OVERVIEW OF ‘C’
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 23
‘C’ - TOKENS
MODULE-1 : OVERVIEW OF ‘C’
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 24
‘C’ - TOKENS
MODULE-1 : OVERVIEW OF ‘C’
KEYWORDS
• Keywords are tokens which are used for their intended
purpose only.
• Each keyword has fixed meaning and that cannot be
changed by user. Hence, they are also called reserved-
words.
IDENTIFIER
• As the name indicates, a identifier is used to identify various
entities of program such as variables, constants, functions etc.
• In other words, an identifier is a word consisting of sequence
of
→ Letters
→ Digits or
→ "_"(underscore)
• For ex: area, length, breadth
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 25
‘C’ - TOKENS
MODULE-1 : OVERVIEW OF ‘C’
CONSTANTS
A constant is an identifier whose value remains fixed
throughout the execution of the program.
The constants cannot be modified in the program.
For example:
1, 3.14512 , “z‟, “girishmantha"
Different types of constants are:
1) Integer Constant
2) Floating Point Constant
3) Character Constant
4) String Constant
5) Escape Sequence Characters
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 26
‘C’ - DATATYPES
MODULE-1 : OVERVIEW OF ‘C’
The data type defines the type of data stored in a memory-location.
1) int
2) float
3) double
4) char
5) void
Data type Bytes Range of data type
char 1 bytes -128 to 127
int 2 bytes -32, 768 to 32,767
float 4 bytes 3.4E-38 to 3.4E38
double 8 bytes 1.7E-308 to 1.7E308
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 27
‘C’ - VARIABLES
MODULE-1 : OVERVIEW OF ‘C’
A variable is an identifier whose value can be changed during execution of the program.
In other words, a variable is a name given to a memory-location where the data can be stored.
• Using the variable-name, the data can be
→ stored in a memory-location and
→ accessed or manipulated
Rules for defining a variable
1) The first character in the variable should be a letter or an underscore
2) The first character can be followed by letters or digits or underscore
3) No extra symbols are allowed (other than letters, digits and underscore)
4) Length of a variable can be up to a maximum of 31 characters
5) Keywords should not be used as variable-names
Valid variables:
Ex : a, principle_amount, sum_of_digits
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 28
‘C’ - VARIABLES
MODULE-1 : OVERVIEW OF ‘C’
Declaring Variables
Syntax :- datatype var-name;
Ex : int age; //stores integer value in variable age
Char section; //variable section stores only one char
Double salary; // Variable salary stores double value with decimal number
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 29
‘C’ - VARIABLES
MODULE-1 : OVERVIEW OF ‘C’
Initializing Variables
Syntax :- datatype var-name = constant ;
For Example :-
char ch = 'a' ;
double d = 12.2323 ;
int i, j = 20 ; /* note in this case i is not initialized */
Assigning values to variables
Ex :
int x,y,z;
x = 20 ;
x = y = z = 100 ;
Girish Mantha
ISE Dept
JNNCE, Shimoga
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 30
Type Conversions
MODULE-1 : OVERVIEW OF ‘C’
• Unary Operator
• Increment and Decrement Operators
• Binary Operator
• Arithmetic Operators
• Assignment Operator
• Assignment Operator
• Relational Operators
• Logical Operators
• Bitwise Operators
• Ternary Operator
• Conditional Operator
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 31
Increment and Decrement Operators
MODULE-1 : OVERVIEW OF ‘C’
INCREMENT OPERATOR
• ++ is an increment operator.
• As the name indicates, increment means increase, i.e. this operator is used to increase the value of a variable by 1.
• For example:
If b=5
then b++ or ++b; // b becomes 6
• The increment operator is classified into 2 categories:
1) Post increment Ex: b++
2) Pre increment Ex: ++b
#include<stdio.h>
void main()
{
int x=10,y = 10, z ;
z= x++;
printf(“ z=%d x= %dn”, z, x);
z = ++y;
printf(“ z=%d y= %d”, z, y);
}
Output:
z=10 x=11
z=11 y=11
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 32
Increment and Decrement Operators
MODULE-1 : OVERVIEW OF ‘C’
DECREMENT OPERATOR
• -- is a decrement operator.
• As the name indicates, decrement means decrease, i.e. this operator is used to decrease the value of a variable by 1.
• For example:
If b=5
then b-- or --b; // b becomes 4
• Similar to increment operator, the decrement operator is classified
into 2 categories:
1) Post decrement Ex: b--
2) Pre decrement Ex: --b
void main()
{
int x=10,y = 10, z ;
z= x--;
printf(“ z=%d x= %dn”, z, x);
z = --y;
printf(“ z=%d y= %d”, z, y);
}
Output:
z=10 x=9
z=9 y=9
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 33
Logical Operators
MODULE-1 : OVERVIEW OF ‘C’
Operator Meaning Example
&& Logical AND If c=5 and d=2 then ((c==5) && (d>5)) returns false.
|| Logical OR If c=5 and d=2 then ((c==5) || (d>5)) returns true.
! Logical NOT If c=5 then !(c==5) returns false.
#include<stdio.h>
void main(){
printf(“7 && 0 : %d n”, 7 && 0 );
printf(“7 || 0 : %d n”, 7 || 0 );
printf(“ !0 : %d”, !0 );
}
Output:
7 && 0 : 1
7 || 0 : 1
!0 : 1
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 34
CONDITIONAL OPERATOR (Ternary Operator)
MODULE-1 : OVERVIEW OF ‘C’
• The conditional operator is also called ternary operator it takes three operands.
• Conditional operators are used for decision making in C.
• The syntax is shown below:
(exp1)? exp2: exp3;
where exp1 is an expression evaluated to true or false;
If exp1 is evaluated to true, exp2 is executed;
If exp1 is evaluated to false, exp3 is executed.
#include<stdio.h>
void main()
{
int a,b, max ;
printf(“ enter 2 distinct numbers n”);
scanf(“%d %d”, &a, &b);
max=(a>b)? a : b;
printf(“ largest number =%d ”, max);
}
Output:
enter 2 distinct numbers
3 4
largest number = 4
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 35
BITWISE OPERATORS(Binary Operator)
MODULE-1 : OVERVIEW OF ‘C’
• These operators are used to perform logical operation (and, or, not) on individual bits of a binary number.
• There are 6 bitwise operators:
Operators Meaning of operators
& Bitwise AND
| Bitwise OR
^ Bitwise exclusive OR
~ Bitwise complement
<< Shift left
>> Shift right
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 36
TYPE CONVERSION
MODULE-1 : OVERVIEW OF ‘C’
• Type conversion is used to convert data of one type to data of another type.
• Type conversion is of 2 types as shown in below figure:
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 37
IMPLICIT TYPE CONVERSION
MODULE-1 : OVERVIEW OF ‘C’
• If a compiler converts one type of data into another type of data automatically, it is known as implicit
conversions.
• There is no data loss in implicit conversion.
• The conversion always takes place from lower rank to higher rank.
For ex, int to float as shown in the above datatype hierarchy.
• For ex:
int a = 22, b=11;
float c = a; //c becomes 21.000000
float d=b/c=11/22.000000=11.000000/22.000000=0.500000
• Example: Program to illustrate implicit conversion.
#include<stdio.h>
void main()
{
int a = 22, b=11;
float d ;
d=b/c;
printf("d Value is : %f ", d );
}
Output:
d Value is : 0.500000
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 38
EXPLICIT TYPE CONVERSION
MODULE-1 : OVERVIEW OF ‘C’
• When the data of one type is converted explicitly to another type with the help of some pre-define functions,
it is called as explicit conversion.
• There may be data loss in this process because the conversion is forceful.
• The syntax is shown below:
data_type1 v1;
data_type2 v2= (data_type2) v1;
where v1 can be expression or variable
• For ex:
float b=11.000000;
int c = 22;
float d=b/(float)c=11.000000/22.000000=0.500000
• Example: Program to illustrate explicit conversion.
#include<stdio.h>
void main()
{
float b=11.000000;
int c = 22;
float d;
d=b/(float)c;
printf("d Value is : %f ", d );
}
Output:
d Value is : 0.500000
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 39
THE PRECEDENCE OF OPERATORS
MODULE-1 : OVERVIEW OF ‘C’
• The order in which different operators are used to evaluate an expression is called precedence
of operators. #include<stdio.h>
void main()
{
int a = 20;
int b = 10;
int c = 15;
int d = 5;
int e;
e = (a + b) * c / d; // ( 30 * 15 ) / 5
printf("Value of (a + b) * c / d is : %d n", e );
e = ((a + b) * c) / d; // (30 * 15 ) / 5
printf("Value of ((a + b) * c) / d is : %d n" , e );
e = (a + b) * (c / d); // (30) * (15/5)
printf("Value of (a + b) * (c / d) is : %d n", e );
e = a + (b * c) / d; // 20 + (150/5)
printf("Value of a + (b * c) / d is : %d " , e );
}
Output:
Value of (a + b) * c / d is : 90
Value of ((a + b) * c) / d is : 90
Value of (a + b) * (c / d) is : 90
Value of a + (b * c) / d is : 50
4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 40
MODULE-1
END MODULE-1

More Related Content

What's hot

Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
Ahmed M. Abed
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
jemimajerome
 
Harvard architecture
Harvard architectureHarvard architecture
Harvard architecture
Gichelle Amon
 

What's hot (20)

Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer Architecture
 
Unit 5 Advanced Computer Architecture
Unit 5 Advanced Computer ArchitectureUnit 5 Advanced Computer Architecture
Unit 5 Advanced Computer Architecture
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
 
Part I:Introduction to assembly language
Part I:Introduction to assembly languagePart I:Introduction to assembly language
Part I:Introduction to assembly language
 
Operating system architecture
Operating system architectureOperating system architecture
Operating system architecture
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086
 
Computer Organization and Assembly Language
Computer Organization and Assembly LanguageComputer Organization and Assembly Language
Computer Organization and Assembly Language
 
Stored program concept
Stored program conceptStored program concept
Stored program concept
 
Disk scheduling
Disk schedulingDisk scheduling
Disk scheduling
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
Computer Organization and Architecture.
Computer Organization and Architecture.Computer Organization and Architecture.
Computer Organization and Architecture.
 
Modes of data transfer
Modes of data transferModes of data transfer
Modes of data transfer
 
Peephole Optimization
Peephole OptimizationPeephole Optimization
Peephole Optimization
 
Assemblers
AssemblersAssemblers
Assemblers
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
Processes and threads
Processes and threadsProcesses and threads
Processes and threads
 
x86 architecture
x86 architecturex86 architecture
x86 architecture
 
Modern block cipher
Modern block cipherModern block cipher
Modern block cipher
 
Processor Organization and Architecture
Processor Organization and ArchitectureProcessor Organization and Architecture
Processor Organization and Architecture
 
Harvard architecture
Harvard architectureHarvard architecture
Harvard architecture
 

Similar to VTU 18CPS13/23 CPPS module-1 PPT

computer peripheral & hardware maintenance micro project (22013).pdf
 computer peripheral & hardware maintenance micro project (22013).pdf computer peripheral & hardware maintenance micro project (22013).pdf
computer peripheral & hardware maintenance micro project (22013).pdf
BhaveshNehare
 
1. Programming in C - Introduction.pdf
1. Programming in C - Introduction.pdf1. Programming in C - Introduction.pdf
1. Programming in C - Introduction.pdf
hydyc
 
Wonho Park_20151209
Wonho Park_20151209Wonho Park_20151209
Wonho Park_20151209
Wonho Park
 
computer archtecture lab, computer hardware , problem and solutons in computer
computer archtecture lab, computer hardware , problem and solutons in computercomputer archtecture lab, computer hardware , problem and solutons in computer
computer archtecture lab, computer hardware , problem and solutons in computer
GS Kosta
 

Similar to VTU 18CPS13/23 CPPS module-1 PPT (20)

Architecture presentation
Architecture presentationArchitecture presentation
Architecture presentation
 
computer peripheral & hardware maintenance micro project (22013).pdf
 computer peripheral & hardware maintenance micro project (22013).pdf computer peripheral & hardware maintenance micro project (22013).pdf
computer peripheral & hardware maintenance micro project (22013).pdf
 
mod1.pptx
mod1.pptxmod1.pptx
mod1.pptx
 
Networking of Micro-Controllers through USB
Networking of Micro-Controllers through USBNetworking of Micro-Controllers through USB
Networking of Micro-Controllers through USB
 
COMPUTER ORGANIZATION AND ARCHITECTURE
COMPUTER ORGANIZATION AND ARCHITECTURECOMPUTER ORGANIZATION AND ARCHITECTURE
COMPUTER ORGANIZATION AND ARCHITECTURE
 
1. Programming in C - Introduction.pdf
1. Programming in C - Introduction.pdf1. Programming in C - Introduction.pdf
1. Programming in C - Introduction.pdf
 
Introduction to Computers
Introduction to ComputersIntroduction to Computers
Introduction to Computers
 
EEE226a.ppt
EEE226a.pptEEE226a.ppt
EEE226a.ppt
 
Wonho Park_20151209
Wonho Park_20151209Wonho Park_20151209
Wonho Park_20151209
 
Hardware description of a simplified 4-bit softcore processor with bcd capabi...
Hardware description of a simplified 4-bit softcore processor with bcd capabi...Hardware description of a simplified 4-bit softcore processor with bcd capabi...
Hardware description of a simplified 4-bit softcore processor with bcd capabi...
 
Hardware description of a simplified 4-bit softcore processor with bcd capabi...
Hardware description of a simplified 4-bit softcore processor with bcd capabi...Hardware description of a simplified 4-bit softcore processor with bcd capabi...
Hardware description of a simplified 4-bit softcore processor with bcd capabi...
 
computer archtecture lab, computer hardware , problem and solutons in computer
computer archtecture lab, computer hardware , problem and solutons in computercomputer archtecture lab, computer hardware , problem and solutons in computer
computer archtecture lab, computer hardware , problem and solutons in computer
 
Computing Without Computers - Oct08
Computing Without Computers - Oct08Computing Without Computers - Oct08
Computing Without Computers - Oct08
 
slides.pdf
slides.pdfslides.pdf
slides.pdf
 
Computer Hardware Servicing Learning Module v.2.0
Computer Hardware Servicing Learning Module v.2.0Computer Hardware Servicing Learning Module v.2.0
Computer Hardware Servicing Learning Module v.2.0
 
Embedded systems-unit-1
Embedded systems-unit-1Embedded systems-unit-1
Embedded systems-unit-1
 
Linux-Based Data Acquisition and Processing On Palmtop Computer
Linux-Based Data Acquisition and Processing On Palmtop ComputerLinux-Based Data Acquisition and Processing On Palmtop Computer
Linux-Based Data Acquisition and Processing On Palmtop Computer
 
Linux-Based Data Acquisition and Processing On Palmtop Computer
Linux-Based Data Acquisition and Processing On Palmtop ComputerLinux-Based Data Acquisition and Processing On Palmtop Computer
Linux-Based Data Acquisition and Processing On Palmtop Computer
 
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 2 - The Sys...
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 2 - The Sys...Understanding Computers: Today and Tomorrow, 13th Edition Chapter 2 - The Sys...
Understanding Computers: Today and Tomorrow, 13th Edition Chapter 2 - The Sys...
 
Cp unit 1
Cp unit 1Cp unit 1
Cp unit 1
 

Recently uploaded

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 

Recently uploaded (20)

Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 

VTU 18CPS13/23 CPPS module-1 PPT

  • 1. J N N College of Engineering Dept. Information Science and Engineering Course In-charge Girish Mantha Asst. Professor ISE Dept 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 1 C Programming for Problem Solving – 18CPS13 C Programming Laboratory - 18CPL17 BE-1st Sem, Chemistry Cycle
  • 2. C PROGRAMMING FOR PROBLEM SOLVING Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 2 Course Objectives CO1 Understand the basics of computer hardware and software CO2 Understand the problem solving techniques using C programming constructs CO3 Develop programs in C language based on modular programming CO4 Implement the programs in C language based on the concepts of structures, pointers and preprocessor directives. Theory : At the end of Course students should be able to:
  • 3. C PROGRAMMING FOR PROBLEM SOLVING Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 3 Course Objectives Lab : At the end of Course students should be able to: CO1 Identify different components of a computer CO2 Develop different programming constructs for problem solving using C language CO3 Use modular programming concepts to develop solutions to a problem CO4 Develop program in C language based on concepts of structure and pointers
  • 4. C PROGRAMMING FOR PROBLEM SOLVING Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 4 Evaluation Pattern CIE Marks = 40 (30 marks from test, 10 marks for Assignment) SEE Marks = 60 ( SEE exam will conducted for 100 marks and reduced to 60)
  • 5. MODULE-1 Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 5 Syllabus Introduction to computer hardware and Software: Computer generations, computer types, bits, bytes, and words, CPU, primary, secondary memory, ports and connections , input & output devices, computers in networks, network hardware, software basics and software types. Overview of C: Basic structure of C program, executing C program. Constant, variable and datatypes, operators and expressions. (RBT Levels: L1 & L2)
  • 6. MODULE-1 : Introduction to computer hardware and Software Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 6 INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE: Computer generations : First Generation computers Time Period : 1951 to 1959 Technology : Vacuum Tubes Size : Very Large System Processing : Very Slow Characterized By:-  Magnetic Drums  Magnetic Tapes  Difficult to program  Used machine language & assembly language
  • 7. MODULE-1 : Introduction to computer hardware and Software Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 7 INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE: Computer generations : Second Generation computers Time Period : 1959 to 1963 Technology : Transistors Size : Smaller Processing : Faster Characterized By:-  Magnetic Cores  Magnetic Disk  Used high level language  Easier to program
  • 8. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 8 INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE: Computer generations : Third Generation computers Time Period : 1963 to 1975 Technology : ICs (Integrated Circuits) Incorporated many transistors & electronic circuits on a single chip Size : Smaller as compared to 2nd generation computers Processing : Faster than 2nd generation computers Characterized By:- Minicomputers accessible by multiple users from remote terminals. MODULE-1 : Introduction to computer hardware and Software
  • 9. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 9 INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE: Computer generations : Fourth Generation computers Time Period : 1975 till now Technology : VLSI (Very Large Scale Integration) Incorporated many millions of transistors & electronic circuits on a single chip Size : Small as compared to first generation computer Processing : Faster than third generation computer Characterized By:-  The personal computer and user friendly micro- programs, very fast processor chip high level language, OOP (Object Oriented Programming) MODULE-1 : Introduction to computer hardware and Software
  • 10. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 10 INTRODUCTION TO COMPUTER HARDWARE AND SOFTWARE: Computer generations : Fifth Generation computers Time Period : present and Future Technology Technology : Artificial Intelligence Size : Micro and Nano size Processing : Faster than Fourth generation computer Characterized By:-  Artificial Intelligence MODULE-1 : Introduction to computer hardware and Software
  • 11. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 11 COMPUTER AND COMPUTER TYPES Computer : Computer is an electronic device for storing and processing data, typically in binary form, according to instructions given to it in a variable program. Classification based on working technology :  Analog computers  Digital computers  Hybrid computers Classification based on size, usage and speed :  Super Computers  Mainframe computers  Mini Computers  Micro computers  Small & Embedded computers MODULE-1 : Introduction to computer hardware and Software
  • 12. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 12 COMPUTER MEMORY SYSTEM Computer : Computer is an electronic device for storing and processing data, typically in binary form, according to instructions given to it in a variable program. BITS Computer memory stores everything in terms of bits, zero’s and ones’s. (1/0). BYTES Group of 8 bits are called as 1 byte. Similarly group of 1028 Bytes are called 1KB and so on. PRIMARY & SECONDARY MEMORY Physical memory in CPU is differentiated as primary and secondary memory. MODULE-1 : Introduction to computer hardware and Software
  • 13. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 13 DIFFERENCES BETWEEN PRIMARY AND SECONDARY MEMORY SR.NO. PRIMARY MEMORY SECONDARY MEMORY 1. Primary memory is temporary. Secondary memory is permanent. 2. Primary memory is directly accessible by Processor/CPU. Secondary memory is not directly accessible by the CPU. 3. Nature of Parts of Primary memory varies, RAM- volatile in nature. ROM- Non-volatile. It’s always Non-volatile in nature. 4. Primary memory devices are more expensive than secondary storage devices. Secondary memory devices are less expensive when compared to primary memory devices. 5. The memory devices used for primary memory are semiconductor memories. The secondary memory devices are magnetic and optical memories. 6. Primary memory is also known as Main memory or Internal memory. Secondary memory is also known as External memory or Auxiliary memory. 7. Examples: RAM, ROM, Cache memory, PROM, EPROM, Registers, etc. Examples: Hard Disk, Floppy Disk, Magnetic Tapes, etc. MODULE-1 : Introduction to computer hardware and Software
  • 14. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 14 CENTRAL PROCESSING UNIT(CPU) MODULE-1 : Introduction to computer hardware and Software A central processing unit (CPU) is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logical, control and input/output (I/O) operations specified by the instructions.
  • 15. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 15 PORTS & CONNECTIONS MODULE-1 : Introduction to computer hardware and Software A port is a physical docking point using which an external device can be connected to the computer. 1. Serial Port – to connect mouse 2. Parallel Port – Scanner and Printers 3. PS/2 Port - to connect old computer keyboard and mouse 4. Universal Serial Bus (or USB) Port - It can connect all kinds of external USB devices 5. VGA Port - Connects monitor to a computer's video card 6. Power Connector - Connects to the computer's power cable 7. Firewire Port - Transfers large amount of data at very fast speed. 8. Modem Port - Connects a PC's modem to the telephone network. 9. Ethernet Port - Connects to a network and high speed Internet. 10. Game Port - Connect a joystick to a PC 11. Digital Video Interface, DVI port - Connects Flat panel LCD monitor to the computer's high-end video graphic cards. 12. Sockets - connect the microphone and speakers to the sound card of the computer.
  • 16. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 16 COMPUTERS IN NETWORK MODULE-1 : Introduction to computer hardware and Software Types of Network 1. Personal Area Network (PAN) 2. Local Area Network (LAN) 3. Wireless Local Area Network (WLAN) 4. Campus Area Network (CAN) 5. Metropolitan Area Network (MAN) 6. Wide Area Network (WAN) Storage 7. System-Area Network (also known as SAN) 8. Passive Optical Local Area Network (POLAN) 9. Enterprise Private Network (EPN) 10. Virtual Private Network (VPN)
  • 17. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 17 COMPUTERS IN NETWORK MODULE-1 : Introduction to computer hardware and Software Networking Hardware 1. Network Cables - Network cables are the transmission media to transfer data from one device to another. 2. Routers - is a connecting device that transfers data packets between different computer networks. 3. Repeaters, Hubs, and Switches - Connects network devices together so that they can function as a single segment. 4. Bridges - Connects two separate Ethernet network segments. It forwards packets from the source network to the destined network. 5. Gateways - Connects entirely different networks that work upon different protocols. It is the entry and the exit point of a network and controls access to other networks. 6. Network Interface Cards - NIC is a component of the computer to connect it to a network. Network cards are of two types: Internal network cards and external network cards.
  • 18. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 18 COMPUTERS IN NETWORK MODULE-1 : Introduction to computer hardware and Software Software’s and types : Software is a collection of data, programs, procedures, instructions, and documentation that perform various predefined tasks on a computer system. They enable users to interact with the computer Types 1. System Software System software aids the user and the hardware to function and interact with each other. Basically, it is software to manage computer hardware behavior so as to provide basic functionalities that are required by the user. a. Operating Systems b. Device Drivers c. Firmware d. Programming Language Translators e. Utility 1. Application Software Application software also known as end-user programs or productivity programs are software that helps the user in completing tasks such as doing online research, jotting down notes, setting an alarm, designing graphics, keeping an account log, doing calculations or even playing games. a. Word processors b. Database software c. Multimedia software d. Education and Reference Software e. Graphics Software f. Web Browsers
  • 19. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 19 MODULE-1 : OVERVIEW OF ‘C’ Problem Solving in C
  • 20. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 20 Basic Concepts of C Program. Example : /* This is Documentation Section */ Program to Print Hello World on the terminal */ #include <stdio.h> void main() { /* This is how comments are implemented in C to comment out a block of text */ // or like this for a single line comment printf( "Hello Worldn" ) ; } MODULE-1 : OVERVIEW OF ‘C’
  • 21. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 21 Steps in Executing a C Program Executing a C program involves following steps : 1. Creating a C Program 2. Compiling the C Program 3. Linking the program Executing the C program. MODULE-1 : OVERVIEW OF ‘C’
  • 22. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 22 Properties of C Programming Language. C language became popular because of the following reasons. • C is a robust language, which consists of number of built-in functions and operators can be used to write any complex program • Programs written in c are executed fast compared to other languages. • C language is highly portable • C language is well suited for structured programming. • C is a simple language and easy to learn. MODULE-1 : OVERVIEW OF ‘C’
  • 23. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 23 ‘C’ - TOKENS MODULE-1 : OVERVIEW OF ‘C’
  • 24. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 24 ‘C’ - TOKENS MODULE-1 : OVERVIEW OF ‘C’ KEYWORDS • Keywords are tokens which are used for their intended purpose only. • Each keyword has fixed meaning and that cannot be changed by user. Hence, they are also called reserved- words. IDENTIFIER • As the name indicates, a identifier is used to identify various entities of program such as variables, constants, functions etc. • In other words, an identifier is a word consisting of sequence of → Letters → Digits or → "_"(underscore) • For ex: area, length, breadth
  • 25. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 25 ‘C’ - TOKENS MODULE-1 : OVERVIEW OF ‘C’ CONSTANTS A constant is an identifier whose value remains fixed throughout the execution of the program. The constants cannot be modified in the program. For example: 1, 3.14512 , “z‟, “girishmantha" Different types of constants are: 1) Integer Constant 2) Floating Point Constant 3) Character Constant 4) String Constant 5) Escape Sequence Characters
  • 26. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 26 ‘C’ - DATATYPES MODULE-1 : OVERVIEW OF ‘C’ The data type defines the type of data stored in a memory-location. 1) int 2) float 3) double 4) char 5) void Data type Bytes Range of data type char 1 bytes -128 to 127 int 2 bytes -32, 768 to 32,767 float 4 bytes 3.4E-38 to 3.4E38 double 8 bytes 1.7E-308 to 1.7E308
  • 27. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 27 ‘C’ - VARIABLES MODULE-1 : OVERVIEW OF ‘C’ A variable is an identifier whose value can be changed during execution of the program. In other words, a variable is a name given to a memory-location where the data can be stored. • Using the variable-name, the data can be → stored in a memory-location and → accessed or manipulated Rules for defining a variable 1) The first character in the variable should be a letter or an underscore 2) The first character can be followed by letters or digits or underscore 3) No extra symbols are allowed (other than letters, digits and underscore) 4) Length of a variable can be up to a maximum of 31 characters 5) Keywords should not be used as variable-names Valid variables: Ex : a, principle_amount, sum_of_digits
  • 28. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 28 ‘C’ - VARIABLES MODULE-1 : OVERVIEW OF ‘C’ Declaring Variables Syntax :- datatype var-name; Ex : int age; //stores integer value in variable age Char section; //variable section stores only one char Double salary; // Variable salary stores double value with decimal number
  • 29. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 29 ‘C’ - VARIABLES MODULE-1 : OVERVIEW OF ‘C’ Initializing Variables Syntax :- datatype var-name = constant ; For Example :- char ch = 'a' ; double d = 12.2323 ; int i, j = 20 ; /* note in this case i is not initialized */ Assigning values to variables Ex : int x,y,z; x = 20 ; x = y = z = 100 ;
  • 30. Girish Mantha ISE Dept JNNCE, Shimoga 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 30 Type Conversions MODULE-1 : OVERVIEW OF ‘C’ • Unary Operator • Increment and Decrement Operators • Binary Operator • Arithmetic Operators • Assignment Operator • Assignment Operator • Relational Operators • Logical Operators • Bitwise Operators • Ternary Operator • Conditional Operator
  • 31. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 31 Increment and Decrement Operators MODULE-1 : OVERVIEW OF ‘C’ INCREMENT OPERATOR • ++ is an increment operator. • As the name indicates, increment means increase, i.e. this operator is used to increase the value of a variable by 1. • For example: If b=5 then b++ or ++b; // b becomes 6 • The increment operator is classified into 2 categories: 1) Post increment Ex: b++ 2) Pre increment Ex: ++b #include<stdio.h> void main() { int x=10,y = 10, z ; z= x++; printf(“ z=%d x= %dn”, z, x); z = ++y; printf(“ z=%d y= %d”, z, y); } Output: z=10 x=11 z=11 y=11
  • 32. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 32 Increment and Decrement Operators MODULE-1 : OVERVIEW OF ‘C’ DECREMENT OPERATOR • -- is a decrement operator. • As the name indicates, decrement means decrease, i.e. this operator is used to decrease the value of a variable by 1. • For example: If b=5 then b-- or --b; // b becomes 4 • Similar to increment operator, the decrement operator is classified into 2 categories: 1) Post decrement Ex: b-- 2) Pre decrement Ex: --b void main() { int x=10,y = 10, z ; z= x--; printf(“ z=%d x= %dn”, z, x); z = --y; printf(“ z=%d y= %d”, z, y); } Output: z=10 x=9 z=9 y=9
  • 33. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 33 Logical Operators MODULE-1 : OVERVIEW OF ‘C’ Operator Meaning Example && Logical AND If c=5 and d=2 then ((c==5) && (d>5)) returns false. || Logical OR If c=5 and d=2 then ((c==5) || (d>5)) returns true. ! Logical NOT If c=5 then !(c==5) returns false. #include<stdio.h> void main(){ printf(“7 && 0 : %d n”, 7 && 0 ); printf(“7 || 0 : %d n”, 7 || 0 ); printf(“ !0 : %d”, !0 ); } Output: 7 && 0 : 1 7 || 0 : 1 !0 : 1
  • 34. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 34 CONDITIONAL OPERATOR (Ternary Operator) MODULE-1 : OVERVIEW OF ‘C’ • The conditional operator is also called ternary operator it takes three operands. • Conditional operators are used for decision making in C. • The syntax is shown below: (exp1)? exp2: exp3; where exp1 is an expression evaluated to true or false; If exp1 is evaluated to true, exp2 is executed; If exp1 is evaluated to false, exp3 is executed. #include<stdio.h> void main() { int a,b, max ; printf(“ enter 2 distinct numbers n”); scanf(“%d %d”, &a, &b); max=(a>b)? a : b; printf(“ largest number =%d ”, max); } Output: enter 2 distinct numbers 3 4 largest number = 4
  • 35. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 35 BITWISE OPERATORS(Binary Operator) MODULE-1 : OVERVIEW OF ‘C’ • These operators are used to perform logical operation (and, or, not) on individual bits of a binary number. • There are 6 bitwise operators: Operators Meaning of operators & Bitwise AND | Bitwise OR ^ Bitwise exclusive OR ~ Bitwise complement << Shift left >> Shift right
  • 36. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 36 TYPE CONVERSION MODULE-1 : OVERVIEW OF ‘C’ • Type conversion is used to convert data of one type to data of another type. • Type conversion is of 2 types as shown in below figure:
  • 37. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 37 IMPLICIT TYPE CONVERSION MODULE-1 : OVERVIEW OF ‘C’ • If a compiler converts one type of data into another type of data automatically, it is known as implicit conversions. • There is no data loss in implicit conversion. • The conversion always takes place from lower rank to higher rank. For ex, int to float as shown in the above datatype hierarchy. • For ex: int a = 22, b=11; float c = a; //c becomes 21.000000 float d=b/c=11/22.000000=11.000000/22.000000=0.500000 • Example: Program to illustrate implicit conversion. #include<stdio.h> void main() { int a = 22, b=11; float d ; d=b/c; printf("d Value is : %f ", d ); } Output: d Value is : 0.500000
  • 38. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 38 EXPLICIT TYPE CONVERSION MODULE-1 : OVERVIEW OF ‘C’ • When the data of one type is converted explicitly to another type with the help of some pre-define functions, it is called as explicit conversion. • There may be data loss in this process because the conversion is forceful. • The syntax is shown below: data_type1 v1; data_type2 v2= (data_type2) v1; where v1 can be expression or variable • For ex: float b=11.000000; int c = 22; float d=b/(float)c=11.000000/22.000000=0.500000 • Example: Program to illustrate explicit conversion. #include<stdio.h> void main() { float b=11.000000; int c = 22; float d; d=b/(float)c; printf("d Value is : %f ", d ); } Output: d Value is : 0.500000
  • 39. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 39 THE PRECEDENCE OF OPERATORS MODULE-1 : OVERVIEW OF ‘C’ • The order in which different operators are used to evaluate an expression is called precedence of operators. #include<stdio.h> void main() { int a = 20; int b = 10; int c = 15; int d = 5; int e; e = (a + b) * c / d; // ( 30 * 15 ) / 5 printf("Value of (a + b) * c / d is : %d n", e ); e = ((a + b) * c) / d; // (30 * 15 ) / 5 printf("Value of ((a + b) * c) / d is : %d n" , e ); e = (a + b) * (c / d); // (30) * (15/5) printf("Value of (a + b) * (c / d) is : %d n", e ); e = a + (b * c) / d; // 20 + (150/5) printf("Value of a + (b * c) / d is : %d " , e ); } Output: Value of (a + b) * c / d is : 90 Value of ((a + b) * c) / d is : 90 Value of (a + b) * (c / d) is : 90 Value of a + (b * c) / d is : 50
  • 40. 4/15/2021 C PROGRAMMING FOR PROBLEM SOLVING(CPPS)- 18CPS13 40 MODULE-1 END MODULE-1