HOW TO TAKE INPUT FROM USER In C Language?

0

WE WILL DISCUSS HOW TO TAKE INPUT FROM USER...




scanf reads input from stdin, which is the standard input and by default it is what you type on your terminal using the keyboard.
The function prototype of scanf is:
int scanf ( char *format, … )
It is pretty clear that scanf returns an int (integer) value. This int value corresponds to the number of characters successfully read as defined by you using % for format and & for address variable. It stops when the format string is exhausted after successfully reading all the input.
If some input fails to match the control specification (format), scanf stops and returns the number successfully matched and assigned input items before the mismatch failure. If there is a mismatch on the very first format specification, scanf returns 0. EOF is returned on end of the file.

Format Specifiers

There are many format specifiers defined in C. Take a look at the following list:
%i or %d int
%c char
%f float
%s string

ESCAPE SEQUENCE:

\n (newline)
\t (tab)
\v (vertical tab)
\f (new page)
\b (backspace)
\r (carriage return)
\n (newline)

%d (print as a decimal integer)
%6d (print as a decimal integer with a width of at least 6 wide)
%f (print as a floating-point)
%4f (print as a floating-point with a width of at least 4 wide)
%.4f (print as a floating-point with a precision of four characters after the decimal point)
%3.2f (print as a floating-point at least 3 wide and a precision of 2)



Coding

#include<stdio.h>
int main()
{
      int a;
      printf("Enter the number\n");
     scanf("%d\n",&a);
     printf("%d",(a+10));

 }

For know the Execution of the Coding watching below video




Post a Comment

0Comments

We you have any doubt let me know :)

Post a Comment (0)
To Top