Thursday, January 10, 2019

C- Language Part-1



C Language-Basics

1. What is Execution?
Answer: An execution is a process in which the instruction or programs are executed.

2. What is constant in C?
Answer: A constant in a program is that which never altered its existence during execution.

3. Types of constant.
Answer: In C there are two types of constant
                a. Pre-processor Directive (#define)
                b. A CONST keyword

4. What is variable?
Answer: A variable is a value which may be change during program execution.

5. What is the difference between 'break' and 'continue'?
Answer: a. to alter the normal flow of the program, ‘break’ and ‘continue’ statement is used in C.
b. break statement is used in both switch as well as loops while continue is only used in loops.
c. When break executed it terminates the block or loops while continue gets the control to the next iteration of the loop.

6. What is the difference between 'while' and 'do while'?
Answer: while loop is actually an entry in the loop if it’s true and do-while is actually used to exit   from the loop if it’s true.

7. What is a function?
Answer: A function is a block of statements that performs a specific task. Suppose you are building an application in C language and in one of your program, you need to perform a same task more than once. In such case you have two options –
a) Use the same set of statements every time you want to perform the task
b) Create a function to perform that task, and just call it every time you need to perform that task.


8. What is pointer?
Answer: A pointer is a variable that contains the address of another variable.

9. What is output of the following?
               int *p , i;
               p=&i ;
               i=2 ;
               printf("%d" , i ) ;
               printf("%u" , p ) ;
               printf("%d" , *p ) ;
Answer:  2  , 2348084956  ,  2

10. What is the data type in C?
Answer: a data type is a type of data which resides in the memory. Type of data means int, char, float etc.

11. What is recursion?
Answer: A function which calls itself is called as recursive function and the technique is known as recursion.

12. What is the difference b/w functions and recursion?
Answer: A recursion is also a function and a function which calls itself is called recursion.


13. What is structure and union?
Answer: a. to store different data type in the same memory location UNION is used while in   structure each member is assigned unique storage location.
                b. In union only one member can be accessed at a time while in structure individual member can be accessed at a time.

14. What is the difference between declaration and definition of a variable or function?
Answer: Declaration of a variable or a function is only meant to define data type but not allocates the memory while in definition of a variable a memory allocation is done on the basis of data type.

15. What are local static variables? What is their use?
Answer: A static variable never change its value in the program. It can be used to count the number of visitors on the website. The default value of static variable is 0.

No comments:

Post a Comment

C- Language Part-1

C Language-Basics 1. What is Execution? Answer: An execution is a process in which the instruction or programs are executed. ...