Advertisement

INTRODUCTION TO C PROGRAMMING.


Fill in the blanks:
(1)C is a High level language.
(2)A C program must be compile before it can be executed.
(3) A named area in memory that stores a character or numeric value is called Variable.
(4) In C, a number containing a decimal point of type float.
(5) The memory size of a floating point number is usually 4 bytes.
(6)The equality checking operator in C is ==.
(7) “%C is the standard function to read a single character from keyboard.
2. State whether the following statements are true or false.
(1) C is a interpreted language.False.
(2) In C , an user must define the meaning of keyword used.False.
(3) The type of variable determines what kind of values it may take on.True.
(4) A variable name can be begin with underscore.False.
(5) A variable declaration tells the name and type of a variable.False.
(6) “34.5” is a numeric constant. False.
(7) The keyword int is used to declare a constant.False.
(8) The expression 4+5*6 will evaluate to 54.False.
(9) The expression 4 ^ 2 to find the square of 4 is valid in C. False.
(10) The standard C functions are grouped into header files. True.
(11) The standard C function to find  the absolute value of a number x is abs(x).False.
(12) The format specifier for an integer in a printf statement in C is \n. False
(13)Explanatory comments in C are given with the REM keyword.False

3. Give the purpose of each of the following in a C program.
(1) float : float is a data type to store a floating point number. E.g. : 3.14
(2) char : char is a data type to store a character. E.g. : ‘a’
(3) getchar( ) : The function input a simple character from the keyboard.
(4) scanf :  The function performs formatted input.  E.g. scanf(“%d”, & a);
(5) stdio.h : stdio.h is a header file which predefined standard input and output function.
(6) math.h : math.h is a header file which predefined mathematical function
(7) \t : It is an escape sequence which is used in print.
4. Answer the following questions in one or two sentences each:
(1) What are the primary data types in C?
Ans..int (integer), char (Character), float (floating point number) and double are the primary data type in C.
(2)What is a numeric constant?
Ans.. Numeric constant is a number. E.g. 2,3.142.
(3)What does the modulus operator do in c.
Ans. Modulus operator returns the mode of a division. E.g. 4 % 3 = 1.
(4)What is the deference between the operators =  and ==?
Ans.= is a assignment operator eg. a=2.== is evaluating 2 numbers to find out the big one .
(5)What is a header file?
Ans. Header file is a predefined function which can be used in our program.
(6)State the parts of a C program?
Ans. Heading, inclusion, function main( ) with statements and optional user defined functions.
(7)What is the purpose of the inclusion statements in a C program??
Ans.To include predefined user function to user program.
5. Write the C expression for.
(1)raising 2 to the power 5:pow(2,5);
(2)a3- 7b +1.:pow(a,3)- (7*b)+1
(3)(5(f-32))/9: (5 * (f-32))/9
6. Identify the valid variable name in C: m, N, 7N,-avg, %d.
Ans. m, N.
7. The following statement block in C is supposed to calculate (a+b)3, but there are errors. Find out the errors and rewrite the statement block.
int a ==5, b=6,ans
ans=(a+b)^3;
printf(The answer is, ans);
Ans. int a=5,b=6,ans;
ans=(a+b) * 3;

printf(“The answer is %d “, ans);