Hello, student All of your Question-related here all C function, with Reason or Advantages & Disadvantages of it’s. why use scanf and what is scanf in c language?
For Input the data in C or what is scanf in c language?
scanf(); ‘C’ provides function scanf(); for reading the value.
Syntax:- scanf("format_specifier", Address of variable);
1. The format string contains appropriate number and the appropriate type of format specifier in an appropriate order.
2. Address of variable is retrieved by using symbol ‘&’
for example:– If you want to enter the value of ‘g’ then how looks your statement in C program is given below.
Note:- scanf(); is function. “%d” is format specifier it may be a difference in another datatype it’s used for Integer type Data. ‘&’ here we use “&” for Retrieving the address of Variable.
Why we use scanf in c
Output The Data-
what is scanf in c language(); :-
printf(); In C it’s provides function ‘printf(); to Display output on Monitor.
Syntax: printf(” Message”,List of Variables separate with comma);
1. The message string contains the message. format specifier and escape sequences.
2. The message string is printed as it is on the monitor except for format specifiers.
3. The value of the Appropriate variable is printed in the palace of format specifiers.
for example:- If you won’t go to print the value of ‘b’, let you store the value of a=5 then, how to write in C for printing that is:-
printf(" Value of b=", b); 'or' printf(" /n Value of b=", b);
Note:- Here escape sequence ‘/n’ is used to move the cursor in the output window.
what is scanf in c language
What is scanf in c programming
Why use clrscr(); in C?
Ans:- clrscr(); stands for Clear Screen, in every C program we can use this function for clear the output screen. we attach it bottom of <Data type section> & top of printf(); or scanf(); .
Profit of clrscr(); is given below:-
without clrscr(); – Your output screen looks like Rough Page.
with clrscr(); –Your output screen looks like a clean Page.
Q. Why use getch(); in c program?
Ans:- There are various functions in C which do not return any value in some cases on the output screen. A function with no return value has no errored but also not a complete program. In C program if you will use header file as <conio.h> then you have to necessary to use getch(); or return 0; if any case you don’t use this, then our compiler can not understand what to do, Because of header file <conio.h> , conio stands for Console Input/Outputso the C compiler will be confused.
Function:- Function is a sub program or block of code written separately to perform a specific tasks, but here scanf(); & printf(); is also function but another type of function.
Function Body:- The function body contains a collection of statements that define what the function does.
Function declaration:- A function declaration tells the compiler about a function name and how to call the function. The actual body of the function can be defined separately.
How to work Function scanf( ); & Printf(); :– While you using a C function, you give a definition of what the function has to do. To use a function, you will have to call that function to perform the defined task. When a program calls a function, the program control is transferred to the called function. A called function performs a defined task and when its return statement is executed or when its function-ending closing brace is reached, it returns the program control back to the main program.
What is printf and scanf in c
Advantages of Function in C:-
1. Function breaks our program into a number of smaller modules. This makes the program easier to understand & Debug.
2. The function enables us to use the same block of code several times at several spaces in the program.
3. Function eliminates unnecessaryduplication of code.
4. The function saves time and memory.
I hope you will understand what is scanf in c language();.