TTS_Module5-CC102
TTS_Module5-CC102
MODULE
College
INFORMATION SHEET PR-5.1.1
“Input and Output Statements”
Input Statement – a statement used to input a single character or a sequence of characters from the
keyboard
1. getch – a function used to input a single character from the keyboard without echoing the
character on the monitor.
Syntax: getch()
Ex: ch=getch();
2. getch – a function used to input a single character from the keyboard, the character pressed
echoed on the monitor, like READLN in PASCAL
Syntax: getche();
Example: ch = getche();
3. getchar – a function used to input a single character from the keyboard, the character
pressed echoed on the monitor, terminated by pressing ENTER key.
Syntax: getchar();
Example: ch = getchar();
4. gets – a function used to input sequence of character from the keyboard, space are
accepted, terminated by pressing enter key
Syntax: gets();
Example: gets(ch);
5. scanf – a function used to input single characters from the keyboard, it needs the control
string codes in able to recognized. Space are not accepted upon inputting. Terminated by
pressing spacebar
Syntax: scanf(“control string codes”, identifier).
Example: scanf(“%d”, &num);
Output Statement – a statement used to display the argument list or string on the monitor
1. printf – a function used to display the argument list on the monitor. It sometimes needs the
control string codes to help display the remaining argument on the screen.
Syntax: printf(“control string codes”, argument list);
Example: printf(“Hello %s, you are %d years old”, name, age);
2. putchar – a function used to display the argument list or string on the monitor. It is like
overwriting a character.
Syntax: putchar();
Example: putchar(tolower(ch));
3. puts – a function used to display the argument list or string on the monitor. It does not need
the help of the control string codes
Syntax: puts()
Example: puts(“hello”);
Format Strings and Escape Sequences
All format specifiers start with a percent sign (%) and are followed by a single letter indicating
the type of data and how data are to be formatted.
1. Make a program that will display the word “Hello”, “I’m fine”, and “Thank You” in a different
lines and column.
#include <stdio.h>
#define g gotoxy Output:
main() Hello
{ I’m Fine
clrscr(); Thank You
printf(“Hello”);g(5,2);
printf(“I\’m Fine”);g(10, 3);
printf(“Thank You”);
getch();
}
2. Create a program that accepts and displays a person’s name and age.
#include <stdio.h>
#define p printf Output:
main() Enter Name: Paul
{ Enter Age: 3
int age;char name[10]; Hello Paul, you are 3 years old
clrscr();
p(“\n Enter name:”);
scanf(“%s”, &name);
p(“\n Enter Age:”);
scanf(“%d”, &age);
p(“\n Hello %s, you are %d years old”, name, age);
getch();
}
3. Make a program that will compute and display the sum and product of two numbers.
#include <stdio.h>
Output:
First number: 5
Second number: 6
Reference:
Workbook in C Programming Computer Programming 1 by Paulino H. Gatpandan, Azenith M. Rollan
page 54-59.
SELF CHECKPR-5-1-1
1. %% - _______________________
2. %s - _______________________
3. %f - _______________________
4. %X - _______________________
5. %c - _______________________
6. %x - _______________________
7. %d - _______________________
8. %u - _______________________
9. %e - _______________________
10. %o - _______________________
STUDENT NAME: __________________________________ SECTION: __________________
PERFORMANCE OBJECTIVE: The learners independently demonstrate core competencies about Input
and Output Program
MATERIALS:
Computer / Android phone
Applications / Software:
Computer: TurboC2
Android phone: Coding C / CppDroid – C/C++ IDE
Procedure:
A. Make a program that will compute and display the sum and average of three
numbers
B. Make a program that will convert an inputted number in inches (in.) and
display its equivalent measure in feet (ft)
C. Create a program that asks for a distance in kilometers and converts it into its
metric equivalent
D. Put the screenshot of the output and code here.
PRECAUTIONS:
Undertake final inspections to ensure the program conform to requirements
ASSESSMENT METHOD: PERFORMANCE TASK CRITERIA CHECKLIST
STUDENT NAME: __________________________________ SECTION: __________________
5 - Excellently Performed
4 - Very Satisfactorily Performed
3 - Satisfactorily Performed
2 - Fairly Performed
1 - Poorly Performed
_________________________________
TEACHER
Date: ______________________