❖ Dig comp is an electronic programmable machine that can process all kinds of
data using some set of instructions called programs
❖ BLOCK DIAGRAM OF A COMP
Has 4 main components: input & output devices, memory and CPU
➢ INPUT UNIT
▪ Used to input data to comp via input devices like keyboard, scanner,
microphone etc.
▪ It accepts data & instructions from the outside world
▪ Converts it to binary form which a comp can understand
▪ Sends the converted data to comp system for further processing
➢ OUTPUT UNIT
▪ The computed result is then displayed to the outside world via output
devices like monitor, printer, speaker etc.
➢ STORAGE UNIT
▪ It stores the input data for processing & displaying the output and it also
saves the data for later use
▪ Classified into 2 types: primary and secondary memory
▪ Primary memory: faster, less storage(MB), expensive ; volatile in nature
ie data is lost once the comp is switched off & in order to store, it must
be transferred to sec mem ; consists of RAM & ROM ; RAM-consists of
all temp data used by CPU, CPU can process only the data present in the
RAM ; ROM- very small memory used for booting process
, ▪ Secondary memory: slower, huge storage(GB), cheap ; permanent in
nature and doesn’t get lost after switching off the comp ; eg-hard disk,
CD etc.
➢ CPU
▪ CU+ALU
▪ Brain of the comp
▪ Performs all cal
▪ Takes all decisions
▪ Controls all units of comp
➢ MEMORY SIZE
▪ Dig comp use binary system ie 0 & 1
▪ Each char/no is rep by 8-bit code = byte
▪ Size of primary memory usually in KB & MB
▪ 1 KB = 1024 bytes & 1 MB = 1024 KB
❖ Bcoz of comp extreme speed, it can carry out cals within mins which req
months or years if carried out by hands ie time req to do simple cal like
addition is usually rep in terms of microseconds ; this very high speed is
accompanied by equally high level of reliability ie comp can never make
mistakes on their own and error occurs only due to wrong instructions/data
❖ C lang
➢ General purpose programming lang
➢ Very popular and powerful despite being old
➢ Fast compared to java & python
➢ Very versatile & small size
➢ C++ is extension of c ; diff – it supports classes and objects
➢ Extensive use of fun calls & pointers
➢ Structured & case sensitive lang
❖ Comp hardware: refers to physical components ; any part of comp that we can
touch ; primary electronic devices used to build up the comp ; eg-monitor,
mouse, keyboard, printer, scanner, CPU etc.
❖ Comp software: collection of instructions , procedures, programs that perform
diff tasks on comp system ie programming code executed on processor ; can
, be machine level code / code written for OS ; eg-MS word, excel, ppt, google
chrome, photoshop etc.
❖ OS: software helps user to operate comp efficiently; acts as interface bet comp
& user since it understands only binary lang; eg-DOS (disk), windows OS,
unix/linux OS
❖ Compiler: software that translates programs written in high level lang(source
program) to machine lang(object program) ; eg-C-compiler, java-compiler etc.
CH4: DATA INPUT AND OUTPUT
❖ getchar, putchar, scanf, printf, gets and puts functions permit the transfer of
info bet comp & std i/o devices
❖ Header file req for std i/o lib fun = <stdio.h>
❖ getchar() function
➢ input fun used for entering single char usually from keyboard
➢ does not req arg but parentheses() r must
➢ char var = getchar();
➢ return type is char
❖ putchar() function
➢ output fun used for displaying single char usually on monitor
➢ arg must be specified within ()
➢ putchar(char var);
➢ return type is int (ASCII value)
eg for both:
#include<stdio.h>
int main()
{
char c;
printf("enter a character: ");
c=getchar();
, printf("you entered: ");
putchar(c);
return 0;
}
❖ scanf() function
➢ input fun used for entering any comb of numerical values, single chars &
strings in memory address using ampersand&
➢ data type must be provided using format specifiers ie %d%f%c etc.
➢ scanf(“format specifiers”, &arg1, &arg2…);
➢ the format specifiers must respectively match its arg & array name cannot
begin with &
➢ max field width can be used with the format specifier ie %3d %.4f etc.
however char exceeding the field width will be considered for the next data
item
➢ whitespace is also considered as newline char
➢ assignment suppression ie %*d used for skipping the data item
➢ unrecognized char r skipped
❖ printf() function
➢ output fun used for displaying any comb of numerical values, single chars &
strings
➢ can be simply used to print any message on the screen
➢ printf(“format specifiers”, arg1, arg2…);
➢ & not used since printf() has nothing to do with memory addresses
➢ Min field width can be used with the format specifier ie %3d %.4f etc.
however char less than it will be filled with blank spaces
➢ Unrecognized char r printed just like that
eg for both:
#include<stdio.h>
int main()