Q.1 Differentiate between Actual Parameters and Formal Parameters.Ans.The Parameters which are sent from main function to the subdivided function are called as Actual Parameters and the parameters which are declared a the Subdivided function end are called as Formal Parameters. |
Q.2 Can a C program be compiled or executed in the absence of a main()?Ans.The program will be compiled but will not be executed. To execute any C program, main() is required. |
Q.3 What do you mean by a Nested Structure?Ans. When a data member of one structure is referred by the data member of another function, then the structure is called a Nested Structure. |
Q.4 What is the main difference between the Compiler and the Interpreter?Ans.Compiler is used in C Language and it translates the complete code into the Machine Code in one shot. On the other hand, Interpreter is used in Java Programming Langauge and other high-end programming languages. It is designed to compile code in line by line fashion. |
Q.5 What is a C Token?Ans. TOKEN is the smallest unit in a 'C' program. It is each and every word and punctuation that you come across in your C program. The compiler breaks a program into the smallest possible units (tokens) and proceeds to the various stages of the compilation. A token is divided into six different types, viz, Keywords, Operators, Strings, Constants, Special Characters, and Identifiers. |
Q.6 What is the purpose of printf() and scanf() in C Program?Ans. printf() is used to print the values on the screen. To print certain values, and on the other hand, scanf() is used to scan the values. We need an appropriate datatype format specifier for both printing and scanning purposes. For example, |
Q.7 Can I create a customized Head File in C language?Ans. It is possible to create a new header file. Create a file with function prototypes that need to be used in the program. Include the file in the ‘#include’ section in its name. |
Q.8 What is typecasting?Ans. Typecasting is a process of converting one data type into another is known as typecasting. If we want to store the floating type value to an int type, then we will convert the data type into another data type explicitly. Syntax:(type_name) expression; |
Q.9 Write a C program to print hello world without using a semicolon (;)Ans. #include < stdio.h >void main(){if(printf('hello world')){}} |
Q.10 What do you mean by Dangling Pointer Variable in C Programming?Ans. A Pointer in C Programming is used to point the memory location of an existing variable. In case if that particular variable is deleted and the Pointer is still pointing to the same memory location, then that particular pointer variable is called as a Dangling Pointer Variable. |
Q.11 WHAT ARE THE DIFFERENT TYPES OF OPERATORS IN C?Ans. Arithmetic operatorsAssignment operatorsRelational operatorsLogical operatorsBit wise operatorsConditional operators (ternary operators)Increment/decrement operatorsSpecial operators |
Q.12 Write prgram of C Code with MacrosAns. #define SQUARE(x) ((x)*(x))void test() {int x = 5;int y = SQUARE(x++);printf('Result of x is %d, y is %d.
', x, y);} |
Q.13 Write program using C Code to Allocate Memory.char* allocateMemory() {char str[20] = 'Hello are you with us.';return str;}void test() {char* pString = allocateMemory();printf('pString is %s.
', pString);} |
Q14. What will be printed as the result of the operation below?main(){char *p1;char *p2;p1=(char*)malloc(25);p2=(char*)malloc(25);strcpy(p1,'Cisco');strcpy(p2,'systems');strcat(p1,p2);printf('%s',p1);}Ans. Output: Ciscosystems |
Q15. What will be output of following program?#includeint main() {int a = 10;void *p = &a;int *ptr = p;printf('%u',*ptr);return 0;}Ans. Output: 10 |
Q16. State the equivalent pointer expression which refer the given array elementa[i][j][k][l]?Ans. Above pointer expression can be written as *(*(*(*(a+i)+j)+k)+l). |
Q17. Can you combine the following two statements into one?char *p;p = (char*)malloc(100);Ans. Above two expressions can be written in combined form aschar*p = (char*)malloc(100); |
Q.18 Difference between of printf() and scanf() functions?Ans .printf() is used to print the output on the display.scanf() is used to read formatted data from the keyboard.Some datatype format specifiers for both printing and scanning purposes are as follows: |
Q.19 What is format specifiers?Ans%d: It's a datatype format specifier for printing and scanning an integer value.%s: It's a datatype format specifier for printing and scanning a string.%c: It's a datatype format specifier for displaying and scanning a character value.%f: The datatype format specifier %f is used to display and scan a float value |
Q.20 What is typecasting in C?Ans. Typecasting is the process to convert a variable from one datatype to another. If we want to store the large type value to an int type, then we will convert the data type into another data type explicitly. |
Q.21 Why n++ executes faster than n+1 ?Ans .n++ being a unary operation, it just needs one variable. Whereas, n = n + 1 is a binary operation that adds overhead to take more time (also binary operation: n += 1). However, in modern platforms, it depends on few things such as processor architecture, C compiler, usage in your code, and other factors such as hardware problems. |
Q.22 What are Enumerations?Ans. Enumeration, also known as Enum in C, is a user-defined data type. It consists of constant integrals or integers that have names assigned to them by the user. Because the integer values are named with enum in C, the whole program is simple to learn, understand, and maintain by the same or even different programmer. |
Q.23 what is meaning of char* p ?Ans. const char* p is a pointer to a const char. |
Note: const char and char const are the same. |
Q.24 what is meaning of char const* p ?Ans. char const* p is a pointer to a char const. Note: const char and char const are the same. |
Q.25 What is the difference between ‘g’ and “g” in C?Ans.In C double-quotes variables are identified as a string whereas single-quoted variables are identified as the character. |
Q.26 What is global variable.Ans .The difference between this is in scope. A truly global variable has a global scope and is visible everywhere in your program.#includeint my_global_var = 0;intmain(void){printf('%d
', my_global_var);return 0;} |