filmov
tv
Formatted Input in C Programming in Tamil

Показать описание
#c #formatinput #computerlanguage #learntoday
What is Formatted Input in C Programming in Tamil?
Formatted Input refers to an input data that has been arranged in a particular format
for example consider the following statement
15.75 123 John
15.75 %f is also known as float
123 %d is also known as int
John %c is also known as char
The general form of scanf is
scanf("control string",arg1,arg2....argn);
control string- Which dat type is specified.
arg1,arg2...argn-Specify the address of locations.
Inputting Integers Numbers
The field specification for reading an integer number is %w sd
consider the following example
scanf("%2d%5d",&num1,&num2);
data line 50 31426
tha value 50 is assigned to num1 and 31426 to num2.
An input field may be skipped by specifying * in the place field width.
Inputting Real Numbers
Unlike integer numbers the field width of real numbers is not to be specified and therefore scanf reads real numbers using the simple specification %f for both the notations,namely,decimal point notation and exponential notation.
Inputting Character Strings
We have already seen how a single character can be read from the terminal using the getchar function.
The same can be achieved using the scanf function also.In addition a scanf function can input strings containing more than one character.
%ws or %wc
%wc w-width c-character
%ws w-width s-string
Reading mixed data types
It is possible to use one scanf statement to input a data line containing mixed mode data.
The statement
scanf("%d%c%f%s",&count,&code,&ratio,name); will read the data
15 P 1.575 coffee
Correctly and assign the values to the variables in the order in which they appear.
Detection of Errors in Input
When a scanf function completes reading it's list it returns the value of number of items that are successfully read.
For example ("%d%f%s",&a,&b,name);
20 150.25 motor
h-for short Integers
l-for long Integers or double
L-for long double
Points to remember while using scanf
Except the control string must be pointers to variables.
Seperate by spaces and must match the variables.
Any unread data items in a line will be considered as next scanf call.
In this chennal only provide education related videos.
What is Formatted Input in C Programming in Tamil?
Formatted Input refers to an input data that has been arranged in a particular format
for example consider the following statement
15.75 123 John
15.75 %f is also known as float
123 %d is also known as int
John %c is also known as char
The general form of scanf is
scanf("control string",arg1,arg2....argn);
control string- Which dat type is specified.
arg1,arg2...argn-Specify the address of locations.
Inputting Integers Numbers
The field specification for reading an integer number is %w sd
consider the following example
scanf("%2d%5d",&num1,&num2);
data line 50 31426
tha value 50 is assigned to num1 and 31426 to num2.
An input field may be skipped by specifying * in the place field width.
Inputting Real Numbers
Unlike integer numbers the field width of real numbers is not to be specified and therefore scanf reads real numbers using the simple specification %f for both the notations,namely,decimal point notation and exponential notation.
Inputting Character Strings
We have already seen how a single character can be read from the terminal using the getchar function.
The same can be achieved using the scanf function also.In addition a scanf function can input strings containing more than one character.
%ws or %wc
%wc w-width c-character
%ws w-width s-string
Reading mixed data types
It is possible to use one scanf statement to input a data line containing mixed mode data.
The statement
scanf("%d%c%f%s",&count,&code,&ratio,name); will read the data
15 P 1.575 coffee
Correctly and assign the values to the variables in the order in which they appear.
Detection of Errors in Input
When a scanf function completes reading it's list it returns the value of number of items that are successfully read.
For example ("%d%f%s",&a,&b,name);
20 150.25 motor
h-for short Integers
l-for long Integers or double
L-for long double
Points to remember while using scanf
Except the control string must be pointers to variables.
Seperate by spaces and must match the variables.
Any unread data items in a line will be considered as next scanf call.
In this chennal only provide education related videos.
Комментарии