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

Saturday, October 24, 2020

C Interview Questions and Answers | Set-3

C Interview Questions and Answers


1) What is auto keyword in C?

In C, every local variable of a function is known as an automatic (auto) variable. Variables which are declared inside the function block are known as a local variable. The local variables are also known as an auto variable. It is optional to use an auto keyword before the data type of a variable. If no value is stored in the local variable, then it consists of a garbage value.


2) What is is const keyword in C?

Constants are fixed value or variables, whose value cannot be changed throughout the execution of program. The fixed value is known as literal or literal constant.

You can define a constant for any type using "const" keyword. They behave like normal variables expect that they are read only (once assigned cannot be modified). For example: const int emp = 50577 C supports two styles of constant definition. int

  1. Using constkeyword
  2. Using #define directive


3) What is a static keyword in C?

In C, Static keyword can be used with both variables and functions, i.e. we can declare a static variable and static function as well. An ordinary variable is limited to the scope in which it is defined, while the scope of the static variable is throughout the program.


4) What is a register keyword in C?

In C, Register variable tell the complier to store the variable in CPU register instead of memory. Frequently used variables are kept in registers and they have faster accessibility.


5) What is a sizeof() keyword in C?

It is a compile time unary operator and used to compute the size of its operand.

sizeof() operator used to compute the size of data type as well as variables in bytes. It simply returns the amount of memory allocated to that data type. More details.

For Example:

int roll;
int b[5];
printf("Size of int = %d"\n, sizeof(int)); // WILL RETURN 4 BYTES  
printf("Size of int = %d"\n, sizeof(b)); //IT WILL RETURN 5 * 4 = 20 BYTES

6) What is a typedef keyword in C?

In C, typedef is used to create alternative names to existing datatypes to make a program more readable to the programmer. It is mostly used with user defined datatypes, when names of the datatypes become slightly complicated to use in programs.

For Example:
typedef int newint;
  

7) What is extern keyword in C?

In C, extern keyword is used to extend the visibility of function or variable. External variables can be declared numbers of times but define only once.


8) What is scope in C?

In C, a scope is a region of the program where a defined variable can be accessible directly, and it cannot be accessible beyond that region. More details.

For Example:

#include <stdio.h>   
int main() 
{  
  {
      int x = 10;
  }
  {
     /* Error: x is not accessible here since, there is no declaration of x in this block*/
    print("%d", x); 
  }
return 0;  
}  

9) What are the basic data types used in C

Data type determines the types of data a variable can hold. For example, If a variable x is declared as int. It means x can hold only integer value. Every variable which is used in program must be declared as what data type it is.

C language supports two different types of data types:

  1. Primary or Primitive data types: These are fundamental data types in C namely integer (int), floating point (float), character (char), double and void.
  2. Derived data types: Derived data types are nothing but primitive data types but a little twisted or grouped together like an array, structure, union, and pointer. These are discussed in details later.

10) Is void is a data type?

No it's not a data type. It is just a keyword that means nothing. See the below example to understand it better

For Example:

#include <stdio.h>
 int main()
 {
   int size;
   size = sizeof(void);
   printf("%d", size);
   return 0;
 }

Output

compilation error
/* If will try to find the size of void then compiler will show an error 
 * message "not type allowed" as we cannot use any storage class modifier 
 * with void, since void doesn't reserve any memory space. Hence we cannot 
 * declare any variable as of void type i.e. void num*/
   void num // Complication error
  

In C language, when void is used as a function return type as you can see in at below example: "void protec()", That means it indicates that function is not returning anything. When used in a function parameter list like (void), that means void indicates that the function takes no parameters.

void protec() {
  printf("Free online IT tutorial site."); // No returned value. 
}









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