Logo F2FInterview

C Interview Questions

Q   |   QA
‹‹ previous1234567891011

C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system

Although C was designed for implementing system software, it is also widely used for developing portable application software.

C is one of the most widely used programming languages of all time and there are very few computer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably C++, which began as an extension to C.

1. C follows the procedural programming paradigm while C++ is a multi-paradigm language(procedural as well as object oriented).

In case of C, importance is given to the steps or procedure of the program while C++ focuses on the data rather than the process.
Also, it is easier to implement/edit the code in case of C++ for the same reason.

2. In case of C, the data is not secured while the data is secured(hidden) in C++

This difference is due to specific OOP features like Data Hiding which are not present in C.

 3. C is a low-level language while C++ is a middle-level language (Relatively, Please see the discussion at the end of the post)

C is regarded as a low-level language(difficult interpretation & less user friendly) while C++ has features of both low-level(concentration on whats going on in the machine hardware) & high-level languages(concentration on the program itself) & hence is regarded as a middle-level language.

4. C uses the top-down approach while C++ uses the bottom-up approach

In case of C, the program is formulated step by step, each step is processed into detail while in C++, the base elements are first formulated which then are linked together to give rise to larger systems

5. C is function-driven while C++ is object-driven

Functions are the building blocks of a C program while objects are building blocks of a C++ program

6. C++ supports function overloading while C does not

Overloading means two functions having the same name in the same program. This can be done only in C++ with the help of Polymorphism(an OOP feature)

7. We can use functions inside structures in C++ but not in C.

In case of C++, functions can be used inside a structure while structures cannot contain functions in C.

8. The NAMESPACE feature in C++ is absent in case of C

C++ uses NAMESPACE which avoid name collisions. For instance, two students enrolled in the same university cannot have the same roll number while two students in different universities might have the same roll number. The universities are two different namespace & hence contain the same roll number(identifier) but the same university(one namespace) cannot have two students with the same roll number(identifier)

9. The standard input & output functions differ in the two languages

C uses scanf & printf while C++ uses cin>> & cout<< as their respective input & output functions

10. C++ allows the use of reference variables while C does not

Reference variables allow two variable names to point to the same memory location. We cannot use these variables in C programming.

11. C++ supports Exception Handling while C does not.

C does not support it "formally" but it can always be implemented by other methods. Though you don't have the framework to throw & catch exceptions as in C++.

sprintf(...) writes data to the character array whereas printf(...) writes data to the standard output device.

Size of the final executable can be reduced using dynamic linking for libraries

void PrintPermu (char *sBegin, char* sRest) {
     int iLoop;
     char cTmp;
     char cFLetter[1];
     char *sNewBegin;
     char *sCur;
     int iLen;
     static int iCount;
     iLen = strlen(sRest);

     if (iLen == 2) {
          printf("%d: %s%s\n",iCount,sBegin,sRest);
          printf("%d: %s%c%c\n",iCount,sBegin,sRest[1],sRest[0]);
     } else if (iLen == 1) {
          printf("%d: %s%s\n", iCount, sBegin, sRest);
     } else {
          // swap the first character of sRest with each of
          // the remaining chars recursively call debug print
          sCur = (char*)malloc(iLen);
          sNewBegin = (char*)malloc(iLen);
          for (iLoop = 0; iLoop <>
          strcpy(sCur, sRest);
          strcpy(sNewBegin, sBegin);
          cTmp = sCur[iLoop];
          sCur[iLoop] = sCur[0];
          sCur[0] = cTmp;
          sprintf(cFLetter, "%c", sCur[0]);
          strcat(sNewBegin, cFLetter);
          debugprint(sNewBegin, sCur+1);

void main() {
     char s[255];
     char sIn[255];
     printf("\nEnter a string:");
     PrintPermu(s, sIn);

‹‹ previous1234567891011

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: