Module 1 - C Program
Module 1 - C Program
Module 1 - C Program
MODULE-01
1
M O D U L E -1
SYLLABUS
(1) I N D R O D U C T I O N TO C O P U T E R H A R D WA R E A N D
S O F T WA R E
1. C O M P U T E R G E N E R AT I O N
2. COMPUTER TYPES
3. BITS
4. BY T E S & WO RS
5. CPU
6. P R IMA RY M E M O RY
7. S E C O N DA RY M E M E O RY
8. P O RT S & C O N N E C T I O N S
9. I/P D E V I C E S
10. O/P D E V I C E S
11. C O M P U T E R I N A N E T WO R K
12. N E T WO R K H A R DWA R E
13. S/W B AS I C S 8
14. S/W T Y P E S .
(2) OV E RV I E W O F C :-
1. B AS I C S T R U C T U R E O F C - P RO G R A M
2. E X E C U T I N G A C - P RO G R A M
3. C O N S TA N T VA R I A B L E A N D DATA T Y P E S
4. O P E R ATO RS A N D E X P R E S S I O N.
1) C O M P U T E R G E N E R AT I O N
1940 – 1956: First Generation – Vacuum Tubes.
Supercomputers.
S ervers.
Workstations.
Information appliances.
Embedded computers.
3) BITS
a "bit" is atomic: the smallest unit of storage.
A bit stores just a 0 or 1. "In the computer it's
all 0's and 1's“.
https://www.youtube.com/watch?v=Xpk67YzOn5
w 15
4) BYTES AND WORDS
5)C PU
6) P R I M A RY M E M O RY
7 ) S ECO N DARY M E M O RY
8) P O RT S A N D C O N N E C T I O N S
Computer Ports
1)Serial and Parallel port(VGA,DVI,DISPLAY ports)
2) RCA/VEDIO C O N N E C T O R P O RT S
3) H D M I port 4) U S B
2. DV I Cable
3. H D M I Cable
4. Ethernet Cable
(9)A ND (10) I N P U T AND OUTPUT DEVICES
P R I N T E RS
(11)COMPUTERS I N A N E T WO R K
•Interconnection of computer is called a
computer network.
•Different ways of connecting computers in
•Network Interface C a rd
• H u b and Switch
Software is a collection of instructions and data that tell the computer how to
work. This is in contrast to physical hardware, from which the system is built
and actually performs the work.
E X A M P L E : LAPTOP/PC/SIMPLE C O M P U T E R .
14) S O F T WA R E T Y P E S
The 4 major types of computer software are:
1. Application Software
2. System Software
3. Programming Software
4. Driver Software
1)Application Software
M S Excel: It is spreadsheet software that you can use for presenting and
analyzing data.
Photoshop: It is a photo editing application software by Adobe. You can
use it to visually enhance, catalogue and share your pictures.
Skype: It is an online communication app that you can use for video chat,
voice calling and instant messaging.
Z O O M APP, T E A M S A PP, G O O G L E M E ET. . . E . T. C
2) System Software
For desktop computers, laptops and tablets:
Microsoft Windows
Mac (for Apple devices)
Linux
For smartphones:
Apple’s iOS
Google’s Android
Windows Phone O S
3) Programming Software
Eclipse – a Java language editor
5) Freeware(APPS)
Google Chrome
Google Meet
Skype
Instagram
Snapchat
teams/zoom apps
Adobe reader
37
6)Shareware
Adobe PhotoShop
Adobe Illustrator
Netflix App
Matlab
McAfee Antivirus
PHP
LINUX/UNIX
38
8) Closed Source Software
.NET
J ava
Android
Microsoft Office
Adobe PhotoShop
9) Utility Software
Antivirus and security software
File compressor
Disk cleaner
ALGORITHM
F L O WC H A RT
h-sdev-dev-1/chapter/flowchart-symbols-
8-3-
43
13/#:~:text=The%20two%20most%20co
%20a%20diamond.
m
mon%20types,usually%20denoted%20as
(2)OVERVIEW O F C
{
printf("Hello World!");
return 0;
}
Output
Hello, World!
2./*Progame to A D D two Numbers*/
#include<stdio.h > // stdio.h means standard input and output
void main() / /M A IN F U N C T IO N S E C T IO N
{
int a, b, sum;--------------------------------------DECLARATION PART
printf("Enter two no: ");
scanf("%d %d", &a, &b);
sum = a + b; -----------EXECUTABLE PART
printf("Sum : %d", sum);
return(0);
}
Output :
1
2
Enter two no: 5 6 48
Sum : 11
3./*Progame to Find A R E A and P E R I M E T E R of a
CIRCLE*/
Algorithm
S T E P 1: Take radius as input from the user
S T E P 2: Calculate the area and Perimeter of circle
using,
area = (3.14)*r*r
Perimeter= = 2*3.14*radius
S T E P 3: Print the area and
perimeter of the Circle to
the screen
P RO G R A M
https://www.programiz.com/c-
programming/online-compiler/
2.Execting a C-program:
1. Creating the program
2. Compiling the program
3. Linking the program with the functions that are needed from the C-
library
4. Executing the program.
1 .CREATING T H E P RO G R A M
S AV E and
QUIT
(Ctrl+S)
Mkdir Foldername Cd Foldername gedit Filename.c
(Ctrl+Q)
(2)&(3)COMPILI N G T H E P RO G R A M and L I N K I N G T H E P RO G R A M
WITH T H E F U N C T I O N S THAT A R E N E E D E D F RO M T H E C L I B R ARY
cc filename.c (ex: cc school.c)
Constant (Literals):
A constant is a fixed value that cannot be changed after
defining. Ex :-pie value, a=10, sin45,tan 90,....etc
They are also called literals.
EX: 1)radius, perimeter and Area are variable in c-program to find area
and perimeter of a circle
2) length, width, area, perimeter are variable in c-program to find area
and perimeter of a Rectangle.
•The width and length are variables that can store integers.
• They are assigned the values 10 and 20.
• The values of these variables are used to calculate the area and
perimeter.
• Finally, the results are printed to the console.
DATAT Y P E S :
Variables in C are associated with data type. Each data type requires
an amount of memory and performs specific operations.
There are some common data types in C −
int − Used to store an integer value.
char − Used to store a single character.
float − Used to store decimal numbers with single precision.
double − Used to store decimal numbers with double precision .
#include <stdio.h>
int main()
{
// datatypes
int a = 10;
char b = 'S';
float c = 2.88;
double d =
28.888;
printf("Integer datatype : %d\n",a);
printf("Character datatype : %c\n",b);
printf("Float datatype : %f \n",c);
printf("Double Float datatype : %lf \
n",d);
return 0;
}
OUTPUT
Integer datatype : 10
Character datatype : S
Float datatype : 2.880000
Double Float datatype : 28.888000
4.Operators and Expression.
Operators:
D E F I N I T I O N : - An operator is a symbol that tells the compiler to perform a certain
mathematical or logical manipulation .
5/5=1(
5%5=0
Relational operators
Logical operators
Bitwise operators
00001<<2 = 00101
0010>>1 = 0001
Assignment Operators
Assignment operators supported by C language are as follows.
Conditional operator
The conditional operators in C language are known by two more names
1) Ternary Operator
2) ? : Operator
.
Constant expressions: Constant Expressions consists of only constant
values. A constant value is one that doesn’t change.
E x amples: 5, 10 + 5 / 6.0, 'x’
2-TYPES:-
92
93
94
95