English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

can anyone plz explain what both functions do?

2006-11-29 18:23:05 · 8 answers · asked by Anonymous in Computers & Internet Programming & Design

8 answers

Scanf and Printf are funtions in the language of C.

Scanf Listens for a key to be pressed on the keyboard, then attaches this key to a variable.

Printf is used to print, or best described as display, charicters in the program window.

Hope that helps

2006-11-29 18:24:10 · answer #1 · answered by Anonymous · 0 0

Both Scanf and Printf are Build-in functions of C.

Scanf is used to get input from the user - The user may give the input from the key board or the input may be obtained from a file which is already present in the computer. While execution, Scanf prompts the user to give the input and stores the obtained input in some memory location.

For eg. if you have a variable named "reg_no", the variable name will be given a memory location, Now when use scanf as below

int reg_no;
scanf("%d", reg_no);

the input value obtained from the user will be stored iin the memory location alloted to reg_no. The & symbol in scanf indicates the compiler to store the obtained value at the memory address of reg_no.

Printf is used for printing the output the the output stream. The output stream may be the monitor or any file.

printf("Register Number is : %d", reg_no);

In above statement, the %d will be replaced by the value of reg_no.

**********
Vasu M
**********

2006-11-29 21:17:20 · answer #2 · answered by V@su Maniram 3 · 0 0

The scanf function takes a value from the user.
The printf function displays the output of the program code.

2006-11-29 18:25:34 · answer #3 · answered by Anonymous · 0 0

scanf and printf are standard functions for input and output operations in C.
They are defined in the header file "stdio.h" (Standard Input Output Header File)
Scanf waits for User input (key press or a bunch of keys till "Enter/Return" key is hit) and stores them in appropriate variables
Format : scanf("FormatSpecifier",&VariableAddress);
Printf echoes value of variables on screen
Format : printf("Format Specifier", Variable Name);

2006-11-29 18:35:27 · answer #4 · answered by Pavan M 2 · 0 0

Printf is a function to print formated output to consol. Variables can be used to create the output.
Scanf is counterpart of printf function which accepts formatted input from consol and assigns them to specified variable.

NB: both functions can use multiple & multi type variable.

2006-11-29 18:34:48 · answer #5 · answered by superman 1 · 0 0

scanf is a c function to get the input from the user.

printf is another c function to display the data on to screen.

2006-11-29 18:26:22 · answer #6 · answered by Ankush Kumar 1 · 0 0

scanf reads structured input from an input stream.
printf writes structured output to an output stream.

If the stream is the (text mode) console... scanf would read from keyboard input and printf would write text to the display.

2006-11-29 18:33:28 · answer #7 · answered by Dragonlord Warlock 4 · 0 0

There is no way to predict how code like this would run. Everything depends on the order in which the compiler and run-time support evaluates function arguments. You could try it on two different platforms and get two different results, as well. This kind of code is ugly, difficult to debug and impossible to maintain. If you were my student, I'd flunk this assignment.

2016-05-23 04:20:37 · answer #8 · answered by Anonymous · 0 0

fedest.com, questions and answers