0% found this document useful (0 votes)
7 views

Printf-Scanf-FunctionsPri

This document provides an overview of the printf and scanf functions in C programming, essential for input and output operations. It explains how printf outputs data to the console and how scanf reads user input, including the use of format specifiers. The document also includes practice tasks for creating pseudocode and actual programs using these functions.

Uploaded by

mpaucuizon
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Printf-Scanf-FunctionsPri

This document provides an overview of the printf and scanf functions in C programming, essential for input and output operations. It explains how printf outputs data to the console and how scanf reads user input, including the use of format specifiers. The document also includes practice tasks for creating pseudocode and actual programs using these functions.

Uploaded by

mpaucuizon
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Printf & Scanf Functions

C Programming
Objective
By the end of this lesson, you will
understand the basics of using the printf and
scanf functions in C programming. These
functions are fundamental for input and output
operations, allowing you to display information
to the user and read data from the user.
Introduction to printf
The printf function is used to output data to the
standard output (usually the console). It allows
you to print text, numbers, and other data types
formatted in various ways.

In this example:

● "Hello, World!\n" prints a simple message. \


n is a newline character.
● "%d" is a format specifier for integers. It is
replaced by the value of age.
Introduction to scanf
The scanf function is used to read input from the
standard input (usually the keyboard). It allows
you to take user input and store it in variables.

● format is a string that specifies the type of


input expected.
● ... are pointers to variables where the input
data will be stored.
Introduction to scanf

In this example:

● "%d" specifies that the input should be an


integer.
● &age is the address of the variable where the
input value will be stored.
3. Format Specifiers
Format specifiers are used in printf and scanf
to define the type of data being handled.

Common Format Specifiers


● %d - Integer
● %f - Float
● %lf - Double
● %c - Character
● %s - String
Let’s Practice these Program:
On a ½ Sheet of Paper, Let’s practice the following task.
Step 1: Create a Pseudocode of each program.
Step 2: Convert your Pseudocode to an actual program
using printf & scanf functions.

● Write a program that calculates the


average of three numbers.
● Write a program that calculates the
area of a Triangle based on user
input for length and width.

You might also like