C is the basic language, which is important for every programmer to start their journey in this field.
In most of companies and multinational technological companies, interviewer ask at least 2 to 4 question on C language.
C LANGUAGE
1. What is C language?
Nowadays, C is a basic and procedural language. This programming language is also known as the structural programming language is a technique in which massive programs are broken down into smaller parts. This kind of technique minimize errors.
2. Why C language known as a mother language?
C is known as mother language of all languages because most of programs and compilers are written in this language. It introduces new core concepts like arrays, functions, files which are useful in these languages.
3. What is the use of printf() and scanf() functions?
The printf() function is used to print the integer, character, float and string values. Even, find many specifiers, like %d, %c, %f, %d and many more
While, the scanf() is used to take input from the users.
4. What is an array in C?
An Array is a group of common types of elements. It makes the code optimized, easy to traverse and easy to sort it. After declaration the size and types can't be changed.
There are two types of arrays :-
1. Multidimensional Array :- it contains more than one array
2. One- dimensional array :- It stores the elements one after the another
5. What is static memory allocation?
In this allocation, memory is allocated at compile time, and memory cannot be increased while running the program. It using static keyword, this memory is faster than dynamic memory. In this allocation, more memory is required to store the variable.
6. What is dynamic memory allocation?
It is totally different from static memory. It is allocated at runtime and memory can be increased while executing the program. No other dynamic memory is required. In this portion, less memory is required to store different variables.
7. What is a pointer in C?
Basically, a pointer is a variable that address value. It makes the performance of code faster than previous one. In a program, the variable is find then system allocates some memory to variable. The memory contains some address number. The variable that hold this address number is known as the pointer variable.
8. What is a NULL pointer in C?
When we assign a '0' value to a pointer of any type, then it becomes a NULL pointer. It doesn't refer to any address of value.
9. What is a Union?
The Union is a user-defined data type, which allows contain multiple kind of data in single unit. It holds the memory of the largest member only. In union, people can access only single variable at special time.
10. Can we compile a program without main() function?
Sure, we can compile , but it can't be executed. If we use #define, we can easily compile and run C program. So, that's how we can use without compile.
11. What is the maximum length of an identifier?
It has 32 characters, but implementation specific.
12. Write a program to print "hello world" without using a semicolon?
#include<stdio.h>
void main(){
If(printf("hello world")){} // It prints the?
hello world? on the screen.
}
13. Write a program to print Fibonacci series using recursion?
#include<stdio.h>
#inculde<conio.h>
void printFibonacci(int n) // function to calculate the fibonacci series
{
static int n1=0, n2=1, n3; // declaration of static variables.
if(n>0){
n3 = n1 + n2;
n1 = n2;
n2 = n3;
printf("%d", n3);
printFibonacci(n-1); //calling the function recyrsively.
}
}
void main(){
int n;
clrscr();
printf("Enter the number of elements:");
scanf("%d",&n);
printf("Fibonacci Series:");
printf("%d %d", 0,1);
printFibonacci(n-2);//n-
2 because 2 numbers are already printed
getch();
}
14. What is typecasting?
Typecasting is a process of transferring one data type into another data. If we want to store the floating data type to an int type, we will convert data into another ones.
15. What is an auto keyword in C?
In this programming language, all the local variable known as an automatic variable. The local variables are also known as an auto variable. It become optional to use an auto keyword before the data type of a variable. The value become garbage value, when there is no value is store in local variable.
➽ This is model questions and answers, but this is also important question will be asked in any companies. So, be prepared for other complex questions.
0 Comments