C Tutorial

Define C

Define Programming

Programming Approach

First C Program

TurboC Shortcut keys

Compiler vs Interpreter

C Variable

C Keywords

C Data Types

C Comments

C Operators

Hierarchy of Operators

Ex: Arithmetic Operator

C Formatting Output

C Escape Sequence

C if statement

Ex: If statement

C Switch statement

Ex: Switch

Increment / Decrement

C Loops

Ex: Loops

C Nesting Of Loops

Ex: Nested Loops

C Jumping Statements

C Exit(), Gotoxy()

C Arrays 1D

Ex: Arrays 1D

C Arrays 2D

Ex: Arrays 2D

C Sorting

ASCII Value

Character I/O Function

Ex: Character

C String Functions

Ex: Strings

Array of Strings

C Math Functions

User-defined Function

Exercise Function

Local, Reference variable

Function Calling types

Array Passing Function

Recursion Function

Ex: Recursion Function

Constant Variable

Storage Class

C Header Files

C Preprocessor

C Pointers

Pointer to Pointer

C Structures

Exercise Structure

C Typedef

C Enumeration

C File Handling

Ex: File Handling

Command Line Argument

MCQ

Question-Answer

Page Stats

Visitor: 657

C - Questions and Answers

  1. What is C language?
  2. C is a middle level and procedural programming language.

  3. Why C is called a middle level programming language?
  4. It supports the feature of both low-level and high level languages that is why it is known as a middle level programming language.
    Low level language specific machine dependent, fast to run, But it is not easy to understand.
    High Level language is not specific to one machine i.e. machine independent. It is easy to understand.

  5. Why C is known as a mother language?
  6. C is known as a mother language because most of the compilers, kernels and JVMs are written in C language and most of the languages follows c syntax.
    It provides the core concepts like if condition, loops, array, functions, file handling etc. that is being used in many languages like C++, Java, C#, Python etc.

  7. Who is the founder of C language?
  8. Dennis Ritchie.

  9. When C language was developed?
  10. C language was developed in 1972 at bell laboratory of AT&T.

  11. What are the features of C language?
  12. The main features of C language are given below:
    • Simple
    • Portable
    • Machine Independent
    • Rich Library
    • Fast Speed
    • Extensible
    • Memory Management

  13. Why C is a also known as procedural language?
  14. A procedure is known as function, method, routine, subroutine etc. A procedural language specifies a series of steps or procedures for the program to solve the problem. A procedural language breaks the program into functions, data structures etc. C is a procedural language. In C, variables and function prototypes must be declared before being used.

  15. What is the use of printf() and scanf() functions?
  16. The printf() function is used for output and scanf() function is used for input.

  17. What is token?
  18. Token is an identifier. It can be constant, keyword, string literal etc.

  19. What is new line escape sequence?
  20. The new line escape sequence is represent by "\n". It inserts a new line on the output screen.

  21. What is the maximum length of an identifier?
  22. It is 32 characters ideally but implementation specific.

  23. What is the difference between local variable and global variable in C?
  24. Local variable: A variable which is declared inside the function or block is known as local variable.

    Global variable: A variable which is declared outside the function or block is known as global variable.

    int a=10; //global variable
    void function(){
        int b=20; //local variable
    }

  25. What is the use of static variable in C?
  26. A variable which is declared as static is known as static variable. The static variable retains its value between multiple function calls.

    void function(){
        int x=10;//local variable
        static int y=10;//static variable
        x=x+1;
        y=y+1;
        printf("%d\n",x);//will always print 11
        printf("%d\n",y);//will always increment value, it will print 11, 12, 13 and so on
    }

  27. What is auto keyword in C?
  28. In C, every local variable of a function is known as automatic (auto) variable. Let's explain with an example:
    void fun()
    {
        int i ;
        auto int j;
    }
    Here, both 'i' and 'j' variables are automatic variables.

  29. What is infinite loop?
  30. A loop running continuously for indefinite number of times is called infinite loop.

    Infinite For Loop:
    for(;;){
        printf("\nInfinitive for loop");
    }

    Infinite While Loop:
    while(1){
        printf("\nInfinitive while loop");
    }

    do{
        printf("\nInfinitive do while loop");
    }while(1);

    Multiple initializations in for loop
    for (i=1,j=1; j<=10; i++, j++)
    {
        printf("%d %d\n", i, j);
    }

  31. What is array in C?
  32. Array is a group of similar types of elements. It has contiguous memory location. It makes the code optimized, easy to traverse and easy to sort.

  33. What is the acronym for ASCII?
  34. American Standard Code of Information Interchange.

  35. What is the difference between getch() and getche()?
  36. The getch() function reads a single character from keyboard. It doesn't use any buffer, so entered data is not displayed on the output screen.

    The getche() function reads a single character from keyword and data is displayed on the output screen.

  37. What is the use of function in C?
  38. A function in C language provides modularity. It can be called many times. It saves code and we can reuse the same code many times.

  39. What is the difference between call by value and call by reference in C?
  40. We can pass value to function by one of the two ways: call by value or call by reference.
    In call by value, a copy of value is passed to the function, so original value is not modified.
    But in the case of call by reference, an address of a variable is passed via function argument, so original value is modified.

  41. What is recursion in C?
  42. Calling the same function, inside the function is known as recursion.

  43. What is pointer in C?
  44. A pointer is a variable that refers to the address of a variable. It makes the code optimized and makes the performance fast.

  45. What is the usage of pointer in C?
  46. • Accessing array elements
    • Dynamic memory allocation
    • Call by Reference
    • Data Structures like tree, graph, linked list etc.

  47. What is pointer to pointer in C?
  48. In case of pointer to pointer concept, one pointer refers to the address of another pointer.

  49. Can we access array using pointer in C language?
  50. Yes, by holding the base address of array into pointer, we can access the array using pointer.

  51. What is static memory allocation?
  52. In case of static memory allocation, memory is allocated at compile time and memory can't be increased while executing the program. It is used in array.

  53. What is dynamic memory allocation?
  54. In case of dynamic memory allocation, memory is allocated at run time and memory can be increased while executing the program. It is used in linked list.

  55. What is structure?
  56. Structure is a user-defined data type that allows to store multiple types of data in a single unit. It occupies the sum of memory of all members.

  57. What is union?
  58. Like Structure, union is a user-defined data type that allows to store multiple types of data in a single unit. But it doesn't occupies the sum of memory of all members. It occupies the memory of largest member only.

  59. What is command line argument?
  60. The argument passed to the main() function while executing the program is known as command line argument. For example:
    void main(int count, char *args[])
    {
        //code to be executed
    }

  61. What are the functions to open and close file in C language?
  62. The fopen() function is used to open file whereas fclose() is used to close file.

  63. Can we compile a program without main() function?
  64. Yes, we can compile but it can't be executed. But, if we use #define, we can compile and run C program without using main() function. For example:
    #include<stdio.h>
    #define start main
    void start()
    {
        printf("Hello");
    }

  65. Write a program to print "hello world" without using semicolon?
  66. There are various ways to do so. Let's see a program to print "hello world" using if.
    #include<stdio.h>
    void main()
    {
        if(printf("hello world")){}
    }

  67. Write a c program to find the sum of n numbers given as input by the user.
Updated: 19-Jul-21