Solved Question Papers
3.User-defined data types4.Empty data typesPrimary data types There are four fundamental data types, namely integer (int), character(char), floating point (float) double floating point (double).Derived data types Generally arrays, functions, structures and pointer will come underthe category of derived data types.User defined data types Type definition (type def) enumerated data type (enum) are theuser defined data types. (Structures and unions also come under this category).Size of data types:-
1.Char or signed char82.Unsigned char 83.Int or signed char164.Unsigned int165.Short int (or)8Signed short int6.Long int (or)32Signed long int7.Float328.Double649.Long double80
2.(a)Distinguish between getchar and scanf functions for reading strings.
Getchar:-Reading a single character can be done by using the function getchar.
Syntax:- variable_name = getchar ( );
Variable_name is a valid
name that has been declared as char type. When this statementis encountered, the computer waits until a key is pressed and then assigns this character asa value to getchar function. Since getchar is used on the right hand side of an assignmentstatement, the character value of getchar is in turn assigned to the variable_name on theleft. The getchar function may be called successively to read the characters contained in aline of text. Getchar accepts space character.
Scanf (“control strings”,arg1, arg2, ………… argn);
The control string specifies the field format in which the data is to be entered and thearguments arg 1, arg 2, arg
specify the address of locations where the data is stored.Scanf does not accept space character.