Pop 3
Pop 3
The output device helps the computer to produce or display the information to the users.
Input devices
External devices that are connected tom CPU using which data or commands can be entered into
computer.
keyboard
pointing devices
scanners
keyboard:
the primary input device used in all computers.It has group of switches associated with a character.
User can type data or the commands by using keyboard.Keyboard has around 101 keys.
Keyboard layout is called querty.
Pointing devices
It’s an input devices using which we can control the movement of pointer on nthe screen.
We can communicate with the computer by pointing any desired location, we can select the items on the
screen.
Mouse
Scanner
The device which ues light as source of input for detecting or recognizing variolus things.
It can read characters,marks codes,etc.
Eg:
barcode reader
optical recognition
magnetic ink character
Output Devices
Output Devices are the devices that show us the result after giving the input to a computer system. Output
can be of many different forms like image, graphic audio, video, etc. Some of the output devices are
described below.
Monitor
Monitors, also known as Visual Display Units (VDUs), are a computer’s primary output device. It creates
images by arranging small dots, known as pixels, in a rectangular pattern. The amount of pixels
determines the image’s sharpness.
The two kinds of viewing screens used for monitors are described below.
Cathode-Ray Tube (CRT) Monitor: Pixels are minuscule visual elements that make up a CRT
display. The higher the image quality or resolution, the smaller the pixels.
Flat-Panel Display Monitor: In comparison to the CRT, a flat-panel display is a type of video
display with less volume, weight, and power consumption. They can be hung on the wall or worn
on the wrist.
Flat-panel displays are currently used in calculators, video games, monitors, laptop computers, and
graphical displays.
Printers
output devices that allow you to print information on paper. There are certain types of printers which are
described below.
Impact Printers
Character Printers
Line Printers
Non-Impact Printers
Laser Printers
Inkjet Printers
Plotters
A plotter is large format inkjet printer to produce high quality color graphics using electronic charges.
A plotter is a printer that interprets commands from a computer to make line drawings on paper with one
or more automated pens. Unlike a regular printer, the plotter can draw continuous point-to-point lines
directly from vector graphics files or commands.
It is also used to print banners.
Size will be very large.
Digitizer
It's an input device which converts analog information into a digital form. Digitizer can convert a signal
from the television camera into a series of numbers that could be stored in a computer. They can be used
by the computer to create a picture of whatever the camera had been pointed at.
Digitizer is also known as Tablet or Graphics Tablet because it converts graphics and pictorial data into
binary inputs. A graphic tablet as digitizer is used for doing fine works of drawing and images
manipulation applications.
ans:1.250000
printf(“%0.3f\n”, 20/3.0); 1 M
ans:6.667
Write equivalent expressions in C: 2 M
(-b+sqrt((b*b)-((4*a*c)))/(2*a)
3.Draw the flowchart and write algorithm and write Program to compute simple and
compound interest.
#include<stdio.h>
void main()
{
int p,r,t;
float i;
printf("Enter the Principal, Rate and Time\n");
scanf("%d %d %d",&p,&r,&t);
i=p*r*t/100;
CI = p*pow((1+r/100),t);
printf("Compound interest is : %f\n", CI);
return 0;
}
output
Algorithm
start.
Declaration of variable with their data type, like :- int p, r, t,CI; float I;
Input the value in variable
perform SI=(p*r*t)/100;
CI = p*pow((1+r/100),t);
printf( ) called to print value of CI
Stop
4.Explain structure of a C program with example program.
1 ) Comment line
2) Preprocessor directive
3 ) Global variable declaration
4) main function( )
{ Local variables;
Statements;
}
User defined function
}
}
1) Preprocessor directive & header file // #include<stdio.h>
2) Global variable declaration // variable that is used throughout the program, for all the
modules/blocks of the program.
3) main function
// two ways main function can be written .
void main()/ main()/int main()
{
Local variable declaration
Statements input , processing, output
Return statement
}
4) User defined function // user only defines the steps of the function and also defines the name
of the function
5) Comment lines // to explain the meaning of the statement... syntax: //comment or
/*comment*/
main(): It is the user defined function and every function has one main()
function from where actually program is started and it is encloses within the pair
of curly braces. The main( ) function can be anywhere in the program , but in
general practice it is placed in the first position.
Syntax :
main()
{ ........ ........ ........
} int main( )
{ return 0;
}
The main( ) function return
value when it declared by data
type as:
The main function does not return any value when void (means null/empty) is
used as return type.
{
printf (“C language”);
Output: C language
5.Write syntax for nested –if statement? Draw the flowchart and write a C
program to find largest of three numbers using nested if statements?
Syntax
if (condition1)
{
// Executes when condition1 is true
if (condition2)
{
// Executes when condition2 is true
}
else
{
// Executes when condition2 is false
}
program
#include <stdio.h>
int main() {
// outer if statement
if (n1 >= n2) {
// inner if...else
if (n1 >= n3)
printf("%.2lf is the largest number.", n1);
else
printf("%.2lf is the largest number.", n3);
}
// inner if...else
if (n2 >= n3)
printf("%.2lf is the largest number.", n2);
else
printf("%.2lf is the largest number.", n3);
}
return 0;
}
output
Enter three numbers: -4.5
3.9
5.6
5.60 is the largest number.
5.KSRTC Transport Company charges for the parcels from Kolar to Bangalore or
vice-versa as per the given tariff:
Weight charges
Upto 10kg Rs.20 per kg
For next 20 kg Rs.10 per kg
For next 20 kg Rs.8 per kg
More than 50 kg Rs.5 per kg
Write a program to calculate the charge for a parcel taking the weight of parcel as input.
#include<stdio.h>
#include<conio.h>
void main()
{
int w;
float c=0;
printf("Enter the weight of parcel");
scanf("%d",&w);
if(w<=10)
c=w*20;
if((w>10)&&(w<=30))
c=200+(w-10)*10;
if((w>30)&&(w<=50))
c=200+200+(w-30)*8;
if(w>50)
c=200+200+160+(w-50)*5;
output
--------
100
Celsius: 37.777779
a) Bitwise Operators.
b) Ternary Operator.
Bitwise Operators
A=60
A= A>>1
A=2+4+8+16=30
A=60
A=8+16+32+64=120
return0;
}
Output
a = 5, b = 9
a & b = 1
a | b = 13
a ^ b = 12
~a = -6
b << 1 = 18
b >> 1 = 4
#include <stdio.h>
int main() {
int age;
return 0;
}
In the above example, we have used a ternary operator that checks whether a user can vote or not based on
the input value. Here,
age >= 18 - test condition that checks if input value is greater or equal to 18
printf("You can vote") - expression1 that is executed if condition is true
printf("You cannot vote") - expression2 that is executed if condition is false
Here, the user inputs 12, so the condition becomes false. Hence, we get You cannot vote as output.
8. Explain syntax with examples of printf() and scanf() statements. How string
with blanks can be accepted by gets() and scanf() statements? Write syntax
with examples.
These are called as formatted Input and output functions because they have special format to
read and write The text from streams and then converting them into binary stream.
Syntax of scanf() : scanf ( “ Control string” , & var1, & var2, ........,& var n).
Format specifiers : For integer variables------ %d
For float variables--------%f
For character variables ------- %c
Input Statements ( reading input)
scanf()
// built-in/standard /formattedinputfunction to read input
syntax: scanf(“format specifier”
//formatspecifier:int-%d,float-%f,char-%c
//& - address operator
i) To display a message
i) To display a message
i) To display a message
scanf() reads input until it encounters whitespace, newline or End Of File(EOF) whereas gets() reads input
until it encounters newline or End Of File(EOF),
gets() does not stop reading input when it encounters whitespace instead it takes whitespace as a string.
Eg:1
#include <stdio.h>
int main()
{
char str[20];
gets(str);
printf("%s", str);
return 0;
}
output
CMRIT UNIVERSITY
CMRIT UNIVERSITY
eg:2
#include <stdio.h>
int main()
{
char str[20];
scanf("%[^\n]%*c", str);
printf("%s", str);
return 0;
}
output
section sem
section sem