Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +917541905230, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Wednesday, October 14, 2020

C Interview questions and answers | Set-2

C Interview questions and answers-2


1) What is C Input/Output: printf() and scanf() functions?

The printf() and scanf() functions are used for input and output in C language and both functions are inbuilt library functions, declared in <stdio.h> header file.

  • printf() function: It is a C output function used to print or display output on the screen ("character, string, float, integer, octal and hexadecimal values."). Stands for print format.
  • scanf() function: It is a C Input function used to take input from user. The scanf() reads formatted input fro the standard input such as Keyboards. Stands for scanf format.

2) What is format specifier?

The format specifier tell the compiler what type of data to be input using scanf() while taking input form user and what type of data to be output on the screen using printf() functions. For example

Following are the format specifier:

  • %d: It is a format specifier used to print an integer value.
  • %s: It is a format specifier used to print a string.
  • %c: It is a format specifier used to display a character value.
  • %f: It is a format specifier used to display a floating point value.

3) What is data type?

Data type define the type of data a variable can hold, for example an int variable can hold integer data, a char variable can hold character type data etc.


14) What is keywords?

Keywords are predefined, reserved words used in programming that has a special meaning to the complier. Keywords can be command or parameter they cannot be used as an identifier. For example int roll_no; here, int is a keyword that indicates roll_no is a variable of integer type.


5) What is identifier?

Identifier refers to a name given to entities such as variables, functions, structures etc. Identifiers must be unique. They are created to give a unique name to an entity to identify it during the execution of program.


6) What is variable?

Variable is a name given to a memory location, that is used to hold a value. For example: int roll_no; here, roll_no is a name of variable that can hold a integer value.

Each variable in C has a specific type, which determines the size and layout of the variable's memory.


7) What is local variable, global variable and static variable ?

Types of variables:

  • Local variable: A variable which is declared inside function or block is known as a local variable. to
  • Global variable: A variable which is declared outside of function or block is known as a global variable.
  • Static variable: A variable which is declared as static is known as a static variable.
  • Constant variable: Any variable declared with const keyword is known as constant variable, and the constant variables must be initialized while declared. Example: const int emp = 50577

8) Difference between local variable and global variable?

Following are the differences between a local variable and global variable:

Basis for comparison

Local variable

Global variable

Declaration

A variable which is declared inside function or block is known as a local variable.

A variable which is declared outside function or block is known as a global variable.

Scope

The scope of a variable is available within a function in which they are declared.

The scope of a variable is available throughout the program.

Access

Variables can be accessed only by those statements inside a function in which they are declared.

Any statement in the entire program can access variables.

Life

Life of a variable is created when the function block is entered and destroyed on its exit.

Life of a variable exists until the program is executing.

Storage

Variables are stored in a stack unless specified.

The compiler decides the storage location of a variable.

More details.


9) What is the use of a static variable?

Following are the uses of a static variable:

  • A variable which is declared as static is known as a static variable. The static variable retains its value between multiple function calls.
  • Static variables are used because the scope of the static variable is available in the entire program. So, we can access a static variable anywhere in the program.
  • The static variable is initially initialized to zero. If we update the value of a variable, then the updated value is assigned.
  • The static variable is used as a common value which is shared by all the methods.
  • The static variable is initialized only once in the memory heap to reduce the memory usage.
More details.

10) What is literal or literal constant?

Literal constant or literal: refer to fixed values or constants values assigned to the constant variables that cannot be modified during its execution. It also contains memory but does not have reference as variables. For example: const int = 5; is a constant integer expression in which 5 is an integer literal.




Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec

Help others by sharing this page.

Ahmad Irshad

Author & Editor

I love blogging, teaching, learning computer science and sharing it to others. I've written and develped this site so that students may learn computer science related tutorials eaisly. MCA / MCITP

0 Comments:

Post a Comment

Please don't enter any spam link in the comment box.


Protec Computer Academy (An ISO 9001:2015 Certified Institute, Powered by E-Max Education, Branch Code EMAX/EK-80503, Registered by government of India.) is a best IT training center in Siwan with 100% Job placement assistance. Where you can learn Programming, WebDesigning, Hardware|Networking, Blogging, WordPress, Digitial marketing, English Speaking, And many more...| All certificates are valid in Government Jobs as well as in Private Companies. *** At Tara Market, Beside Vishal Mega Mart - Siwan*** +966532621401, Email- ahmad.irshad781@gmail.com *** Follow us on | | @welcome2protec
Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec Protec
Contact Us