programming for problem solving viva questions and answers

c programming viva questions

' src=

Welcome to our comprehensive guide on module-wise  C Programming viva questions  for first-year engineering students. To help you excel in your viva examination, we have curated a set of questions organized by modules. Each module focuses on specific C programming concepts as per Mumbai University Syllabus , enabling you to prepare at last moment and have a practice .

Table of Contents

Module 1 : introduction ( c programming viva questions ).

No.Question and Answers
1What are the components of a computer system?
AnswerThe components of a computer system include the central processing unit (CPU), memory, input devices, output devices, and storage devices.
2What is an algorithm?
AnswerAn algorithm is a step-by-step procedure or set of rules for solving a specific problem.
3What is a flowchart?
AnswerA flowchart is a graphical representation of the steps or actions involved in solving a problem or completing a process.
4What are keywords in C programming?
AnswerKeywords are reserved words in the C programming language that have predefined meanings and cannot be used as variable names or identifiers.
5What are identifiers in C programming?
AnswerIdentifiers are names given to variables, functions, or other entities in a C program.
6What are constants in C programming?
AnswerConstants are fixed values that do not change during the execution of a program.
7What are variables in C programming?
AnswerVariables are memory locations used to store values that can be modified during the execution of a program.
8What are the different data types in C programming?
AnswerThe data types in C programming include integer, float, character, and void, among others.
9What are operators in C programming?
AnswerOperators are symbols or characters that perform various operations on operands, such as arithmetic, logical, and relational operations.
10How do you perform basic input and output operations in C?
AnswerBasic input and output operations in C are performed using functions like scanf() and printf().
11What are expressions in C programming?
AnswerExpressions are combinations of variables, constants, and operators that evaluate to a single value.
12What is the precedence of operators in C?
AnswerThe precedence of operators determines the order in which operators are evaluated in an expression.
13What are in-built functions in C?
AnswerIn-built functions are pre-defined functions provided by the C language that perform specific tasks.

( C Programming viva questions )

Module 2 : Control Structures

No.Question and Answer ( )
1What are control structures in programming?
A1Control structures are statements or constructs that control the flow of execution in a program.
2What are the branching and looping structures in C?
A2Branching structures include if, if-else, nested if-else, and else-if ladder statements. Looping structures include for loop, while loop, and do-while loop.
3How does the if statement work in C?
A3The if statement is used to execute a block of code if a specified condition is true. If the condition is false, the code block is skipped.
4What is the purpose of the switch statement in C?
A4The switch statement is used to select one of many code blocks to be executed, based on the value of a variable or expression.
5How do for, while, and do-while loops work in C?
A5The for loop executes a block of code repeatedly until a specified condition is met. The while loop and do-while loop also repeat a block of code based on a condition, but with different control structures.
6What is the purpose of the break statement in C?
A6The break statement is used to exit a loop or switch statement prematurely.
7What is the purpose of the continue statement in C?
A7The continue statement is used to skip the remaining code in a loop and move to the next iteration.
8What are the different types of loops in C?
A8C programming language supports three types of loops: the for loop, the while loop, and the do-while loop. Each loop has its own syntax and specific use cases.
9What are nested control structures in programming?
A9Nested control structures refer to the use of one control structure inside another. This can be done by placing one control structure’s block of code within another control structure’s block. It allows for more complex program flow and decision-making.
10What is the difference between the while loop and the do-while loop in C?
A10The while loop checks the condition before executing the code block, while the do-while loop checks the condition after executing the code block. This means that the do-while loop will always execute the code block at least once, even if the condition is initially false.

Module 3: Functions

No.Question and Answer ( )
1What is a function in C programming?
A1A function is a block of code that performs a specific task. It can be called from other parts of the program to execute the code within the function.
2What is a function prototype?
A2A function prototype is a declaration that provides the function’s name, return type, and parameter types to the compiler before the function definition.
3How do you define a function in C?
A3A function definition specifies the code to be executed when the function is called. It includes the return type, function name, parameters (if any), and the code block.
4How do you access a function in C?
A4A function can be accessed or called by its name followed by parentheses, and arguments can be passed within the parentheses if the function has parameters.
5What is parameter passing in functions?
A5Parameter passing is the mechanism of passing values to a function’s parameters when the function is called, allowing the function to work with the provided data.
6What is recursion in C?
A6Recursion is a programming technique where a function calls itself directly or indirectly to solve a problem by breaking it into smaller subproblems.

Module 4: Arrays and Strings

No.Question and Answer ( )
1What is an array in C?
A1An array is a collection of elements of the same data type, stored in contiguous memory locations, and accessed using an index.
2How do you declare and initialize a one-dimensional array in C?
A2An array is declared by specifying the data type of its elements and its size within square brackets. Initialization involves assigning initial values to the array elements.
3How do you declare and initialize a two-dimensional array in C?
A3A two-dimensional array is declared by specifying the data type of its elements and the number of rows and columns. Initialization involves assigning values to the array elements using nested braces.
4What is a string in C?
A4A string is an array of characters terminated by a null character (‘\0’).
5How do you define and initialize a string in C?
A5A string can be defined as an array of characters and initialized by enclosing the characters within double quotes.
6What are string functions in C?
A6String functions are predefined functions in C that perform operations on strings, such as copying, concatenating, comparing, and searching.
7How do you access elements in an array in C?
A7Elements in an array are accessed by using the array name followed by the index of the element within square brackets.
8What is the difference between an array and a pointer in C?
A8An array is a collection of elements, whereas a pointer is a variable that stores the memory address of another variable. However, there are similarities between arrays and pointers in C.
9Can an array be resized in C?
A9No, the size of an array in C is fixed at the time of declaration and cannot be changed during runtime. If resizing is required, dynamic memory allocation can be used.
10What is the maximum number of elements an array can hold in C?
A10The maximum number of elements an array can hold in C depends on the data type and the available memory in the system.

Module 5: Structure and Union

No.Question and Answer ( )
1What is the concept of structure and union in C?
A1Structures and unions are user-defined data types in C that allow you to combine different data types under a single name.
2How do you declare and initialize a structure in C?
A2A structure is declared by specifying its members and their data types. Initialization involves assigning values to the members using the dot operator.
3What are nested structures in C?
A3Nested structures are structures that are members of another structure. They allow you to create complex data structures by combining multiple structures.
4How do you declare and access an array of structures in C?
A4An array of structures is declared by specifying the structure type and the size of the array. Each element of the array can be accessed using the array index and the dot operator.
5How do you pass a structure to a function in C?
A5A structure can be passed to a function as a parameter by value or by reference. By value means a copy of the structure is passed, while by reference means the function receives the address of the structure.
6What is the difference between a structure and a union in C?
A6The main difference between a structure and a union in C is how they allocate memory. In a structure, each member has its own memory space, while in a union, all members share the same memory space. Additionally, a union can only store one value at a time, while a structure can store multiple values simultaneously.
7How do you access members of a structure in C?
A7Members of a structure can be accessed using the dot operator (.) followed by the member name. For example, if “struct_name” is a structure and “member_name” is a member of that structure, you can access it as “struct_name.member_name”.
8What is the purpose of typedef in C structures?
A8The typedef keyword in C is used to create a new name for an existing data type, including structures. It provides a convenient way to define complex data types and make the code more readable.
9Can structures contain functions in C?
A9No, structures in C cannot directly contain functions. However, they can have function pointers as members, which can be used to indirectly call functions.
10What is the size of a structure in C?
A10The size of a structure in C is determined by the sum of the sizes of its members, with possible padding added for alignment purposes. The sizeof operator can be used to determine the size of a structure.

Module 6: Pointers

No.Question and Answer ( )
1What are pointers in C?
A1Pointers are variables that store memory addresses. They allow you to indirectly access and manipulate data in memory.
2How do you declare, initialize, and dereference pointers in C?
A2Pointers are declared by specifying the data type they point to, initialized by assigning the address of a variable, and dereferenced using the dereference operator (*).
3What operations can be performed on pointers in C?
A3Pointers can be incremented or decremented, compared for equality or inequality, and assigned new addresses. They can also be used to access and modify the value they point to.
4What is dynamic memory allocation in C?
A4Dynamic memory allocation in C allows you to allocate and deallocate memory at runtime using functions like malloc(), calloc(), realloc(), and free().
5What is the difference between pointers and arrays in C?
A5Pointers and arrays in C are closely related, and in many cases, arrays are implemented using pointers. However, pointers and arrays have some differences, such as how they are declared, accessed, and used in different contexts.
6How do you pass pointers to functions in C?
A6Pointers can be passed to functions in C by specifying the pointer type as a parameter. The function can then access and modify the data pointed to by the pointer.
7What are null pointers in C?
A7Null pointers in C are pointers that do not point to any valid memory address. They are typically used to indicate the absence of a meaningful value or to initialize pointers before assigning them valid addresses.
8What is pointer arithmetic in C?
A8Pointer arithmetic in C allows you to perform arithmetic operations, such as addition, subtraction, and comparison, on pointers. It is often used to navigate through arrays or dynamically allocated memory.
9What are function pointers in C?
A9Function pointers in C are pointers that store the memory address of functions. They can be used to indirectly call functions or to store different functions as values in data structures.
10How do you allocate and deallocate memory using malloc() and free() in C?
A10Memory allocation in C can be done using the malloc() function, which dynamically allocates a specified amount of memory, and deallocation is done using the free() function to release the allocated memory.
11What is the purpose of the const keyword with pointers in C?
A11The const keyword in C can be used with pointers to declare that the value pointed to by the pointer is constant and cannot be modified through that pointer. It allows for safer and more controlled usage of pointers.
12What are void pointers in C?
A12Void pointers in C are pointers that have no associated data type. They can be used to store addresses of objects of any type, but they require explicit typecasting before they can be dereferenced.
13What is the difference between pass by value and pass by reference in C?
A13Pass by value in C involves making a copy of the value being passed to a function, while pass by reference involves passing the address of the value to the function. Changes made to

Tips for a Successful Viva Examination

Preparing for a viva examination ( C Programming viva questions ) can be overwhelming, but with these tips, you can increase your chances of success:

  • Thoroughly revise the fundamentals : Ensure you have a strong grasp of basic C programming concepts, including data types, control statements, functions, arrays, strings, structures, and file handling.
  • Practice with sample questions : we provided you viva questions try to practice those.
  • Seek clarification : If you encounter doubts while preparing, don’t hesitate to seek clarification from your professors, friends, or online resources.
  • Stay calm and composed : During the viva, remain calm and composed. Take a moment to think before answering, and if you don’t know an answer, be honest and express your willingness to learn.

Congratulations! You have now gained a comprehensive understanding of  C programming viva questions . By preparing with this guide, you will be well-equipped to tackle your viva examination with confidence. Remember to revise the important topics, practice answering questions, and stay composed during the examination. With dedication and thorough preparation, you can excel in your viva and achieve the desired outcomes.

Now, go ahead and ace that viva examination! Best of luck!

References : https://www.w3schools.com/c/

Related Articles

Artificial intelligence viva questions with answers semester 5 mumbai university.

Artificial Intelligence Viva Questions with Answers semester 5 mumbai university Module 1: Introduction to Artificial Intelligence Question 1: What is Artificial Intelligence (AI)? Answer 1:…

Data Warehousing and Mining Viva Questions with Answers semester 5 mumbai university

Data Warehousing and Mining Viva Questions with Answers semester 5 mumbai university Module 1 : Data Warehouse and OLAP ( Data Warehousing and Mining )…

ML QuestionPaper Solution May 2023 – AI-DS/ML

ML QuestionPaper Solution May 2023 – AI-DS/ML Q.1 Solve any Four A. What is Machine Learning? What are the steps in developing a machine learning…

DAV Question Paper solution May 2023

download as an pdf : https://drive.google.com/file/d/1ii57ewWx1IrbSarEgfZ9M6cWz7-md59p/view?usp=sharing DAV Question Paper solution May 2023 , some of the answers have an link , if you know the…

DBMS Viva Questions and Answers SE – AI&DS/ML/CS/

DBMS or Database Management System is a crucial subject for second-year engineering students, providing the foundation for understanding database concepts and their practical applications. This…

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

Cancel reply

There was a problem reporting this post.

Block Member?

Please confirm you want to block this member.

You will no longer be able to:

  • See blocked member's posts
  • Mention this member in posts

Please allow a few minutes for this process to complete.

programming-point.com

C Programming Viva Questions Answers

If you are preparing for a C programming viva or interview, then you have reached the right place. In this article, a list of frequently asked C programming viva or interview questions and answers are given below. You will also get a mix of Basic to Advanced C programming viva or interview questions in this article. And before going ahead, if you want to know more about C programming, check out Introduction to C now?

C Programming Viva Questions Answer Download (PDF)

C programming viva questions answers part-1 #wpsm_accordion_565 .wpsm_panel-heading{ padding:0px important; } #wpsm_accordion_565 .wpsm_panel-title { margin:0px important; text-transform:none important; line-height: 1 important; } #wpsm_accordion_565 .wpsm_panel-title a{ text-decoration:none; overflow:hidden; display:block; padding:0px; font-size: 20px important; font-family: open sans important; color:#000000 important; border-bottom:0px important; } #wpsm_accordion_565 .wpsm_panel-title a:focus { outline: 0px important; } #wpsm_accordion_565 .wpsm_panel-title a:hover, #wpsm_accordion_565 .wpsm_panel-title a:focus { color:#000000 important; } #wpsm_accordion_565 .acc-a{ color: #000000 important; background-color:#e8e8e8 important; border-color: #ddd; } #wpsm_accordion_565 .wpsm_panel-default > .wpsm_panel-heading{ color: #000000 important; background-color: #e8e8e8 important; border-color: #e8e8e8 important; border-top-left-radius: 0px; border-top-right-radius: 0px; } #wpsm_accordion_565 .wpsm_panel-default { border:1px solid transparent important; } #wpsm_accordion_565 { margin-bottom: 20px; overflow: hidden; float: none; width: 100%; display: block; } #wpsm_accordion_565 .ac_title_class{ display: block; padding-top: 12px; padding-bottom: 12px; padding-left: 15px; padding-right: 15px; } #wpsm_accordion_565 .wpsm_panel { overflow:hidden; -webkit-box-shadow: 0 0px 0px rgba(0, 0, 0, .05); box-shadow: 0 0px 0px rgba(0, 0, 0, .05); border-radius: 4px; } #wpsm_accordion_565 .wpsm_panel + .wpsm_panel { margin-top: 5px; } #wpsm_accordion_565 .wpsm_panel-body{ background-color:#ffffff important; color:#000000 important; border-top-color: #e8e8e8 important; font-size:19px important; font-family: open sans important; overflow: hidden; border: 2px solid #e8e8e8 important; } #wpsm_accordion_565 .ac_open_cl_icon{ background-color:#e8e8e8 important; color: #000000 important; float:right important; padding-top: 12px important; padding-bottom: 12px important; line-height: 1.0 important; padding-left: 15px important; padding-right: 15px important; display: inline-block important; } 1. what is compiler, 2. what is interpreter, 3. what is assembler, 4. what is protocol, 5. what is ide in c, 6. what are instructions, 7. what is c programming language, 8. c language has been developed in which language, 9. what is the difference between text files and binary files, 10. is c a structured programming language, 11. c is successor of which programming language, 12. what is algorithm, 13. what is flowchart, 14. what are library functions, 15. what is a program, 16. what is object code, 17. what is executable code, 18. what is void in c language, 19. what is the meaning of header file name some header files., 20. can i create a customized header file in c language, 21. explain the use of comma operator (,)., 22. what is the use of printf() function, 23. what is the use of scanf() function, 24. what is console, 25. what is #include, more topics.

  • Convert Decimal to Binary Conversion
  • Write a C Program to Calculate Electricity Bill
  • Why Loops are used in C?
  • How to use Pivot Table in Excel?
  • Macro in Excel

So just feel confident during your viva interview and wish you the best of luck for your viva or interview. I hope these C questions and answers will help you to crack your exam easily.

Download our App for Study Materials and Placement Preparation 📝✅ | Click Here

Last Moment Tuitions

C programming Viva Questions

1. which type of language is c.

Ans- C is a high–level language and general-purpose structured programming language.

2. What is a compiler?

Ans- Compile is a software program that transfer program developed in a high-level language into executable object code.

3. What is an algorithm?

Ans- The approach or method that is used to solve the problem is called an algorithm.

4. What is a c token and types of c tokens?

Ans- The smallest individual units are known as C tokens. C has six types of tokens Keywords, Constants, Identifiers, Strings, Operators and Special symbols.

5. How many Keywords (reserve word)are in C?

Ans- There are 32 Keywords in the C language.

6. What is an identifier?

Ans- Identifiers are user-defined names given to variables, functions and arrays.

7. What are the Back Slash character constants or Escape sequence characters available in C?

Ans- Back Slash character constant are \t, \n, \0.

8. What is a variable?

Ans- Variables are user-defined names given to memory locations and are used to store values. A variable may have different values at different times during program execution.

9. What are the Data Types present in C?

Ans- Primary or Fundamental Data types (int, float, char), Derived Datatypes(arrays, pointers) and User-Defined data types(structures, unions, enum)

10. How to declare a variable?

Ans- The syntax for declaring variable isdata type variable_name-1, variable_name-2,….variable_name-n;

  • Example 1: int a, b;
  • Example 2: float p,q;

11.What is meant by initialization and how do we initialize a variable?

Ans- While declaring a variable assigning value is known as initialization. Variable can be initialized by using assignment operator (=).

12.How many types of operators or there in C?

Ans- C consist Arithmetic Operators (+, -, *, /,%), Relational Operators (<, <=, >, >=, !=), Logical Operators (&&, ||, !), Assignment Operators (=, +=, -=, *=, /=), Increment and Decrement Operators (++, –), Conditional Operator(?:), Bitwise Operators(<<, >>, ~, &, |, ^) and  Special Operators (. , ->, &, *, size of)

13. What is a Unary operator and what are the unary operators present in C?

Ans- An operator which takes only one operand is called a unary operator. C unary operators are Unary plus (+), Unary minus (-), Increment and Decrement operators (++,–), Address of operator (&), Value at operator (*), sizeof operator, ones complement operator (~)

14. What is the use of the modulus (%) operator?

Ans- The modulus operator produces the remainder of an integer division. It cannot be used on floating-point data

15. What is the use of printf and scanf functions in C?

Ans-Values of variables and results of expressions can be displayed on the screen using printf functions. Values to variables can be accepted through the keyboard using scanf function

16. Forms of IF statements?

Ans- Simple IF statement, IF-ELSE statement, NESTED IF-ELSE statement and ELSE IF ladder

17. Forms of IF statements?

18. what is a goto statement.

Ans- GOTO is an unconditional branching statement which transfers control to the specified label.

19. What is a loop?

Ans- Loop is a sequence of statements that runs repeatedly.

20. What are loop control statements in C?

Ans- While do-while and for.

21. What are sections present in for loop?

Ans- Initialization section, conditional section and increment/decrement section.

22. What is the use of break statements?

Ans- The break statement is used to exit from the loop.

23. What is an array?

Ans-The array is a collective name given to similar elements.

24. How can we initialize an array?

Ans- The initializer for an array is a comma-separated list of constant expressions enclosed in braces

 ( { } ). The initializer is preceded by an equal sign ( = ). You do not need to initialize all elements in an array.

25. What is the difference between normal variable and array variable?

Ans- A variable can store only one value at a time whereas an array variable can store several value at a time.

26. What are the types of Arrays?

Ans- A one-Dimensional array, Two-Dimensional array and Multi-Dimensional array

27. What is a character array?

Ans- An array which can store several characters is called character array

28. What is a function?

Ans- The function is a self-contained block of the statement which is used to perform a certain task

29. What are the types of functions?

Ans- C functions are divided into two categories user-defined function and built-in functions

30. Which are called built-in functions?

Ans- Printf, scanf, clrscr, gotoxy, string handling functions and file handling functions

31. What is a recursive function?

Ans- A function calling itself is called function recursion

32. How to pass an array to a function?

Ans- Arrays are passed to a function by sending its address

33. What is a pointer variable?

Ans- A pointer variable is a variable that can store the address of another variable

34. How can we store the address of a variable is a pointer?

Ans- By using the address of the operator we can store the address of a variable in a pointer

35. How many bytes does a pointer variable occupies in memory?

Ans- A pointer variable irrespective of its type it occupies two bytes in memory

36. What are storage classes available in C?

Ans- Auto, static, extern and register

37. What is a structure?

Ans- The structure is user-defined data typed. The structure is a collective name given to dissimilar elements

38. How to excess structure members?

Ans- Structure members can be accessed using the dot operator

39) What are the differences between structures and arrays?

Ans- Structures store dissimilar values whereas arrays stores similar values. One structure variable can be assigned to another structure variable whereas one array variable cannot be assigned to another array variable

40. What is the size of a structure?

Ans- Sum of all the members size is becomes structure size

41. What is a union?

Ans- Union is a user-defined data type that can store a value of different data types

42. What are the types of files we can create using C?

Ans-We can create text and binary files using C

43. What are the file-handling functions present in C?

Ans- fopen, fclose, fgetc, fputc, fgets, fputs, fprintf, fscanf, fread, fwrite, fseek

44. What are the file opening modes present in C?

Ans- r, w, a, r+, w+, a+, rb, wb, rb+, wb+

45. How to access structure members by their pointer?

Ans- We can use structure members using arrow operator with its pointer

46. What is the difference between normal variable and array variable?

47. how to declare a variable.

Ans- The syntax for declaring the variable is

Datatype variable_name-1,variable_name-2…variable_name-n

programming for problem solving viva questions and answers

Telegram Community!

Get All the Updates of Free Courses, Engineering Problem Solved, Study Tips, Placement Preparation and Motivation in the Community

programming for problem solving viva questions and answers

/ Youtube Channel: https://www.youtube.com/channel/UCGFNZxMqKLsqWERX_N2f08Q

Follow For Latest Updates, Study Tips & More Content!

programming for problem solving viva questions and answers

Login with your site account

Remember Me

Not a member yet? Register now

Register a new account

Are you a member? Login now

Code With C

The Way to Programming

  • C Tutorials
  • Java Tutorials
  • Python Tutorials
  • PHP Tutorials
  • Java Projects

200+ Interview Questions for C Programming – 2024

CodeWithC

You might think of C interview questions to be way more difficult compared to your general exam question papers. Yes, C interview questions are not easy to answer, but they are not that difficult too. Your confidence to answer such interview questions correctly depends on your knowledge level related to the question, and your ability to cope up with and analyze a new problem.

In this article, we will go through some commonly asked as well as interesting questions along with their answers to help students prepare for C interviews.

Attempts have been made to cover all parts of the language in the C interview questions presented in this post. I have included relevant, interesting and common questions/problems from C basics, operators, functions, arrays, pointers, data structures, and more. To provide students a clear concept of the problems, I have included source codes, additional explanations as well as images in some questions.

The most commonly asked or frequently asked C interview questions are like What is…..What is the difference between….Write a C program to…..Find the error in the source code given below….What is the output of the source code given below….etc. I have tried to include different types of questions from different chapters/topics of the C programming language.

The C interview questions here have been divided into 3 parts – frequently asked, interesting questions and other most common C questions. I have provided complete answers along with source codes in the first two parts; I have left the third part with questions only for your own practice.

200+ Frequently Asked C Interview Questions & Answers:

C Interview Questions

Q1. Mention the different storage classes in C.

This might be one of the most debated C interview questions; the answer to this question varies book by book, and site by site on the internet. Here, I would like to make it clear there are only two storage classes in C, and the rest are storage class specifiers.

As per reference manual of “The C Programming Language” by: Brian W. Kernighan and Dennis M. Ritchie, in the Appendix A of the reference manual, the very first line says: There are two storage classes: automatic and static . [ The C programing Language 2nd Edition,Brian W. Kernighan ,Dennis M. Ritchie ]

Q2. What are the different storage class specifiers in C?

There are 4 storage class specifiers in C, out of which auto and static act as storage classes as well. So, the storage class specifiers are:

Q3. What are library functions in C?

Library functions are the predefined functions in C, stored in .lib files.

Q4. Where are the auto variables stored?

Auto variables are stored in the main memory. The default value of auto variables is garbage value.

Q5. What is the difference between i++ and ++i?

One of the most commonly asked C interview questions or viva questions – i++ and ++i. The expression i++ returns the old value and then increases i by 1, whereas the expression ++i first increases the value of i by 1 and then returns the new value.

Q6. What is l-value in C? Mention its types.

Location value, commonly known as the l-value, refers to an expression used on the left side of an assignment operator. For example: in the expression “x = 5”, x is the l-value and 5 is the r-value.

There are two types of l-value in C – modifiable l-value and non-modifiable l-value. modifiable l-value denoted a l-value which can be modified. non-modifiable l-value denote a l-value which cannot be modified. const variables are non-modifiable l-value.

Q7. Can i++ and ++i be used as l-value in C?

In C both i++ and ++i cannot be used as l-value. Whereas in C++, ++i can be used as l-value, but i++ cannot be.

Q8. Which of the following shows the correct hierarchy of arithmetic operations in C?

(1) / + * – (2) * – / + (3) + – / * (4) * / + –

4 is the correct answer.

Q9. Which bit wise operator is suitable for

  • checking whether a particular bit is on or off? Ans. The bitwise AND operator.
  • turning off a particular bit in a number? Ans. The bitwise AND operator.
  • putting on a particular bit in a number? Ans. The bitwise OR operator.

Q10. Can a C program be written without using the main function?

This is one of the most interesting C interview questions. I guess, up until now, you might not have ever written a C program without using the main function. But, a program can be executed without the main function. See the example below:

Now, lets see what’s happening within the source code. Here, #define acts as the main function to some extent. We are basically using #define as a preprocessor directive  to give an impression that the source code executes without the main function.

Q11. What is the output of printf(“%d”); ?

For printf(“%d”, a); the compiler will print the corresponding value of a. But in this case, there is nothing after %d, so the compiler will show garbage value in output screen.

Q12. What is the difference between printf() and sprintf() ?

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

Q13. What is the difference between %d and %*d ?

Here, %d gives the original value of the variable, whereas %*d gives the address of the variable due to the use of pointer.

Q14. Which function – gets() or fgets(), is safe to use, and why?

Neither gets() nor fgets() is completely safe to use. When compared, fgets() is safe to use than gets() because with fgest() a maximum input length can be specified.

Q15. Write a C program to print “Programming is Fun” without using semicolon (;) .

Here’s a typical source code to print “Programming is Fun”.

There’s not much trick in printing the line without using the semicolon. Simply use the printf statement inside the if condition as shown below.

An extension of the above can be – write a C program to print “;” without using a semicolon.

Q16. What is the difference between pass by value and pass by reference?

This is another very important topic in this series of C interview questions. I will try to explain this in detail with source code and output.

Pass by Value:

This is the process of calling a function in which actual value of arguments are passed to call a function. Here, the values of actual arguments are copied to formal arguments, and as a result, the values of arguments in the calling function are unchanged even though they are changed in the called function. So, passing by value to function is restricted to one way transfer of information. The following example illustrates the mechanism of passing by value to function.

In this example, the values of x and y have been passed into the function and they have been swapped in the called function without any change in the calling function.

Pass by Reference:

In pass by reference, a function is called by passing the address of arguments instead of passing the actual value. In order to pass the address of an argument, it must be defined as a pointer. The following example illustrates the use of pass by reference.

In this example, addresses of x and y have been passed into the function, and their values are swapped in the called function. As a result of this, the values are swapped in calling function also.

Q17. Write a C program to swap two variables without using a third variable.

This is one of the very common C interview questions. It can be solved in a total of five steps. For this, I have considered two variables as a and b, such that a = 5 and b = 10.

Q18. When is a switch statement better than multiple if statements?

When two or more than two conditional expressions are based on a single variable of numeric type, a switch statement is generally preferred over multiple if statements.

Q19. Write a C program to print numbers from 1 to n without using loop.

Q20. What is the difference between declaration and definition of a function?

Declaration of a function in the source code simply indicates that the function is present somewhere in the program, but memory is not allocated for it. Declaration of a function helps the program understand the following:

  • what are the arguments to that function
  • their data types
  • the order of arguments in that function
  • the return type of the function

Definition of a function, on the other hand, acts like a super set of declaration. It not only takes up the role of declaration, but also allocates memory for that function.

Q21. What are static functions? What is their use in C?

In the C programming language, all functions are global by default. Therefore, to make a function static, the “static” keyword is used before the function. Unlike the global functions, access to static functions in C is restricted to the file where they are declared.

The use of static functions in C are:

  • to make a function static
  • to restrict access to functions
  • to reuse the same function name in other file

Q22. Mention the advantages and disadvantages of arrays in C.

Advantages:

  • Each element of array can be easily accessed.
  • Array elements are stored in continuous memory location.
  • With the use of arrays, too many variables need not be declared.
  • Arrays have a wide application in data structure.

Disadvantages:

  • Arrays store only similar type of data.
  • Arrays occupy and waste memory space.
  • The size of arrays cannot be changed at the run time.

Q23. What are array pointers in C?

Array whose content is the address of another variable is known as array pointer. Here’s an example illustrating array pointers in C.

Q24. How will you differentiate  char const* p and const char* p ?

In char const* p, the pointer ‘p’ is constant, but not the character referenced by it. Here, you cannot make ‘p’ refer to any other location, but you can change the value of the char pointed by ‘p’.

In const char* p, the character pointed by ‘p’ is constant. Here, unlike the upper case, you cannot change the value of character pointed by ‘p’, but you can make ‘p’ refer to any other location.

Q25. What is the size of void pointer in C?

Whether it’s char pointer, function pointer, null pointer, double pointer, void pointer or any other, the size of any type of pointer in C is of two byte. In C, the size of any pointer type is independent of data type.

Q26. What is the difference between dangling pointer and wild pointer?

Both these pointers don’t point to a particular valid location.

A pointer is called dangling if it was pointing to a valid location earlier, but now the location is invalid. This happens when a pointer is pointing at the memory address of a variable, but afterwards some variable has been deleted from that particular memory location, while the pointer is still pointing at that memory location. Such problems are commonly called dangling pointer problem and the output is garbage value.

Wild pointer too doesn’t point to any particular memory location. A pointer is called wild if it is not initialized at all. The output in this case is any address.

Q27. What is the difference between wild pointer and null pointer?

Wild pointer is such a pointer which doesn’t point to any specific memory location as it is not initialized at all. Whereas, null pointer is the one that points the base address of segment. Literally, null pointers point at nothing.

Q28. What is far pointer in C?

C Interview Questions - Far Pointer

Q29. What is FILE?

FILE is simply a predefined data type defined in stdio.h file.

Q30. What are the differences between Structure and Unions?

  • Every member in structure has its own memory, whereas the members in a union share the same member space.
  • Initialization of all the member at the same time is possible in structures but not in unions.
  • For the same type of member, a structure requires more space than a union.
  • Different interpretations of the same memory space is possible in union but not in structures.

Q31. Write a C program to find the size of structure without using sizeof operator?

Q32. What is the difference between .com program and .exe program?

Both these programs are executable programs, and all drivers are .com programs.

  • .com program executes faster than .exe program.
  • .com file has higher preference than .exe type.

Some Interesting C Interview Questions:

Interesting C Interview Questions

The execution depends on the amount machine instruction to carry out the operation in the expression. n++ requires only a single machine instruction, such as INR, to carry out the increment operation. On the other hand, n+1 requires more machine instructions to carry out this operation. Hence, n++ executes faster than n+1 in C.

2. Is int x; a declaration or a definition? What about int x = 3; and x = 3; ?

3. What is the parent of the main() function?

The parent of main() function is header files – the <stdio.h> header file.

4. Write a C program to print the next prime number for any number entered by the user.

5. Write a C program to solve the “Tower of Hanoi” question without using recursion.

Try this yourself.

6. Create an array of char type whose size is not known until its run, i.e., the size must be given by the user.

Hints are given in the source code below. If you want to use array finish, you must free it to return resources to memory.

Other Commonly Asked C Interview Questions:

These are some other commonly asked C interview questions or exam/viva questions. Try answering these on your own, and if you need help with any, mention them in the comments section at the end.

Expression – An expression is the combination of operands and operators.

  • What is the difference between declaration and definition of a variable?
  • Can static variables be declared in a header file?
  • Can a variable be both constant and volatile?
  • What are C identifiers?
  • Can include files in C be nested?
  • What are flag values?
  • Write the prototype of printf function.
  • What is the use of void data type in C?
  • What is the use of typedef in C?
  • Differentiate for loop and while loop.
  • Why is the main() function used in C?
  • What are macros? Mention their advantages and disadvantages.
  • Mention the advantages of a macro over a function.
  • What is function recursion in C?
  • What keyword is used to rename a function in C?
  • What is the difference between Calloc() and Malloc() ?
  • What is the difference between strings and character arrays?
  • What are the differences between sizeof operator and strlen function?
  • Differentiate between static memory allocation and dynamic memory allocation.
  • What are the uses of pointers in C?
  • What is a null pointer assignment error?
  • What are enumerations?
  • Mention the advantages of using unions in C.
  • Differentiate a linker and linkage.
  • What is the difference between C++ and C programming?
  • What are the advantages of C programming?
  • What are the disadvantages of C programming?
  • Give an example of error handling in C programming.
  • How do you write a program in C?
  • What is the difference between C and C++ programming?
  • What is the use of C++?
  • Give an example of polymorphism in C++.
  • What is the difference between object-oriented and procedural programming?
  • What are the different memory models?
  • What is the difference between static and dynamic linking?
  • Explain the use of pointer.
  • What is the difference between a variable and a constant?
  • Explain the scope of variables.
  • What is a statement?
  • Explain the difference between goto and break statements?
  • What is the difference between the forward and backward jump statements?
  • How do you declare an integer variable?
  • Define what a loop is?
  • What is the difference between while and for loops?
  • What is the difference between a conditional and a loop?
  • Define what an array is?
  • Explain the use of malloc and free functions.
  • What are the types of data structures?
  • What are the different data types in C?
  • What is the difference between a data structure and a variable?
  • What is the difference between a character and a string?
  • Define the difference between a pointer and an array.
  • Define the difference between a linked list and a queue.
  • Define the difference between a stack and a heap.
  • Define the difference between a stack and a queue.
  • What is the difference between char and character?
  • What is the difference between signed and unsigned integer types?
  • What is the difference between byte and word types?
  • What is the difference between pointer and array types?
  • What is the difference between float, double, and long integer types?
  • How to declare and use variables?
  • What is the difference between integer and real types?
  • What is the difference between structure and union types?
  • What is the difference between arrays and pointers?
  • What is the difference between functions and subroutines?
  • What are the return values of functions?
  • What is the difference between switch and if statement?
  • What are the differences between for loop and while loop?
  • What is the difference between goto and break statements?
  • What is the difference between enum and typedef?
  • What are the differences between const and volatile?
  • What is the difference between inline and static?
  • What is the difference between static and volatile?
  • What is the difference between static and extern?
  • What is the difference between extern and static?
  • What is the difference between static and global?
  • What are the differences between typedef, enum, union, and struct?
  • What is the difference between char, int, float, and long?
  • What is the difference between void and int?
  • What is the difference between void and char?
  • What are the differences between union and struct types?
  • What are the differences between function and procedure types?
  • What is the difference between void and return types?
  • What is the difference between class and interface types?
  • What is the difference between pointers and arrays?
  • What is the difference between arrays and references?
  •  What is the difference between arrays and pointers?

So, what do you think of the C interview questions mentioned here? Did you find them new, difficult, interesting or boring: we would like to hear your feedback. Also, you can suggest us more interview questions that would suit this post.

You Might Also Like

Program c: building foundations with the c language, s in c programming: understanding string manipulation, program with c: starting your journey in c programming, c programming language: the foundation of system software, programs c language: creating efficient solutions.

C++ project

Nice article, I was searching for something like this i was browsing the net since ours but dint find exact question and answers which justifies the question your article is the best and have all the important questions include in it.

program to swap two variables without using a third variable doesn’t work in code blocks?

int main() { int a, b; scanf(“%d%d”,&a,&b); a=a+b; b=a-b; a=a-b; printf(“\n After swap a=%d b=%d”,a,b); return 0; }

Q: How we use graphics in C ?

Too nyc will help to upcoming students who are searching jobs

Which c programs are may ask in national c code writing competitions

Q:- Which program is used to convert object code into source code in c/c++? plz help me

I sort of get this question as — how does a source code become a program? Are you asking how does a source code get converted into object code?

If yes, the answer is compiler. Source code is turned into object code by a compiler. Then, once the object code is passed through a linker, an executable program comes into existence.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Latest Posts

62 Creating a Google Sheet to Track Google Drive Files: Step-by-Step Guide

Creating a Google Sheet to Track Google Drive Files: Step-by-Step Guide

codewithc 61 Cutting-Edge Artificial Intelligence Project Unveiled in Machine Learning World

Cutting-Edge Artificial Intelligence Project Unveiled in Machine Learning World

75 Enhancing Exams with Image Processing: E-Assessment Project

Enhancing Exams with Image Processing: E-Assessment Project

73 Cutting-Edge Blockchain Projects for Cryptocurrency Enthusiasts - Project

Cutting-Edge Blockchain Projects for Cryptocurrency Enthusiasts – Project

67 Artificial Intelligence Marvel: Cutting-Edge Machine Learning Project

Artificial Intelligence Marvel: Cutting-Edge Machine Learning Project

Privacy overview.

en_US

Sign in to your account

Username or Email Address

Remember Me

  • Multimedia CBSE Class 9 and 10 | March 1, 2023
  • Computer networking CBSE Class 9 and 10 | March 1, 2023
  • Types of software CBSE Class 9 and 10 | March 1, 2023
  • I/O devices CBSE Class 9 and 10 | March 1, 2023
  • Storage devices CBSE Class 9 and 10 | March 1, 2023
  • Memory CBSE Class 9 and 10 | March 1, 2023
  • Computer Systems – CBSE Class 9 and 10 | March 1, 2023
  • Merge String Characters Program in Java | May 26, 2022
  • Name with A Program in Java | May 26, 2022
  • Reversed Case of Char Array Program in Java | May 26, 2022
  • Product and Square of Array Program in Java | May 26, 2022
  • Find Highest and Lowest ASCII value Program in Java | May 26, 2022
  • UP Board Math Class 7th Chapter 6 - रेखीय समीकरण | April 13, 2022
  • UP Board Math Class 7th Chapter 3 - साँख्यिकी | April 13, 2022
  • UP Board Math Class 7th Chapter 2 - घातांक | April 13, 2022
  • Bubble Sort in String Program in Java | April 4, 2022
  • Palindrome String | April 4, 2022
  • Piglatin Form Program in Java | April 4, 2022
  • Find Vowels And Capital Letter in Array Program in Java | April 4, 2022
  • Find Positive and Negative Numbers in Array Program in Java | April 4, 2022

C Language or C Programming Viva Questions

1- what is c language.

C is a mid-level and procedural programming language. The Procedural programming language is also known as the structured programming language is a technique in which large programs are broken down into smaller modules, and each module uses structured code. This technique minimizes error and misinterpretation.

2- Why is C known as a mother language?

C is known as a mother language because most of the compilers and JVMs are written in C language. Most of the languages which are developed after C language has borrowed heavily from it like C++, Python, Rust, javascript, etc. It introduces new core concepts like arrays, functions, file handling which are used in these languages.

3- Why is C called a mid-level programming language?

C is called a mid-level programming language because it binds the low level and high -level programming language. We can use C language as a System programming to develop the operating system as well as an Application programming to generate menu driven customer driven billing system.

4- Who is the founder of C language?

Dennis Ritchie.

5- When was C language developed?

C language was developed in 1972 at bell laboratories of AT&T.

6- What are the features of the C language?

The main features of C language are given below:

  • Simple: C is a simple language because it follows the structured approach, i.e., a program is broken into parts
  • Portable: C is highly portable means that once the program is written can be run on any machine with little or no modifications.
  • Mid Level: C is a mid-level programming language as it combines the low- level language with the features of the high-level language.
  • Structured: C is a structured language as the C program is broken into parts.
  • Fast Speed: C language is very fast as it uses a powerful set of data types and operators.
  • Memory Management: C provides an inbuilt memory function that saves the memory and improves the efficiency of our program.
  • Extensible: C is an extensible language as it can adopt new features in the future.

7- What is the use of printf() and scanf() functions?

printf(): The printf() function is used to print the integer, character, float and string values on to the screen.

Following are the format specifier:

  • %d : It is a format specifier used to print an integer value.
  • %s : It is a format specifier used to print a string.
  • %c : It is a format specifier used to display a character value.
  • %f : It is a format specifier used to display a floating point value.

scanf() : The scanf() function is used to take input from the user.

8- What is the difference between the local variable and global variable in C?

Following are the differences between a local variable and global variable:

Basis for comparisonLocal variableGlobal variable
DeclarationA variable which is declared inside function or block is known as a local variable.A variable which is declared outside function or block is known as a global variable.
ScopeThe scope of a variable is available within a function in which they are declared.The scope of a variable is available throughout the program.
AccessVariables can be accessed only by those statements inside a function in which they are declared.Any statement in the entire program can access variables.
LifeLife of a variable is created when the function block is entered and destroyed on its exit.Life of a variable exists until the program is executing.
StorageVariables are stored in a stack unless specified.The compiler decides the storage location of a variable.

9- What is the use of a static variable in C?

Following are the uses of a static variable:

  • A variable which is declared as static is known as a static variable. The static variable retains its value between multiple function calls.
  • Static variables are used because the scope of the static variable is available in the entire program. So, we can access a static variable anywhere in the program.
  • The static variable is initially initialized to zero. If we update the value of a variable, then the updated value is assigned.
  • The static variable is used as a common value which is shared by all the methods.
  • The static variable is initialized only once in the memory heap to reduce the memory usage.

10- What is the use of the function in C?

Uses of C function are:

  • C functions are used to avoid the rewriting the same code again and again in our program.
  • C functions can be called any number of times from any place of our program.
  • When a program is divided into functions, then any part of our program can easily be tracked.
  • C functions provide the reusability concept, i.e., it breaks the big task into smaller tasks so that it makes the C program more understandable.

11- What is the difference between call by value and call by reference in C?

Following are the differences between a call by value and call by reference are:

Call by valueCall by reference
DescriptionWhen a copy of the value is passed to the function, then the original value is not modified.When a copy of the value is passed to the function, then the original value is modified.
Memory locationActual arguments and formal arguments are created in separate memory locations.Actual arguments and formal arguments are created in the same memory location.
SafetyIn this case, actual arguments remain safe as they cannot be modified.In this case, actual arguments are not reliable, as they are modified.
ArgumentsThe copies of the actual arguments are passed to the formal arguments.The addresses of actual arguments are passed to their respective formal arguments.

Example of call by value:

  • #include <stdio.h>   
  • void  change( int , int );  
  • int  main()  
  • {  
  •      int  a=10,b=20;  
  •     change(a,b);  //calling a function by passing the values of variables.   
  •     printf( “Value of a is: %d” ,a);  
  •     printf( “\n” );  
  •     printf( “Value of b is: %d” ,b);  
  •      return  0;  
  • }  
  • void  change( int  x, int  y)  
  •     x=13;  
  •     y=17;  

Example of call by reference:

  • void  change( int *, int *);  
  •     change(&a,&b);  // calling a function by passing references of variables.   
  • void  change( int  *x, int  *y)  
  •     *x=13;  
  •     *y=17;  

12- What is recursion in C?

When a function calls itself, and this process is known as recursion. The function that calls itself is known as a recursive function.

Recursive function comes in two phases:

  • Winding phase
  • Unwinding phase

Winding phase : When the recursive function calls itself, and this phase ends when the condition is reached.

Unwinding phase : Unwinding phase starts when the condition is reached, and the control returns to the original call.

Example of recursion

  • int  calculate_fact( int );  
  •   int  n=5,f;  
  •  f=calculate_fact(n);  // calling a function   
  •  printf( “factorial of a number is %d” ,f);  
  •    return  0;  
  • int  calculate_fact( int  a)  
  •    if (a==1)  
  •   {  
  •        return  1;  
  •   }  
  •    else   
  •    return  a*calculate_fact(a-1);  //calling a function recursively.   
  •    }  

13- What is an array in C?

An Array is a group of similar types of elements. It has a contiguous memory location. It makes the code optimized, easy to traverse and easy to sort. The size and type of arrays cannot be changed after its declaration.

Arrays are of two types:

  • One-dimensional array : One-dimensional array is an array that stores the elements one after the another.
  • data_type array_name[size];  
  • Multidimensional array : Multidimensional array is an array that contains more than one array.

Example of an array:

  •     int  arr[5]={1,2,3,4,5};  //an array consists of five integer values.   
  •     for ( int  i=0;i<5;i++)  
  •    {  
  •        printf( “%d “ ,arr[i]);  

14- What is a pointer in C?

A pointer is a variable that refers to the address of a value. It makes the code optimized and makes the performance fast. Whenever a variable is declared inside a program, then the system allocates some memory to a variable. The memory contains some address number. The variables that hold this address number is known as the pointer variable.

For example:

  • Data_type *p;  

The above syntax tells that p is a pointer variable that holds the address number of a given data type value.

Example of pointer

  •     int  *p;  //pointer of type integer.   
  •     int  a=5;  
  •    p=&a;  
  •    printf( “Address value of ‘a’ variable is %u” ,p);  

15- What is the usage of the pointer in C?

  • Accessing array elements : Pointers are used in traversing through an array of integers and strings. The string is an array of characters which is terminated by a null character ‘\0’.
  • Dynamic memory allocation : Pointers are used in allocation and deallocation of memory during the execution of a program.
  • Call by Reference : The pointers are used to pass a reference of a variable to other function.
  • Data Structures like a tree, graph, linked list, etc. : The pointers are used to construct different data structures like tree, graph, linked list, etc.

16- What is a NULL pointer in C?

A pointer that doesn’t refer to any address of value but NULL is known as a NULL pointer. When we assign a ‘0’ value to a pointer of any type, then it becomes a Null pointer.

17- What is a far pointer in C?

A pointer which can access all the 16 segments (whole residence memory) of RAM is known as far pointer. A far pointer is a 32-bit pointer that obtains information outside the memory in a given section.

18- What is dangling pointer in C?

  • If a pointer is pointing any memory location, but meanwhile another pointer deletes the memory occupied by the first pointer while the first pointer still points to that memory location, the first pointer will be known as a dangling pointer. This problem is known as a dangling pointer problem.
  • Dangling pointer arises when an object is deleted without modifying the value of the pointer. The pointer points to the deallocated memory.

Let’s see this through an example.

  • #include<stdio.h>   
  • void  main()  
  •          int  *ptr = malloc(constant value);  //allocating a memory space.   
  •         free(ptr);  //ptr becomes a dangling pointer.   

In the above example, initially memory is allocated to the pointer variable ptr, and then the memory is deallocated from the pointer variable. Now, pointer variable, i.e., ptr becomes a dangling pointer.

How to overcome the problem of a dangling pointer

The problem of a dangling pointer can be overcome by assigning a NULL value to the dangling pointer. Let’s understand this through an example:

  •        void  main()  
  •       {  
  •                int  *ptr = malloc(constant value);  //allocating a memory space.   
  •               free(ptr);  //ptr becomes a dangling pointer.   
  •               ptr=NULL;  //Now, ptr is no longer a dangling pointer.   
  •       }  

In the above example, after deallocating the memory from a pointer variable, ptr is assigned to a NULL value. This means that ptr does not point to any memory location. Therefore, it is no longer a dangling pointer.

19- What is pointer to pointer in C?

In case of a pointer to pointer concept, one pointer refers to the address of another pointer. The pointer to pointer is a chain of pointers. Generally, the pointer contains the address of a variable. The pointer to pointer contains the address of a first pointer. Let’s understand this concept through an example:

  •   int  main()  
  •      int  a=10;  
  •      int  *ptr,**pptr;  // *ptr is a pointer and **pptr is a double pointer.   
  •     ptr=&a;  
  •     pptr=&ptr;  
  •     printf( “value of a is:%d” ,a);  
  •     printf( “value of *ptr is : %d” ,*ptr);  
  •     printf( “value of **pptr is : %d” ,**pptr);  

In the above example, pptr is a double pointer pointing to the address of the ptr variable and ptr points to the address of ‘a’ variable.

20- What is static memory allocation?

  • 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 the array.
  • The lifetime of a variable in static memory is the lifetime of a program.
  • The static memory is allocated using static keyword.
  • The static memory is implemented using stacks or heap.
  • The pointer is required to access the variable present in the static memory.
  • The static memory is faster than dynamic memory.
  • In static memory, more memory space is required to store the variable.
  • For example:  
  • int  a[10];  

The above example creates an array of integer type, and the size of an array is fixed, i.e., 10.

21- What is dynamic memory allocation?

  • In case of dynamic memory allocation, memory is allocated at runtime and memory can be increased while executing the program. It is used in the linked list.
  • The malloc() or calloc() function is required to allocate the memory at the runtime.
  • An allocation or deallocation of memory is done at the execution time of a program.
  • No dynamic pointers are required to access the memory.
  • The dynamic memory is implemented using data segments.
  • Less memory space is required to store the variable.
  • For example  
  • int  *p= malloc( sizeof ( int )*10);  

The above example allocates the memory at runtime.

22- What functions are used for dynamic memory allocation in C language?

  • The malloc() function is used to allocate the memory during the execution of the program.
  • It does not initialize the memory but carries the garbage value.
  • It returns a null pointer if it could not be able to allocate the requested space.
  • ptr = (cast-type*) malloc(byte-size)  // allocating the memory using malloc() function.   
  • The calloc() is same as malloc() function, but the difference only is that it initializes the memory with zero value.
  • ptr = (cast-type*)calloc(n, element-size); // allocating the memory using calloc() function.   
  • The realloc() function is used to reallocate the memory to the new size.
  • If sufficient space is not available in the memory, then the new block is allocated to accommodate the existing data.
  • ptr = realloc(ptr, newsize);  // updating the memory size using realloc() function.   

In the above syntax, ptr is allocated to a new size.

  • free():The free() function releases the memory allocated by either calloc() or malloc() function.
  • free(ptr);  // memory is released using free() function.   

The above syntax releases the memory from a pointer variable ptr.

23- What is the difference between malloc() and calloc()?

calloc()malloc()
DescriptionThe malloc() function allocates a single block of requested memory.The calloc() function allocates multiple blocks of requested memory.
InitializationIt initializes the content of the memory to zero.It does not initialize the content of memory, so it carries the garbage value.
Number of argumentsIt consists of two arguments.It consists of only one argument.
Return valueIt returns a pointer pointing to the allocated memory.It returns a pointer pointing to the allocated memory.

24- What is the structure?

  • The structure is a user-defined data type that allows storing multiple types of data in a single unit. It occupies the sum of the memory of all members.
  • The structure members can be accessed only through structure variables.
  • Structure variables accessing the same structure but the memory allocated for each variable will be different.

Syntax of structure

  • struct  structure_name  
  •   Member_variable1;  
  •  Member_variable2  
  • .  
  • }[structure variables];  

Let’s see a simple example.

  • struct  student  
  •      char  name[10];        // structure members declaration.   
  •      int  age;  
  • }s1;       //structure variable   
  •     printf( “Enter the name” );  
  •     scanf( “%s” ,s1.name);  
  •     printf( “Enter the age” );  
  •     scanf( “%d” ,&s1.age);  
  •     printf( “Name and age of a student: %s,%d” ,s1.name,s1.age);  

25- What is a union?

  • The union is a user-defined data type that allows storing multiple types of data in a single unit. However, it doesn’t occupy the sum of the memory of all members. It holds the memory of the largest member only.
  • In union, we can access only one variable at a time as it allocates one common space for all the members of a union.

Syntax of union

  • union  union_name  
  • Member_variable1;  
  • Member_variable2;  
  • Member_variable n;  
  • }[ union  variables];  

Let’s see a simple example

  • #include<stdio.h>  
  • union data  
  •      int  a;       //union members declaration.   
  •      float  b;  
  •      char  ch;  
  • };  
  •   union data d;        //union variable.   
  •   d.a= 3 ;  
  •   d.b= 5.6 ;  
  •   d.ch= ‘a’ ;  
  •   printf( “value of a is %d” ,d.a);  
  •   printf( “\n” );  
  •   printf( “value of b is %f” ,d.b);  
  •   printf( “value of ch is %c” ,d.ch);  
  •    return   0 ;  

In the above example, the value of a and b gets corrupted, and only variable ch shows the actual output. This is because all the members of a union share the common memory space. Hence, the variable ch whose value is currently updated.

26- What is an 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.

27- What is the purpose of sprintf() function?

The sprintf() stands for “string print.” The sprintf() function does not print the output on the console screen. It transfers the data to the buffer. It returns the total number of characters present in the string.

  • int  sprintf (  char  * str,  const   char  * format, … );  
  •  #include<stdio.h>   
  •   char  a[20];  
  •   int  n=sprintf(a, “javaToint” );  
  •  printf( “value of n is %d” ,n);  
  •   return  0;}  

28- Can we compile a program without main() function?

Yes, we can compile, but it can’t be executed.

But, if we use #define, we can compile and run a C program without using the main() function. For example:

  • #include<stdio.h>     
  • #define start main     
  • void  start() {    
  •    printf( “Hello” );    
  • }    

29- What is a token?

The Token is an identifier. It can be constant, keyword, string literal, etc. A token is the smallest individual unit in a program. C has the following tokens:

  • Identifiers: Identifiers refer to the name of the variables.
  • Keywords: Keywords are the predefined words that are explained by the compiler.
  • Constants: Constants are the fixed values that cannot be changed during the execution of a program.
  • Operators: An operator is a symbol that performs the particular operation.
  • Special characters: All the characters except alphabets and digits are treated as special characters.

30- What is command line argument?

The argument passed to the main() function while executing the program is known as command line argument. For example:

  • main( int  count,  char  *args[]){  
  • //code to  be executed   

31- What is the acronym for ANSI?

The ANSI stands for ” American National Standard Institute.” It is an organization that maintains the broad range of disciplines including photographic film, computer languages, data encoding, mechanical parts, safety and more.

32- What is the difference between getch() and getche()?

The getch() function reads a single character from the keyboard. It doesn’t use any buffer, so entered data will not be displayed on the output screen.

The getche() function reads a single character from the keyword, but data is displayed on the output screen. Press Alt+f5 to see the entered character.

  • #include<conio.h>   
  •       
  •   char  ch;  
  •  printf( “Enter a character “ );  
  •  ch=getch();  // taking an user input without printing the value.   
  •  printf( “\nvalue of ch is %c” ,ch);  
  •  printf( “\nEnter a character again “ );  
  •  ch=getche();  // taking an user input and then displaying it on the screen.   
  •   printf( “\nvalue of ch is %c” ,ch);  
  •   return  0;  

#include<stdio.h> #include<conio.h> int main() {

In the above example, the value entered through a getch() function is not displayed on the screen while the value entered through a getche() function is displayed on the screen.

33- What is the newline escape sequence?

The new line escape sequence is represented by “\n”. It inserts a new line on the output screen.

34- Who is the main contributor in designing the C language after Dennis Ritchie?

Brain Kernighan.

35- What is the difference between near, far and huge pointers?

A virtual address is composed of the selector and offset .

A near pointer doesn’t have explicit selector whereas far, and huge pointers have explicit selector. When you perform pointer arithmetic on the far pointer, the selector is not modified, but in case of a huge pointer, it can be modified.

These are the non-standard keywords and implementation specific. These are irrelevant in a modern platform.

36- What is the maximum length of an identifier?

It is 32 characters ideally but implementation specific.

37- What is typecasting?

The 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.

  • (type_name) expression;  

38- What are the functions to open and close the file in C language?

The fopen() function is used to open file whereas fclose() is used to close file.

39- Can we access the array using a pointer in C language?

Yes, by holding the base address of array into a pointer, we can access the array using a pointer.

40- What is an infinite loop?

A loop running continuously for an indefinite number of times is called the infinite loop.

Infinite For Loop:

  • for (;;){  
  • //code to be executed   

Infinite While Loop:

  • while (1){  

Infinite Do-While Loop:

  • do {  
  • } while (1);  

41- 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.   
  • }     

42- Write a program to swap two numbers without using the third variable?

  • #include<conio.h>       
  • main()      
  • {      
  • int  a=10, b=20;     //declaration of variables.   
  • clrscr();         //It clears the screen.   
  • printf( “Before swap a=%d b=%d” ,a,b);        
  • a=a+b; //a=30 (10+20)        
  • b=a-b; //b=10 (30-20)       
  • a=a-b; //a=20 (30-10)       
  • printf( “\nAfter swap a=%d b=%d” ,a,b);      
  • getch();      

#include<stdio.h> #include<conio.h> main() { int a=10, b=20; //declaration of variables. clrscr(); //It clears the screen. printf(“Before swap a=%d b=%d”,a,b);

a=a+b;//a=30 (10+20) b=a-b;//b=10 (30-20) a=a-b;//a=20 (30-10)

43- Write a program to print Fibonacci series without using recursion?

  • #include<conio.h>     
  • void  main()    
  • {    
  •   int  n1=0,n2=1,n3,i,number;    
  •  clrscr();    
  •  printf( “Enter the number of elements:” );    
  •  scanf( “%d” ,&number);    
  •  printf( “\n%d %d” ,n1,n2); //printing 0 and 1     
  •     
  •   for (i=2;i<number;++i) //loop starts from 2 because 0 and 1 are already printed     
  •  {    
  •   n3=n1+n2;    
  •   printf( ” %d” ,n3);    
  •   n1=n2;    
  •   n2=n3;    
  •  }    
  • getch();    

#include<stdio.h> #include<conio.h> void main() { int n1=0,n2=1,n3,i,number; clrscr(); printf(“Enter the number of elements:”); scanf(“%d”,&number); printf(“\n%d %d”,n1,n2);//printing 0 and 1

44- Write a program to print Fibonacci series using recursion?

  • void  printFibonacci( int  n)  // function to calculate the fibonacci series of a given number.   
  • 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 recursively.   
  •     }      
  • }      
  •      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();      

45- Write a program to check prime number in C Programming?

  • void  main()      
  • int  n,i,m=0,flag=0;     //declaration of variables.   
  • clrscr();     //It clears the screen.   
  • printf( “Enter the number to check prime:” );      
  • scanf( “%d” ,&n);      
  • m=n/2;      
  • for (i=2;i<=m;i++)      
  • if (n%i==0)      
  • printf( “Number is not prime” );      
  • flag=1;      
  • break ;     //break keyword used to terminate from the loop.   
  • if (flag==0)      
  • printf( “Number is prime” );      
  • getch();     //It reads a character from the keyword.   

46- Write a program to check palindrome number in C Programming?

  • main()    
  • int  n,r,sum=0,temp;    
  • clrscr();    
  • printf( “enter the number=” );    
  • scanf( “%d” ,&n);    
  • temp=n;    
  • while (n>0)    
  • r=n%10;    
  • sum=(sum*10)+r;    
  • n=n/10;    
  • if (temp==sum)    
  • printf( “palindrome number “ );    
  • else     
  • printf( “not palindrome” );    

47- Write a program to print factorial of given number without using recursion?

  • void  main(){    
  •    int  i,fact=1,number;    
  •   clrscr();    
  •   printf( “Enter a number: “ );    
  •   scanf( “%d” ,&number);    
  •    for (i=1;i<=number;i++){    
  •       fact=fact*i;    
  •   }    
  •   printf( “Factorial of %d is: %d” ,number,fact);    
  •   getch();    

#include<stdio.h> #include<conio.h> void main(){ int i,fact=1,number; clrscr(); printf(“Enter a number: “); scanf(“%d”,&number);

48- Write a program to print factorial of given number using recursion?

  •   long  factorial( int  n)     // function to calculate the factorial of a given number.    
  •    if  (n == 0)      
  •      return  1;      
  • else       
  • return (n * factorial(n-1));     //calling the function recursively.   
  •   void  main()      
  •    int  number;     //declaration of variables.   
  •    long  fact;      
  •  clrscr();      
  •   printf( “Enter a number: “ );      
  • scanf( “%d” , &number);       
  •  fact = factorial(number);     //calling a function.   
  • printf( “Factorial of %d is %ld\n” , number, fact);      
  •  getch();    //It reads a character from the keyword.    

49- Write a program to check Armstrong number in C?

  • int  n,r,sum=0,temp;     //declaration of variables.   
  • clrscr();  //It clears the screen.      
  • printf( “enter the number=” );      
  • temp=n;      
  • while (n>0)      
  • r=n%10;      
  • sum=sum+(r*r*r);      
  • n=n/10;      
  • if (temp==sum)      
  • printf( “armstrong  number “ );      
  • printf( “not armstrong number” );      
  • getch();   //It reads a character from the keyword.   

50- Write a program to reverse a given number in C?

  • int  n, reverse=0, rem;     //declaration of variables.   
  • clrscr();  // It clears the screen.      
  • printf( “Enter a number: “ );      
  • scanf( “%d” , &n);      
  • while (n!=0)      
  •      rem=n%10;      
  •      reverse=reverse*10+rem;      
  •      n/=10;      
  • printf( “Reversed Number: %d” ,reverse);      
  • getch();   // It reads a character from the keyword.     

Guru99

Top 100 C Programming Interview Questions and Answers (PDF)

George McGovern

Here are C Programming interview questions and answers for fresher as well as experienced candidates to get their dream job.

Basic C Programming Interview Questions and Answers for Freshers

1) how do you construct an increment statement or decrement statement in c.

There are actually two ways you can do this. One is to use the increment operator ++ and decrement operator –. For example, the statement “x++” means to increment the value of x by 1. Likewise, the statement “x –” means to decrement the value of x by 1. Another way of writing increment statements is to use the conventional + plus sign or – minus sign. In the case of “x++”, another way to write it is “x = x +1”.

👉 Free PDF Download: C Programming Interview Questions & Answers >>

2) What is the difference between Call by Value and Call by Reference?

When using Call by Value, you are sending the value of a variable as parameter to a function, whereas Call by Reference sends the address of the variable. Also, under Call by Value, the value in the parameter is not affected by whatever operation that takes place, while in the case of Call by Reference, values can be affected by the process within the function.

C Programming Interview Question And Answers

3) Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

Placing comment symbols /* */ around a code, also referred to as “commenting out”, is a way of isolating some codes that you think maybe causing errors in the program, without deleting the code. The idea is that if the code is in fact correct, you simply remove the comment symbols and continue on. It also saves you time and effort on having to retype the codes if you have deleted it in the first place.

4) What is the equivalent code of the following statement in WHILE LOOP format?

5) what is a stack.

A stack is one form of a data structure. Data is stored in stacks using the FILO (First In Last Out) approach. At any particular instance, only the top of the stack is accessible, which means that in order to retrieve data that is stored inside the stack, those on the upper part should be extracted first. Storing data in a stack is also referred to as a PUSH, while data retrieval is referred to as a POP.

6) What is a sequential access file?

When writing programs that will store and retrieve data in a file, it is possible to designate that file into different forms. A sequential access file is such that data are saved in sequential order: one data is placed into the file after another. To access a particular data within the sequential access file, data has to be read one data at a time, until the right one is reached.

7) What is variable initialization and why is it important?

This refers to the process wherein a variable is assigned an initial value before it is used in the program. Without initialization, a variable would have an unknown value, which can lead to unpredictable outputs when used in computations or other operations.

8 What is spaghetti programming?

Spaghetti programming refers to codes that tend to get tangled and overlapped throughout the program. This unstructured approach to coding is usually attributed to lack of experience on the part of the programmer. Spaghetti programing makes a program complex and analyzing the codes difficult, and so must be avoided as much as possible.

9) Differentiate Source Codes from Object Codes

Source codes are codes that were written by the programmer. It is made up of the commands and other English-like keywords that are supposed to instruct the computer what to do. However, computers would not be able to understand source codes. Therefore, source codes are compiled using a compiler. The resulting outputs are object codes, which are in a format that can be understood by the computer processor. In C programming , source codes are saved with the file extension .C, while object codes are saved with the file extension .OBJ

10) In C programming, how do you insert quote characters (‘ and “) into the output screen?

This is a common problem for beginners because quotes are normally part of a printf statement. To insert the quote character as part of the output, use the format specifiers \’ (for single quote), and \” (for double quote).

11) What is the use of a ‘\0’ character?

It is referred to as a terminating null character, and is used primarily to show the end of a string value.

12) What is the difference between the = symbol and == symbol?

The = symbol is often used in mathematical operations. It is used to assign a value to a given variable. On the other hand, the == symbol, also known as “equal to” or “equivalent to”, is a relational operator that is used to compare two values.

13) What is the modulus operator?

The modulus operator outputs the remainder of a division. It makes use of the percentage (%) symbol. For example: 10 % 3 = 1, meaning when you divide 10 by 3, the remainder is 1.

14) What is a nested loop?

A nested loop is a loop that runs within another loop. Put it in another sense, you have an inner loop that is inside an outer loop. In this scenario, the inner loop is performed a number of times as specified by the outer loop. For each turn on the outer loop, the inner loop is first performed.

15) Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

<> is incorrect. While this operator is correctly interpreted as “not equal to” in writing conditional statements, it is not the proper operator to be used in C programming . Instead, the operator != must be used to indicate “not equal to” condition.

16) Compare and contrast compilers from interpreters.

Compilers and interpreters often deal with how program codes are executed. Interpreters execute program codes one line at a time, while compilers take the program as a whole and convert it into object code, before executing it. The key difference here is that in the case of interpreters, a program may encounter syntax errors in the middle of execution, and will stop from there. On the other hand, compilers check the syntax of the entire program and will only proceed to execution when no syntax errors are found.

17) How do you declare a variable that will hold string values?

The char keyword can only hold 1 character value at a time. By creating an array of characters, you can store string values in it. Example: “char MyName[50]; ” declares a string variable named MyName that can hold a maximum of 50 characters.

18) Can the curly brackets { } be used to enclose a single line of code?

While curly brackets are mainly used to group several lines of codes, it will still work without error if you used it for a single line. Some programmers prefer this method as a way of organizing codes to make it look clearer, especially in conditional statements.

19) What are header files and what are its uses in C programming?

Header files are also known as library files. They contain two essential things: the definitions and prototypes of functions being used in a program. Simply put, commands that you use in C programming are actually functions that are defined from within each header files. Each header file contains a set of functions. For example: stdio.h is a header file that contains definition and prototypes of commands like printf and scanf.

20) What is syntax error?

Syntax errors are associated with mistakes in the use of a programming language. It maybe a command that was misspelled or a command that must was entered in lowercase mode but was instead entered with an upper case character. A misplaced symbol, or lack of symbol, somewhere within a line of code can also lead to syntax error.

21) What are variables and it what way is it different from constants?

Variables and constants may at first look similar in a sense that both are identifiers made up of one character or more characters (letters, numbers and a few allowable symbols). Both will also hold a particular value. Values held by a variable can be altered throughout the program, and can be used in most operations and computations. Constants are given values at one time only, placed at the beginning of a program. This value is not altered in the program. For example, you can assigned a constant named PI and give it a value 3.1415 . You can then use it as PI in the program, instead of having to write 3.1415 each time you need it.

22) How do you access the values within an array?

Arrays contain a number of elements, depending on the size you gave it during variable declaration. Each element is assigned a number from 0 to number of elements-1. To assign or retrieve the value of a particular element, refer to the element number. For example: if you have a declaration that says “intscores[5];”, then you have 5 accessible elements, namely: scores[0], scores[1], scores[2], scores[3] and scores[4].

23) Can I use “int” data type to store the value 32768? Why?

No. “int” data type is capable of storing values from -32768 to 32767. To store 32768, you can use “long int” instead. You can also use “unsigned int”, assuming you don’t intend to store negative values.

24) Can two or more operators such as \n and \t be combined in a single line of program code?

Yes, it’s perfectly valid to combine operators, especially if the need arises. For example: you can have a code like printf (“Hello\n\n\’World\'”) to output the text “Hello” on the first line and “World” enclosed in single quotes to appear on the next two lines.

25) Why is it that not all header files are declared in every C program?

The choice of declaring a header file at the top of each C program would depend on what commands/functions you will be using in that program. Since each header file contains different function definitions and prototype, you would be using only those header files that would contain the functions you will need. Declaring all header files in every program would only increase the overall file size and load of the program, and is not considered a good programming style.

26) When is the “void” keyword used in a function?

When declaring functions, you will decide whether that function would be returning a value or not. If that function will not return a value, such as when the purpose of a function is to display some outputs on the screen, then “void” is to be placed at the leftmost part of the function header. When a return value is expected after the function execution, the data type of the return value is placed instead of “void”.

27) What are compound statements?

Compound statements are made up of two or more program statements that are executed together. This usually occurs while handling conditions wherein a series of statements are executed when a TRUE or FALSE is evaluated. Compound statements can also be executed within a loop. Curly brackets { } are placed before and after compound statements.

28) What is the significance of an algorithm to C programming?

Before a program can be written, an algorithm has to be created first. An algorithm provides a step by step procedure on how a solution can be derived. It also acts as a blueprint on how a program will start and end, including what process and computations are involved.

29) What is the advantage of an array over individual variables?

When storing multiple related data, it is a good idea to use arrays. This is because arrays are named using only 1 word followed by an element number. For example: to store the 10 test results of 1 student, one can use 10 different variable names (grade1, grade2, grade3… grade10). With arrays, only 1 name is used, the rest are accessible through the index name (grade[0], grade[1], grade[2]… grade[9]).

30) Write a loop statement that will show the following output:

C programming interview questions and answers for experienced, 31) what is wrong in this statement scanf(“%d”,whatnumber);.

An ampersand & symbol must be placed before the variable name whatnumber. Placing & means whatever integer value is entered by the user is stored at the “address” of the variable name. This is a common mistake for programmers, often leading to logical errors.

32) How do you generate random numbers in C?

Random numbers are generated in C using the rand() command . For example: anyNum = rand() will generate any integer number beginning from 0, assuming that anyNum is a variable of type integer.

33) What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

The most probable reason behind this error is that the header file for that function was not indicated at the top of the program. Header files contain the definition and prototype for functions and commands used in a C program. In the case of “tolower()”, the code “#include <ctype.h>” must be present at the beginning of the program.

34) What are comments and how do you insert it in a C program?

35) what is debugging.

Debugging is the process of identifying errors within a program. During program compilation, errors that are found will stop the program from executing completely. At this state, the programmer would look into the possible portions where the error occurred. Debugging ensures the removal of errors, and plays an important role in ensuring that the expected program output is met.

36) What does the && operator do in a program code?

The && is also referred to as AND operator. When using this operator, all conditions specified must be TRUE before the next action can be performed. If you have 10 conditions and all but 1 fails to evaluate as TRUE, the entire condition statement is already evaluated as FALSE

37) In C programming, what command or code can be used to determine if a number of odd or even?

There is no single command or function in C that can check if a number is odd or even. However, this can be accomplished by dividing that number by 2, then checking the remainder. If the remainder is 0, then that number is even, otherwise, it is odd. You can write it in code as:

38) What does the format %10.2 mean when included in a printf statement?

This format is used for two things: to set the number of spaces allotted for the output number and to set the number of decimal places. The number before the decimal point is for the allotted space, in this case it would allot 10 spaces for the output number. If the number of space occupied by the output number is less than 10, addition space characters will be inserted before the actual output number. The number after the decimal point sets the number of decimal places, in this case, it’s 2 decimal spaces.

39) What are logical errors and how does it differ from syntax errors?

Program that contains logical errors tend to pass the compilation process, but the resulting output may not be the expected one. This happens when a wrong formula was inserted into the code, or a wrong sequence of commands was performed. Syntax errors, on the other hand, deal with incorrect commands that are misspelled or not recognized by the compiler.

40) What are the different types of control structures in programming?

There are 3 main control structures in programming: Sequence, Selection and Repetition. Sequential control follows a top to bottom flow in executing a program, such that step 1 is first perform, followed by step 2, all the way until the last step is performed. Selection deals with conditional statements, which mean codes are executed depending on the evaluation of conditions as being TRUE or FALSE. This also means that not all codes may be executed, and there are alternative flows within. Repetitions are also known as loop structures, and will repeat one or two program statements set by a counter.

41) What is || operator and how does it function in a program?

The || is also known as the OR operator in C programming. When using || to evaluate logical conditions, any condition that evaluates to TRUE will render the entire condition statement as TRUE.

42) Can the “if” function be used in comparing strings?

No. “if” command can only be used to compare numerical values and single character values. For comparing string values, there is another function called strcmp that deals specifically with strings.

43) What are preprocessor directives?

Preprocessor directives are placed at the beginning of every C program. This is where library files are specified, which would depend on what functions are to be used in the program. Another use of preprocessor directives is the declaration of constants.Preprocessor directives begin with the # symbol.

44) What will be the outcome of the following conditional statement if the value of variable s is 10?

s >=10 && s < 25 && s!=12

45) Describe the order of precedence with regards to operators in C.

Order of precedence determines which operation must first take place in an operation statement or conditional statement. On the top most level of precedence are the unary operators !, +, – and &. It is followed by the regular mathematical operators (*, / and modulus % first, followed by + and -). Next in line are the relational operators <, <=, >= and >. This is then followed by the two equality operators == and !=. The logical operators && and || are next evaluated. On the last level is the assignment operator =.

46) What is wrong with this statement? myName = “Robin”;

You cannot use the = sign to assign values to a string variable. Instead, use the strcpy function. The correct statement would be: strcpy(myName, “Robin”);

47) How do you determine the length of a string value that was stored in a variable?

To get the length of a string value, use the function strlen(). For example, if you have a variable named FullName, you can get the length of the stored string value by using this statement: I = strlen(FullName); the variable I will now have the character length of the string value.

48) Is it possible to initialize a variable at the time it was declared?

Yes, you don’t have to write a separate assignment statement after the variable declaration, unless you plan to change it later on. For example: char planet[15] = “Earth”; does two things: it declares a string variable named planet, then initializes it with the value “Earth”.

49) Why is C language being considered a middle level language?

This is because C language is rich in features that make it behave like a high level language while at the same time can interact with hardware using low level methods. The use of a well structured approach to programming, coupled with English-like words used in functions, makes it act as a high level language. On the other hand, C can directly access memory structures similar to assembly language routines.

50) What are the different file extensions involved when programming in C?

Source codes in C are saved with .C file extension. Header files or library files have the .H file extension. Every time a program source code is successfully compiled, it creates an .OBJ object file, and an executable .EXE file.

51) What are reserved words?

Reserved words are words that are part of the standard C language library. This means that reserved words have special meaning and therefore cannot be used for purposes other than what it is originally intended for. Examples of reserved words are int, void, and return.

52) What are linked list?

A linked list is composed of nodes that are connected with another. In C programming, linked lists are created using pointers. Using linked lists is one efficient way of utilizing memory for storage.

53) What is FIFO?

In C programming, there is a data structure known as queue. In this structure, data is stored and accessed using FIFO format, or First-In-First-Out. A queue represents a line wherein the first data that was stored will be the first one that is accessible as well.

54) What are binary trees?

Binary trees are actually an extension of the concept of linked lists. A binary tree has two pointers, a left one and a right one. Each side can further branch to form additional nodes, which each node having two pointers as well. Learn more about Binary Tree in Data Structure if you are interested.

55) Not all reserved words are written in lowercase. TRUE or FALSE?

FALSE. All reserved words must be written in lowercase; otherwise the C compiler would interpret this as unidentified and invalid.

56) What is the difference between the expression “++a” and “a++”?

In the first expression, the increment would happen first on variable a, and the resulting value will be the one to be used. This is also known as a prefix increment. In the second expression, the current value of variable a would the one to be used in an operation, before the value of a itself is incremented. This is also known as postfix increment.

57) What would happen to X in this expression: X += 15; (assuming the value of X is 5)

X +=15 is a short method of writing X = X + 15, so if the initial value of X is 5, then 5 + 15 = 20.

58) In C language, the variables NAME, name, and Name are all the same. TRUE or FALSE?

FALSE. C language is a case sensitive language. Therefore, NAME, name and Name are three uniquely different variables.

59) What is an endless loop?

An endless loop can mean two things. One is that it was designed to loop continuously until the condition within the loop is met, after which a break function would cause the program to step out of the loop. Another idea of an endless loop is when an incorrect loop condition was written, causing the loop to run erroneously forever. Endless loops are oftentimes referred to as infinite loops.

60) What is a program flowchart and how does it help in writing a program?

A flowchart provides a visual representation of the step by step procedure towards solving a given problem. Flowcharts are made of symbols, with each symbol in the form of different shapes. Each shape may represent a particular entity within the entire program structure, such as a process, a condition, or even an input/output phase.

61) What is wrong with this program statement? void = 10;

The word void is a reserved word in C language. You cannot use reserved words as a user-defined variable.

62) Is this program statement valid? INT = 10.50;

Assuming that INT is a variable of type float, this statement is valid. One may think that INT is a reserved word and must not be used for other purposes. However, recall that reserved words are express in lowercase, so the C compiler will not interpret this as a reserved word.

63) What are actual arguments?

When you create and use functions that need to perform an action on some given values, you need to pass these given values to that function. The values that are being passed into the called function are referred to as actual arguments.

64) What is a newline escape sequence?

A newline escape sequence is represented by the \n character. This is used to insert a new line when displaying data in the output screen. More spaces can be added by inserting more \n characters. For example, \n\n would insert two spaces. A newline escape sequence can be placed before the actual output expression or after.

65) What is output redirection?

It is the process of transferring data to an alternative output source other than the display screen. Output redirection allows a program to have its output saved to a file. For example, if you have a program named COMPUTE, typing this on the command line as COMPUTE >DATA can accept input from the user, perform certain computations, then have the output redirected to a file named DATA, instead of showing it on the screen.

66) What are run-time errors?

These are errors that occur while the program is being executed. One common instance wherein run-time errors can happen is when you are trying to divide a number by zero. When run-time errors occur, program execution will pause, showing which program line caused the error.

67) What is the difference between functions abs() and fabs()?

These 2 functions basically perform the same action, which is to get the absolute value of the given value. Abs() is used for integer values, while fabs() is used for floating type numbers. Also, the prototype for abs() is under <stdlib.h>, while fabs() is under <math.h>.

68) What are formal parameters?

In using functions in a C program, formal parameters contain the values that were passed by the calling function. The values are substituted in these formal parameters and used in whatever operations as indicated within the main body of the called function.

69) What are control structures?

Control structures take charge at which instructions are to be performed in a program. This means that program flow may not necessarily move from one statement to the next one, but rather some alternative portions may need to be pass into or bypassed from, depending on the outcome of the conditional statements.

70) Write a simple code fragment that will check if a number is positive or negative

71) when is a “switch” statement preferable over an “if” statement.

The switch statement is best used when dealing with selections based on a single variable or expression. However, switch statements can only evaluate integer and character data types.

72) What are global variables and how do you declare them?

Global variables are variables that can be accessed and manipulated anywhere in the program. To make a variable global, place the variable declaration on the upper portion of the program, just after the preprocessor directives section.

73) What are enumerated types?

Enumerated types allow the programmer to use more meaningful words as values to a variable. Each item in the enumerated type variable is actually associated with a numeric code. For example, one can create an enumerated type variable named DAYS whose values are Monday, Tuesday… Sunday.

74) What does the function toupper() do?

It is used to convert any letter to its upper case mode. Toupper() function prototype is declared in <ctype.h>. Note that this function will only convert a single character, and not an entire string.

75) Is it possible to have a function as a parameter in another function?

Yes, that is allowed in C programming. You just need to include the entire function prototype into the parameter field of the other function where it is to be used.

76) What are multidimensional arrays?

Multidimensional arrays are capable of storing data in a two or more dimensional structure. For example, you can use a 2 dimensional array to store the current position of pieces in a chess game, or position of players in a tic-tac-toe program.

77) Which function in C can be used to append a string to another string?

The strcat function. It takes two parameters, the source string and the string value to be appended to the source string.

78) What is the difference between functions getch() and getche()?

Both functions will accept a character input value from the user. When using getch(), the key that was pressed will not appear on the screen, and is automatically captured and assigned to a variable. When using getche(), the key that was pressed by the user will appear on the screen, while at the same time being assigned to a variable.

79) Dothese two program statements perform the same output? 1) scanf(“%c”, &letter); 2) letter=getchar()

Yes, they both do the exact same thing, which is to accept the next key pressed by the user and assign it to variable named letter.

80) What are structure types in C?

Structure types are primarily used to store records. A record is made up of related fields. This makes it easier to organize a group of related data.

81) What does the characters “r” and “w” mean when writing programs that will make use of files?

“r” means “read” and will open a file as input wherein data is to be retrieved. “w” means “write”, and will open a file for output. Previous data that was stored on that file will be erased.

82) What is the difference between text files and binary files?

Text files contain data that can easily be understood by humans. It includes letters, numbers and other characters. On the other hand, binary files contain 1s and 0s that only computers can interpret.

83) is it possible to create your own header files?

Yes, it is possible to create a customized header file. Just include in it the function prototypes that you want to use in your program, and use the #include directive followed by the name of your header file.

84) What is dynamic data structure?

Dynamic data structure provides a means for storing data more efficiently into memory. Using Using dynamic memory allocation , your program will access memory spaces as needed. This is in contrast to static data structure, wherein the programmer has to indicate a fix number of memory space to be used in the program.

85) What are the different data types in C?

The basic data types in C are int, char, and float. Int is used to declare variables that will be storing integer values. Float is used to store real numbers. Char can store individual character values.

86) What is the general form of a C program?

A C program begins with the preprocessor directives, in which the programmer would specify which header file and what constants (if any) to be used. This is followed by the main function heading. Within the main function lies the variable declaration and program statement.

87) What is the advantage of a random access file?

If the amount of data stored in a file is fairly large, the use of random access will allow you to search through it quicker. If it had been a sequential access file, you would have to go through one record at a time until you reach the target data. A random access file lets you jump directly to the target address where data is located.

88) In a switch statement, what will happen if a break statement is omitted?

If a break statement was not placed at the end of a particular case portion? It will move on to the next case portion, possibly causing incorrect output.

89) Describe how arrays can be passed to a user defined function

One thing to note is that you cannot pass the entire array to a function. Instead, you pass to it a pointer that will point to the array first element in memory. To do this, you indicate the name of the array without the brackets.

90) What are pointers?

Pointers point to specific areas in the memory. Pointers contain the address of a variable, which in turn may contain a value or even an address to another memory.

91) Can you pass an entire structure to functions?

Yes, it is possible to pass an entire structure to a function in a call by method style. However, some programmers prefer declaring the structure globally, then pass a variable of that structure type to a function. This method helps maintain consistency and uniformity in terms of argument type.

92) What is gets() function?

The gets() function allows a full line data entry from the user. When the user presses the enter key to end the input, the entire line of characters is stored to a string variable. Note that the enter key is not included in the variable, but instead a null terminator \0 is placed after the last character.

93) The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

You can do this by using %% in the printf statement. For example, you can write printf(“10%%”) to have the output appear as 10% on the screen.

94) How do you search data in a data file using random access method?

Use the fseek() function to perform random access input/ouput on a file. After the file was opened by the fopen() function, the fseek would require three parameters to work: a file pointer to the file, the number of bytes to search, and the point of origin in the file.

95) Are comments included during the compilation stage and placed in the EXE file as well?

No, comments that were encountered by the compiler are disregarded. Comments are mostly for the guidance of the programmer only and do not have any other significant use in the program functionality.

96) Is there a built-in function in C that can be used for sorting data?

Yes, use the qsort() function. It is also possible to create user defined functions for sorting, such as those based on the balloon sort and bubble sort algorithm.

97) What are the advantages and disadvantages of a heap?

Storing data on the heap is slower than it would take when using the stack. However, the main advantage of using the heap is its flexibility. That’s because memory in this structure can be allocated and remove in any particular order. Slowness in the heap can be compensated if an algorithm was well designed and implemented.

98) How do you convert strings to numbers in C?

You can write you own functions to do string to number conversions, or instead use C’s built in functions. You can use atof to convert to a floating point value, atoi to convert to an integer value, and atol to convert to a long integer value.

99) Create a simple code fragment that will swap the values of two variables num1 and num2.

100) what is the use of a semicolon (;) at the end of every program statement.

It has to do with the parsing process and compilation of the code. A semicolon acts as a delimiter, so that the compiler knows where each statement ends, and can proceed to divide the statement into smaller elements for syntax checking.

These interview questions will also help in your viva(orals)

  • Bitwise Operators in C: AND, OR, XOR, Shift & Complement
  • Dynamic Memory Allocation in C using malloc(), calloc() Functions
  • Type Casting in C: Type Conversion, Implicit, Explicit with Example
  • C Programming Tutorial PDF for Beginners
  • 13 BEST C Programming Books for Beginners (2024 Update)
  • Difference Between C and Java
  • Difference Between Structure and Union in C
  • calloc() Function in C Library with Program EXAMPLE

Forage

Programming Interview Questions

How to prepare for programming interview questions, forage find, conceptual coding interview questions, how to prepare for conceptual coding interview questions, general coding interview questions, how to prepare for general coding interview questions, common coding interview questions: the bottom line, 45 common coding interview questions.

Zoe Kaplan

  • Share on Twitter Share on Twitter
  • Share on Facebook Share on Facebook
  • Share on LinkedIn Share on LinkedIn

student coding on laptop

Forage puts students first. Our blog articles are written independently by our editorial team. They have not been paid for or sponsored by our partners. See our full  editorial guidelines .

Table of Contents

A coding interview can be nerve-racking, but it’s an essential part of the technical interview process to demonstrate your programming skills and knowledge of coding concepts. While the exact questions a technical recruiter might ask vary depending on what kind of role you’re applying for, there are some common coding interview questions you can prepare for to ace the interview. We’ll review the three main types of questions you’ll encounter during a coding interview and how to prepare for them. 

A coding interview typically starts with an assessment of your computer programming skills. You’ll need to answer questions that demonstrate you know how to do specific tasks or functions, usually through an assessment called a whiteboard challenge or independent coding test.

>>MORE: Are Coding Bootcamps Worth It in 2024?

What questions will you get in a whiteboard challenge or independent coding test? Here are some examples:

  • How do you reverse a string?
  • How do you determine if a string is a palindrome?
  • How do you calculate the number of numerical digits in a string?
  • How do you find the count for the occurrence of a particular character in a string?
  • How do you find the non-matching characters in a string?
  • How do you find out if the two given strings are anagrams?
  • How do you calculate the number of vowels and consonants in a string?
  • How do you total all of the matching integer elements in an array?
  • How do you reverse an array?
  • How do you find the maximum element in an array?
  • How do you sort an array of integers in ascending order?
  • How do you print a Fibonacci sequence using recursion?
  • How do you calculate the sum of two integers?
  • How do you find the average of numbers in a list?
  • How do you check if an integer is even or odd?
  • How do you find the middle element of a linked list?
  • How do you remove a loop in a linked list?
  • How do you merge two sorted linked lists?
  • How do you implement binary search to find an element in a sorted array?
  • How do you print a binary tree in vertical order?

There are two main types of assessments for programming interview questions: a whiteboard challenge and a coding test. 

How to Prepare for a Whiteboard Challenge

A whiteboard challenge is when you’re given a coding challenge during a live interview . You solve the problem in front of the interviewer and explain your process as you work on the challenge.

You can use the UMPIRE method to approach these problems:

U: Understand the problem M: Match the problem with the interviewer P: Plan your approach and solution I: Implement your solution R: Review your solution E: Evaluate your solution

To prepare for a whiteboard challenge, “practice talking through your problem-solving process ,” says Archie Payne, president of CalTek Staffing, an IT and technical staffing firm. “Interviewers don’t just want to see that candidates can complete the test task, they also want to get insights into how candidates approach the process. A good way to prepare is to pretend you’re teaching a programming class, and practice how you’d explain and demonstrate key concepts to someone who doesn’t know them.”

It’s less about solving everything right the first time (or even at all) and more about learning how you approach problems and solve challenges. 

>>MORE: 13 Best Free Coding Bootcamps in 2024

And what happens if you don’t know the answer? Don’t panic.“Be honest that this is a gap in your knowledge,” Payne says. “Take a moment to think critically about the problem and the ways you’d likely approach it, then explain that process to the interviewer. Hiring managers don’t necessarily expect entry-level candidates to have all the answers, but they do want to hire someone who’s self aware about what they do and don’t know, and willing to learn and try new things.”

programming for problem solving viva questions and answers

LeetCode is a great resource for practicing these types of questions. You can create a free account and practice hundreds of coding questions you might get in an interview.

How to Prepare for an Independent Coding Test

An independent coding test focuses on your ability to code and solve problems within a given time frame. You may have an independent coding test after your whiteboard test or before as part of a screening. 

The company will give you a link to a common code editor, and you can choose what programming language you want to write in. Before you start the test, you’ll know how long you have to complete it and whether you’ll be able to leave the platform during the test. Make sure you do the test in a quiet environment where you won’t have distractions.

To prepare for this part of the interview, “​​simulate interview conditions,” Mohit Maheshwari, co-founder at NMG Technologies, a full-service IT company, says. “Practice coding on a whiteboard or a blank sheet of paper, as this is how you will be doing it during the interview. Get used to writing code without the aid of an IDE [integrated development environment] or compiler.” 

Need to practice your coding skills? A Forage job simulation can help you build the skills you need to ace the interview — and give you experience you can talk about during the interview. 

Basic programming, Python, Git, React
Java, RESTful Web Development, HTTP
Data structures, object-oriented design, code analysis, code readability
Data modeling, system design, Java, Spring
Python, cloud security
System design, Java, APIs

The recruiter or hiring manager will also ask conceptual coding interview questions to learn whether you’re familiar with the concepts you’ll be working with. 

“Expect questions on basic data structures such as arrays, linked lists, trees, and graphs, as well as common algorithms like sorting and searching,” Maheshwari says.

Examples of these questions include:

  • What is a data structure?
  • What is an array?
  • What is a linked list?
  • What is the difference between an array and a linked list?
  • What is LIFO? 
  • What is FIFO?
  • What is a stack?
  • What are binary trees?
  • What are binary search trees?
  • What is object-oriented programming?
  • What is the purpose of a loop in programming?
  • What is a conditional statement?
  • What is debugging?
  • What is recursion?
  • What are the differences between linear and non-linear data structures?

Preparing for conceptual coding interview questions requires two focuses: knowing the concepts, then knowing how to explain them.

First, refamiliarize yourself with these concepts. If you studied coding at school, look through your notes, textbooks, and past exams to make sure you understand each concept. Be sure you not only know the definition of the concept, but how to put that concept into context; memorizing index card definitions isn’t the goal.

Then, you can practice by explaining them clearly to someone who doesn’t have technical knowledge. While the recruiter or hiring manager you talk to should have basic technical know-how, explaining the term to someone without it ensures you really know the ins and outs of the concept because you have to break it down very clearly.

Knowing how to explain complex technical terms to non-technical people is also a soft skill that employers look for — be sure to show this skill off in the interview!

>>MORE: Learn explanations of common software engineering technical concepts with entry-level software engineering interview questions (and answers) .

Outside of programming questions and questions about technical concepts, you might answer questions about your general experience, like how you learned to code, behavioral interview questions , and how you keep your skills fresh. 

Examples of general common coding interview questions include:

  • What programming languages do you have experience working with?
  • Describe a time you faced a challenge in a project you were working on and how you overcame it.
  • Walk me through a project you’re currently or have recently worked on.
  • Give an example of a project you worked on where you had to learn a new programming language or technology. How did you go about learning it?
  • How do you ensure your code is readable by other developers?
  • What are your interests outside of programming?
  • How do you keep your skills sharp and up to date?
  • How do you collaborate on projects with non-technical team members?
  • Tell me about a time when you had to explain a complex technical concept to a non-technical team member.
  • How do you get started on a new coding project?

Preparing for general coding interview questions is similar to how you might prepare for any other interview: reviewing your experience and preparing to talk about specific situations you’ve navigated in the workplace. 

“Be prepared to explain your expertise in the languages you know and what types of projects you’ve completed using them,” Payne says. “​​The ability to troubleshoot and correct issues as you go is a key skill for programmers at all career levels. The best answer will focus on the steps you take to diagnose and fix issues, rather than the intricate details of the specific problem you’re describing.”

programming for problem solving viva questions and answers

Interview Preparation: Own Your Story

Learn how to identify your strengths, ask memorable questions in an interview, and share your experience effectively.

Avg. Time: 3-4 hours

Skills you’ll build: Storytelling, career and self development, interview preparation

It’s OK if you don’t have any prior professional experience. You can still draw from examples in the classroom, at an internship , or working on an independent project. 

Programming interview questions generally come in three different forms: practical coding tests, questions about technical concepts, and general questions about your experience. To ace a coding interview, prepare carefully for each section: practice problems, review concepts, and use the STAR method to shape answers about your experience.

Are you getting ready for a coding interview? Practice sample coding problems with matrices and arrays and learn what hiring managers look for in technical interviews with Girls Who Code’s Technical Interview Prep .

Zoe Kaplan

Related Posts

Interview angst here’s what not to say in an interview, how to prep for consulting interview questions, 11 financial analyst interview questions (and answers), upskill with forage.

working at Accenture

Gain job skills you can talk about in interviews.

MCQs and Answers

Engineering interview questions, Mcqs, Objective Questions,Class Notes,Seminor topics,Lab Viva Pdf free download. CIVIL | Mechanical | CSE | EEE | ECE | IT | Chemical Online Quiz Tests for Freshers.

300+ TOP C Language LAB VIVA Questions with Answers Pdf

C language lab viva questions :-.

1. Who developed C language?

C language was developed by Dennis Ritchie in 1970 at Bell Laboratories.

2. Which type of language is C?

C is a high – level language and general purpose structured programming language.

3. What is a compiler?

Compile is a software program that transfer program developed in high level language intoexecutable object code

4. What is IDE?

The process of editing, compiling, running and debugging is managed by a single integratedapplication known as Integrated Development Environment (IDE)

5. What is a program?

A computer program is a collection of the instructions necessary to solve a specific problem.

6. What is an algorithm?

The approach or method that is used to solve the problem is known as algorithm.

7. What is structure of C program?

A C program contains Documentation section, Link section, Definition section, Globaldeclaration section, Main function and other user defined functions

8. What is a C token and types of C tokens?

The smallest individual units are known as C tokens. C has six types of tokens Keywords,Constants, Identifiers, Strings, Operators and Special symbols.

9.What is a Keyword?

Keywords are building blocks for program statements and have fixed meanings and thesemeanings cannot be changed.

10.How many Keywords (reserve words) are in C?

There are 32 Keywords in C language.

C Language LAB VIVA Questions

11.What is an Identifier?

Identifiers are user-defined names given to variables, functions and arrays.

12.What is a Constant and types of constants in C?

Constants are fixed values that do not change during the program execution. Types of constants are Numeric Constants (Integer and Real) and Character Constants (SingleCharacter, String Constants).

13.What are the Back Slash character constants or Escape sequence charactersavailable in C?

Back Slash character constant are \t, \n, \0

14.What is a variable?

Variables are user-defined names given to memory locations and are used to store values. Avariable may have different values at different times during program execution

15.What are the Data Types present in C?

Primary or Fundamental Data types (int, float, char), Derived Data types(arrays, pointers)and User-Defined data types(structures, unions, enum)

16.How to declare a variable?

The syntax for declaring variable isdata type variable_name-1, variable_name-2,….variable_name-n;

17.What is meant by initialization and how we initialize a variable?

While declaring a variable assigning value is known as initialization. Variable can beinitialized by using assignment operator (=).

18.What are integer variable, floating-point variable and character variable?

A variable which stores integer constants are called integer variable. A variable which storesreal values are called floating-point variable. A variable which stores character constants arecalled character variables.

19.How many types of operator or there in C?

C consist Arithmetic Operators (+, -, *, /,%), Relational Operators (<, <=, >, >=, !=), LogicalOperators (&&, ||, !), Assignment Operators (=, +=, -=, *=, /=), Increment and DecrementOperators (++, –), Conditional Operator(?:), Bitwise Operators(<<, >>, ~, &, |, ^) andSpecial Operators (. , ->, &, *, sizeof)

20. What is RAM ?

RAM – Random Access Memory is a temporary storage medium in a computer. RAM is a volatile memory i.e all data stored in RAM will be erased when the computer is switched off.

21. What do mean by network ?

Computer networking refers to connecting computers to share data, application software and hardware divices. Networks allow sharing of information among various computers and permit users to share files

22. List a few unconditional control statement in C.

  • break statement
  • continue statement
  • goto statement
  • exit() function

23. What is an array ?

An array is a collection of values of the same data type. Values in array are accessed using array name with subscripts in brackets[]. Synatax of array declaration is

data type array_ name[size];

24. What is Multidimensional Arrays

An array with more than one index value is called a multidimensional array. To declare a multidimensional array you can do follow syntax

data type array_ name[] [] []….;

25. Define string ?

An array of characters is known as a string.for example

char st[8]; this statement declares a string array with 80 characters .

26. Mention four important string handling functions in C languages .

There are four important string handling functions in C languages .

The header file #include is used when these functions are called in a C program.

27. Explain about the constants which help in debugging?

A #if directive test can be offered with #else and #else if directives. This allows conditional branching of the program to run sections of the code according to the result. Constants defined with a #define directive can be undefined with the #undef directive. The #ifdef directive has a companion directive #ifndef. These commands can be useful when debugging problem code to hide and unhide sections of the program.

28. Define and explain about ! Operator?

The logical operator ! NOT is a unary operator that is used before a single operand. It returns the inverse value of the given operand so if the variable “c” had a value of true then! C would return value of false. The not operator is very much useful in C programs because it can change the value of variables with successful iterations. This ensures that on each pass the value is changed.

29. What is operator precedence?

Operator precedence defines the order in which C evaluates expressions.

e.g. in the expression a=6+b*3, the order of precedence determines whether the addition or the multiplication is completed first. Operators on the same row have equal precedence.

30. Explain about the functions strcat() and strcmp()?

This function concatenates the source string at the end of the target string. Strcmp() function compares two strings to find out whether they are the same or different. The two strings are compared character by character until there is a mismatch or end of one of the strings is reached, whichever occurs first. If in case two strings are identical, a value of zero is returned. If there is no matches between two strings then a difference of the two non matching values are returned according to ASCII values.

31. Define function

A function is a module or block of program code which deals with a particular task. Each function has a name or identifier by which is used to refer to it in a program. A function can accept a number of parameters or values which pass information from outside, and consists of a number of statements and declarations, enclosed by curly braces { }, which make up the doing part of the object

32. Differentiate built-in functions and user – defined functions.

Built – in functions are used to perform standard operations such as finding the square root of a number, absolute value and so on. These are available along with the C compiler and are included in a program using the header files math.h, s tring.h and so on.

User defined functions are written by the user or programmer to compute a value or perform a task. It contains a statement block which is executed during the runtime whenever it is called by the main program.

33. Distinguish between actual and formal arguments.

Actual arguments are variables whose values are supplied to the function in any function call. Formal arguments are variables used to receive the values of actual arguments from the calling program.

34. Explain the concept and use of type void.

A function which does not return a value directly to the calling program is referred as a void function. The void functions are commonly used to perform a task and they can return many values through global variable declaration.

35. What is recursion ?

A function calling itself again and again to compute a value is referref to as recursive function or recursion. Recursion is useful for branching processes and is effective where terms are generated successively to compute a value.

c programming viva questions and answers pdf ::

3 thoughts on “300+ top c language lab viva questions with answers pdf”.

What about pointers, structure and unions

Plz provide some more questios

Very useful

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • C Data Types
  • C Operators
  • C Input and Output
  • C Control Flow
  • C Functions
  • C Preprocessors
  • C File Handling
  • C Cheatsheet
  • C Interview Questions

C Exercises – Practice Questions with Solutions for C Programming

The best way to learn C programming language is by hands-on practice. This C Exercise page contains the top 30 C exercise questions with solutions that are designed for both beginners and advanced programmers. It covers all major concepts like arrays, pointers, for-loop, and many more.

C-Exercises

So, Keep it Up! Solve topic-wise C exercise questions to strengthen your weak topics.

C Programming Exercises

The following are the top 30 programming exercises with solutions to help you practice online and improve your coding efficiency in the C language. You can solve these questions online in GeeksforGeeks IDE.

Q1: Write a Program to Print “Hello World!” on the Console.

In this problem, you have to write a simple program that prints “Hello World!” on the console screen.

For Example,

Click here to view the solution.

Q2: write a program to find the sum of two numbers entered by the user..

In this problem, you have to write a program that adds two numbers and prints their sum on the console screen.

Q3: Write a Program to find the size of int, float, double, and char.

In this problem, you have to write a program to print the size of the variable.

Q4: Write a Program to Swap the values of two variables.

In this problem, you have to write a program that swaps the values of two variables that are entered by the user.

Swap-two-Numbers

Swap two numbers

Q5: Write a Program to calculate Compound Interest.

In this problem, you have to write a program that takes principal, time, and rate as user input and calculates the compound interest.

Q6: Write a Program to check if the given number is Even or Odd.

In this problem, you have to write a program to check whether the given number is even or odd.

Q7: Write a Program to find the largest number among three numbers.

In this problem, you have to write a program to take three numbers from the user as input and print the largest number among them.

Q8: Write a Program to make a simple calculator.

In this problem, you have to write a program to make a simple calculator that accepts two operands and an operator to perform the calculation and prints the result.

Q9: Write a Program to find the factorial of a given number.

In this problem, you have to write a program to calculate the factorial (product of all the natural numbers less than or equal to the given number n) of a number entered by the user.

Q10: Write a Program to Convert Binary to Decimal.

In this problem, you have to write a program to convert the given binary number entered by the user into an equivalent decimal number.

Q11: Write a Program to print the Fibonacci series using recursion.

In this problem, you have to write a program to print the Fibonacci series(the sequence where each number is the sum of the previous two numbers of the sequence) till the number entered by the user using recursion.

FIBONACCI-SERIES

Fibonacci Series

Q12: Write a Program to Calculate the Sum of Natural Numbers using recursion.

In this problem, you have to write a program to calculate the sum of natural numbers up to a given number n.

Q13: Write a Program to find the maximum and minimum of an Array.

In this problem, you have to write a program to find the maximum and the minimum element of the array of size N given by the user.

Q14: Write a Program to Reverse an Array.

In this problem, you have to write a program to reverse an array of size n entered by the user. Reversing an array means changing the order of elements so that the first element becomes the last element and the second element becomes the second last element and so on.

reverseArray

Reverse an array

Q15: Write a Program to rotate the array to the left.

In this problem, you have to write a program that takes an array arr[] of size N from the user and rotates the array to the left (counter-clockwise direction) by D steps, where D is a positive integer. 

Q16: Write a Program to remove duplicates from the Sorted array.

In this problem, you have to write a program that takes a sorted array arr[] of size N from the user and removes the duplicate elements from the array.

Q17: Write a Program to search elements in an array (using Binary Search).

In this problem, you have to write a program that takes an array arr[] of size N and a target value to be searched by the user. Search the target value using binary search if the target value is found print its index else print ‘element is not present in array ‘.

Q18: Write a Program to reverse a linked list.

In this problem, you have to write a program that takes a pointer to the head node of a linked list, you have to reverse the linked list and print the reversed linked list.

Q18: Write a Program to create a dynamic array in C.

In this problem, you have to write a program to create an array of size n dynamically then take n elements of an array one by one by the user. Print the array elements.

Q19: Write a Program to find the Transpose of a Matrix.

In this problem, you have to write a program to find the transpose of a matrix for a given matrix A with dimensions m x n and print the transposed matrix. The transpose of a matrix is formed by interchanging its rows with columns.

Q20: Write a Program to concatenate two strings.

In this problem, you have to write a program to read two strings str1 and str2 entered by the user and concatenate these two strings. Print the concatenated string.

Q21: Write a Program to check if the given string is a palindrome string or not.

In this problem, you have to write a program to read a string str entered by the user and check whether the string is palindrome or not. If the str is palindrome print ‘str is a palindrome’ else print ‘str is not a palindrome’. A string is said to be palindrome if the reverse of the string is the same as the string.

Q22: Write a program to print the first letter of each word.

In this problem, you have to write a simple program to read a string str entered by the user and print the first letter of each word in a string.

Q23: Write a program to reverse a string using recursion

In this problem, you have to write a program to read a string str entered by the user, and reverse that string means changing the order of characters in the string so that the last character becomes the first character of the string using recursion. 

Reverse-a-String

reverse a string

Q24: Write a program to Print Half half-pyramid pattern.

In this problem, you have to write a simple program to read the number of rows (n) entered by the user and print the half-pyramid pattern of numbers. Half pyramid pattern looks like a right-angle triangle of numbers having a hypotenuse on the right side.

Q25: Write a program to print Pascal’s triangle pattern.

In this problem, you have to write a simple program to read the number of rows (n) entered by the user and print Pascal’s triangle pattern. Pascal’s Triangle is a pattern in which the first row has a single number 1 all rows begin and end with the number 1. The numbers in between are obtained by adding the two numbers directly above them in the previous row.

pascal-triangle

Pascal’s Triangle

Q26: Write a program to sort an array using Insertion Sort.

In this problem, you have to write a program that takes an array arr[] of size N from the user and sorts the array elements in ascending or descending order using insertion sort.

Q27: Write a program to sort an array using Quick Sort.

In this problem, you have to write a program that takes an array arr[] of size N from the user and sorts the array elements in ascending order using quick sort.

Q28: Write a program to sort an array of strings.

In this problem, you have to write a program that reads an array of strings in which all characters are of the same case entered by the user and sort them alphabetically. 

Q29: Write a program to copy the contents of one file to another file.

In this problem, you have to write a program that takes user input to enter the filenames for reading and writing. Read the contents of one file and copy the content to another file. If the file specified for reading does not exist or cannot be opened, display an error message “Cannot open file: file_name” and terminate the program else print “Content copied to file_name”

Q30: Write a program to store information on students using structure.

In this problem, you have to write a program that stores information about students using structure. The program should create various structures, each representing a student’s record. Initialize the records with sample data having data members’ Names, Roll Numbers, Ages, and Total Marks. Print the information for each student.

We hope after completing these C exercises you have gained a better understanding of C concepts. Learning C language is made easier with this exercise sheet as it helps you practice all major C concepts. Solving these C exercise questions will take you a step closer to becoming a C programmer.

Frequently Asked Questions (FAQs)

Q1. what are some common mistakes to avoid while doing c programming exercises.

Some of the most common mistakes made by beginners doing C programming exercises can include missing semicolons, bad logic loops, uninitialized pointers, and forgotten memory frees etc.

Q2. What are the best practices for beginners starting with C programming exercises?

Best practices for beginners starting with C programming exercises: Start with easy codes Practice consistently Be creative Think before you code Learn from mistakes Repeat!

Q3. How do I debug common errors in C programming exercises?

You can use the following methods to debug a code in C programming exercises Read the error message carefully Read code line by line Try isolating the error code Look for Missing elements, loops, pointers, etc Check error online

Please Login to comment...

Similar reads, improve your coding skills with practice.

 alt=

What kind of Experience do you want to share?

programming for problem solving viva questions and answers

  • Log in Forgot Password Sign in

Python Viva Question

List of python viva question and answers, q1: name the key features of python.

Answer: There are many key features in python and some of them are listed below:

  • Dynamically-typed
  • Interpreted
  • Object-oriented
  • Concise and simple

Q2: How to check if all characters in a string are alphanumeric?

Answer: isalnum(): In python, we can use the "isalnum()" method to check whether all the characters are alphanumeric or not in a string variable.

Q3: Name the built-in types available in Python?

Answer: We have Mutable and Immutable as built-in types in python, listed as below:

a) The mutable ones include:

  • Dictionaries

b) The immutable types include:

Q4:  Explain the difference between a list and a tuple?

Answer: The list is mutable while the tuple is not. Tuples can be hashed as in the case of making keys for dictionaries.

read more about Tuples in python...

Q5: What is the use of %s in python?

Answer: " %s " is a format specifier which transmutes any value into a string.

Q6: What is a pass in Python?

Answer: No-operation Python statement refers to pass.

Q7: How are files deleted in Python?

Answer: To delete a file in Python:

  • Import OS module
  • Use os.remove() function

Q8: What is pep 8?

Answer: Python Enhancement Proposal or pep 8 is a set of rules that specify how to format Python code for maximum readability.

Q9: What is [::-1} used for?

Answer: [::-1} reverses the order of an array or a sequence. However, the original array or the list remains unchanged.

Q10: What is Numpy?

Answer: NumPy stands for "Numerical Python" .

It is used for efficient and general numeric computations on numerical data saved in arrays. E.g., sorting, indexing, reshaping, and more.

Q11: What is Scipy?

Answer: SciPy stands for "Scientific Python" .

This module is a collection of tools in Python used to perform operations such as integration, differentiation, and more.

Q12: Explain how to delete a file in Python?

Answer: Using a command os.remove (file name / file path) or os.unlink (file name / file path).

Q13: How can you access a module written in Python from C?

Answer: If we need to access the logic from a module written in the programming C we can use the "PyImport_ImportModule" function with a parameter name as the module name like below:

Q14: What is slicing?

Answer: Slicing is a technique that allows us to retrieve only a part of a list, tuple, or string.

Q15: How do you reverse a list?

Answer: We have a list of built-in functions available with the "List" collection and from them using the reverse() method we can reverse the list.

Check your Python Skills with:

Python multiple choice questions and answers, related article, advertisement.

programming for problem solving viva questions and answers

  • Privacy Policy
  • Become An Author
  • Student Login

JOIN TUTORIALS LINK

Our newsletter will let you know when any new articles, tutorials and video are released..

  • Code Snippet
  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Where is programming logic/problem solving learned? [closed]

I feel stuck and I don't know what to do to become a good programmer. I have followed so many tutorials:

FreeCodeCamp - 4h 30 min

3dbuzz C# (like 2 beginner and 1 advanced)

Caleb Curry - 6+

Bob from Microsoft

and many more videos.

And I am stuck. My goal with C# was to improve it so I would get better at Unity. But I dont feel that much better. I would say that my syntax knowledge is pretty good now, but thats the easy part. C# is my first programming language and I am struggling to use my knowledge(syntax) to build things with it. I just dont have the problem solving skills required to create things in either C# or Unity. But where am I supposed to learn that? It seems like everyone either tells you to just do algorithms(Leetcode) or "Just code". (1) I have done different sorting algorithms and other stuff, but I feel like that doesn't really help me. (2) "Just code" yes but what? Everyone tells you to practice, but never how or what. Like I dont have any tasks to use the knowledge I have gained on.

I cant build big applications, I cant make save/load systems, I cant make complex things. I dont know where I am supposed to learn that stuff. And I cant find any vidoes/courses that teach me that stuff. Its all just "this is how foreach" works. "This is how delegates" works. "This is how you implement the observer pattern" its never "This is how you should think, this is how you should implement it all together"

Like do I have to enroll in CS50 to learn how to think as a programmer or is taking a deep dive in C# just a waste of time when my goal is game development(I dont think/hope it is, I mean game engines build on programming)

What Am I supposed to do?

  • unity-game-engine

MrV's user avatar

  • 1 tbh heres your issue "I have followed so many tutorials" if youj have watched enough tutorials that you would say this, you are either just blindingly doing the tutorial, like a race, and just blindly writing down what they did, or, you picked all the wrong ones. You need to use the tutorial to investigate exactly why they did what they did, even if they dont say. Unity methods are documented, look them up, look up alternatives, look to see if you would do thing their doing different, if you would, is your way actually worse? –  BugFinder Commented yesterday
  • " you are either just blindingly doing the tutorial, like a race, and just blindly writing down what they did, or, you picked all the wrong ones" I would say Yes and no. The problem is that all of them just teached me about the syntax of the language. Thats easy to learn. But the hard part is how to use it together to create things, problem solving. But none of the videos/Courses so far teaches me that. I just want a course to actually teach me how it all comes together. –  MrV Commented yesterday
  • 2 The very first book I read on VBA I did the following - read the book and when there was text about an example I closed it and tried to do it ON MY OWN before reading what the author did. Then learn from that. Then at the end of the chapter I would do ALL exercises WITHOUT ANY GOOGLE or HELP as if my life depended on it. –  Ivan Petrov Commented yesterday
  • Don't just watch tutorials, find code challenges so you can get some actual experience –  Hans Kesting Commented yesterday
  • 1 I cant build big applications - I cant make complex things - yes, you can. You can't just spit them out in one piece from end to end. Nobody can. Think of something that you want to do, like perhaps a simplified version of your favorite game. Then break the task into smaller pieces, A, B, C, and so on. If A is still too daunting to take on as a whole, break that down further into A1, A2, A3, and so on, until you have pieces that you actually feel you can handle. –  500 - Internal Server Error Commented yesterday

2 Answers 2

This is a great question that I believe needs to be discussed more. I love programming and have done so from an early age. So, where did I learn it to become seasoned? To reiterate all the great comments, you get there by doing, get frustrated, work through it. Ask what else you could do.

The tutorials you've followed and possibly interacted with have led you to understand how to read code and, in a theoretical sense, concepts such as polymorphism and inheritance. The problem you're facing now is taking that and applying it to the Unity projects you've got queued up. The other piece to note, which you need to separate, is domain knowledge as it applies to C#. Knowing how to develop in C# and the domain libraries, terms, and concepts for game programming and graphics are different.

You're clearly motivated, so take one of your more straightforward ideas and work through it. Make it work, however ugly you think it is; a blank page is daunting. Unity has many tutorials. Work through one and then expand on it. Once it's effectively operating, think about how you could have broken that code up. Are some of your methods doing too much? If you wanted to expand your game ideas, will what you've written support that? If not, think about how you might extract critical information, such as the separation of duties. An example: Round 1 - You want a bag to carry the items you collected:

It's a start, but now you want to know more about the item rather than just a name. Ok, let's create an object for that and apply it.

In this example, you finally want some items to be health, weapons, armor, etc. Each one now deviates from a basic named item.

These still fit in your bag, but you can do much more now. You need to start with your problem, and yes, it can be frustrating, but it's that process of iterating that trains you to think about what you're attempting to do. Everyone has the potential to do this; it just takes time and experience, so start small and grow. Remember, even the most seasoned of us have days where we question our choices but keep going, it's worth it :-)

Maldaer's user avatar

  • I just... I still feel like my programming knowledge is mediocre at best and I can't get over to the other side. I can make simple games without following tutorials. I have made Flappy Birds, Ping pong and even Fruit Ninja Before, but the code I write feels childish. I went back to improve my C# in hopes of also getting better at Unity. I have learned a lot of syntax, I know about the 4 pillars of OOP, I have worked through the most known Design Patterns and done algorithms(Sorting/searching was easy, A* and harder algorithms where to hard)but I never got any tasks to test my knowledge on. –  MrV Commented 15 hours ago
  • That's my weakness, using my knowledge and I never get to use it. I can't find any tasks to do online. So thats why I am still stuck at beginner, not able to climb up to intermediate. I can do easy things, but I dont know how to think when doing more intermediate/advanced stuff. I need more tasks to do. Like there is no website that just gives you hundreds of programming challenged to do and help you with how to think like a programmer. –  MrV Commented 15 hours ago
  • But as you said its about just doing it, like that bag example you gave. But I am Kinda empty, I dont know what to do or what I need in a game. If I make a pirate game I dont know where to start or what to add or how it all works together. I have learned the syntax but no video taught me how to structure my code, what goes where, etc... Me and my friend started to make a game a couple of days ago, just to get better at Unity. The idea is: 2D game with a "ghost" that help you. This ghost is just a playback of the players movement and interactions before he/she entered a door. –  MrV Commented 11 hours ago
  • And with the help of the ghost you finish the game. We already have a simple walk Mechanic. But the problem is how this playback/recording is gonna work with everything. And I have seen that games usually have managers for sound, for spawning, for handling the game, etc... I just don't know how to structure it all. (Sorry for so much text) –  MrV Commented 11 hours ago

I have a suggestion to get a feedback loop that is more effective and engaging. Ask AI to build code for things you want to build. For example, a small game. For bigger things, you can ask it to build parts of it, and then you try to glue it together. Then, when invariably it doesn't work perfectly, either solve it, or, if you run out of ideas, ask the AI about your next doubt. If you can't get insight, then you can ask a human. But the fact you can ask lots of small questions in succession to an AI is beneficial when there's a lot to discover, vs. asking larger questions and waiting some time for an answer. The goal is to iterate quickly on small doubts. The small steps you make this way are motivating. This helps you identify if there are any specific areas you want to tackle first, as opposed to the full technology, by steering yourself towards what pikes your curiosity. Get interacting and put watching as a lower priority.

Pedro Sobota's user avatar

Not the answer you're looking for? Browse other questions tagged c# unity-game-engine or ask your own question .

  • Featured on Meta
  • Upcoming sign-up experiments related to tags
  • Policy: Generative AI (e.g., ChatGPT) is banned
  • The [lib] tag is being burninated
  • What makes a homepage useful for logged-in users

Hot Network Questions

  • Logical AND (&&) does not short-circuit correctly in #if
  • Is there any evidence that 八 used to be pronounced bia?
  • Cleaning chain a few links at a time
  • Do capacitor packages make a difference in MLCCs?
  • How many steps are needed to turn one "a" into at least 100,000 "a"s using only the three functions of "select all", "copy" and "paste"?
  • Where does someone go with Tzara'as if they are dwelling in a Ir Miklat?
  • A 90s (maybe) made-for-TV movie (maybe) about a group of trainees on a spaceship. There is some kind of emergency and all experienced officers die
  • Can you help me to identify the aircraft in a 1920s photograph?
  • Is arxiv strictly for new stuff?
  • What was the first game to intentionally use letterboxing to indicate a cutscene?
  • Does it matter if a fuse is on a positive or negative voltage?
  • Do known physical systems all have a unique time evolution?
  • \newrefsegment prints title of bib file
  • How do guitarists remember what note each string represents when fretting?
  • Why is it 'capacité d'observation' (without article) but 'sens de l'observation' (with article)?
  • Is there any other reason to stockpile minerals aside preparing for war?
  • A chess engine in Java: generating white pawn moves - take II
  • Is it possible to complete a Phd on your own?
  • Why depreciation is considered a cost to own a car?
  • Have children's car seats not been proven to be more effective than seat belts alone for kids older than 24 months?
  • Summation not returning a timely result
  • Cloud masking ECOSTRESS LST data
  • Integration of the product of two exponential functions
  • Does Matthew 7:13-14 contradict Luke 13:22-29?

programming for problem solving viva questions and answers

IMAGES

  1. C Programming Viva Questions

    programming for problem solving viva questions and answers

  2. PPS Lab Viva Questions and Answers

    programming for problem solving viva questions and answers

  3. PPS Lab Viva Questions and Answers

    programming for problem solving viva questions and answers

  4. C Programming Viva Questions Answers

    programming for problem solving viva questions and answers

  5. Python important questions for exams

    programming for problem solving viva questions and answers

  6. C Language viva questions and answer

    programming for problem solving viva questions and answers

VIDEO

  1. Making Intentional Choices by Listening to Your Instincts

  2. Bcsl 057 Web Programming Viva questions &Answers

  3. BCSL057 Web Programming Lab Viva Most Important Question Answers

  4. O Level Internet Of Things (IOT) Practical Viva Questions

  5. C++ VIva Questions and Answers

  6. Practical Viva Questions & Answers Basic Electrical & Electronics Engineering

COMMENTS

  1. c programming viva questions

    An algorithm is a step-by-step procedure or set of rules for solving a specific problem. 3: What is a flowchart? Answer: A flowchart is a graphical representation of the steps or actions involved in solving a problem or completing a process. 4: ... Question and Answer (C Programming viva questions) 1:

  2. C Programming Viva Questions

    Download Notes of All Subjects from the Website:https://universityacademy.myinstamojo.comOrhttps://www.universityacademy.in/productsProgramming for Problem S...

  3. PPS Lab Viva Questions and Answers

    Download Notes of All Subjects from the Website:https://universityacademy.myinstamojo.comOrhttps://www.universityacademy.in/productsProgramming for Problem S...

  4. C Programming Viva Questions

    Download Notes from the Website:https://www.universityacademy.in/products Join our official Telegram Channel by the Following Link:https://t.me/universityaca...

  5. Top 50 C Programming Interview Questions and Answers

    1. Why is C called a mid-level programming language? Due to its ability to support both low-level and high-level features, C is considered a middle-level language. It is both an assembly-level language, i.e. a low-level language, and a higher-level language.

  6. C Programming Viva Questions Answers

    C Programming Viva Questions Answer Download (PDF) C Programming Viva Questions Answers Part-1. 1. What is Compiler? Compiler is a program that converts human readable code (source code) into machine readable code, this process is called compilation. 2.

  7. C Programming Viva Questions

    Ans- C is a high-level language and general-purpose structured programming language. 2. What is a compiler? Ans- Compile is a software program that transfer program developed in a high-level language into executable object code. 3. What is an algorithm? Ans- The approach or method that is used to solve the problem is called an algorithm. 4.

  8. 200+ Interview Questions for C Programming

    Q17. Write a C program to swap two variables without using a third variable. This is one of the very common C interview questions. It can be solved in a total of five steps. For this, I have considered two variables as a and b, such that a = 5 and b = 10. #include<stdio.h>. int main(){. int a=5,b=10; a=b+a;

  9. C Language or C Programming Viva Questions

    The main features of C language are given below: Simple: C is a simple language because it follows the structured approach, i.e., a program is broken into parts. Portable: C is highly portable means that once the program is written can be run on any machine with little or no modifications. Mid Level: C is a mid-level programming language as it ...

  10. VIVA 2

    VIVA QUESTIONS & ANSWERS. 1 is Algorithm? A step by step procedure to solve a particular problem. It is a ordered set of rules to solve a problem. finite set of instructions which are being carried in a specific order to perform the specific task. 2 is the need for Algorithm?

  11. Top 100 C Programming Interview Questions and Answers (PDF)

    Likewise, the statement "x -" means to decrement the value of x by 1. Another way of writing increment statements is to use the conventional + plus sign or - minus sign. In the case of "x++", another way to write it is "x = x +1". 👉 Free PDF Download: C Programming Interview Questions & Answers >>.

  12. 45 Common Coding Interview Questions

    P: Plan your approach and solution. I: Implement your solution. R: Review your solution. E: Evaluate your solution. To prepare for a whiteboard challenge, "practice talking through your problem-solving process ," says Archie Payne, president of CalTek Staffing, an IT and technical staffing firm.

  13. 300+ TOP C Language LAB VIVA Questions with Answers Pdf

    A computer program is a collection of the instructions necessary to solve a specific problem. 6. What is an algorithm? ... c programming viva questions and answers pdf :: Author engineer Posted on May 26, 2024 May 26, 2024 Categories CSE VIVA Questions.

  14. C Exercises

    Q2: Write a Program to find the Sum of two numbers entered by the user. In this problem, you have to write a program that adds two numbers and prints their sum on the console screen. For Example, Input: Enter two numbers A and B : 5 2. Output: Sum of A and B is: 7.

  15. PPS Lab Viva Questions and Answers

    Here we publish c program viva question, In this video we will discuss the various fundamental viva question .Wish you good luck.https://youtu.be/8fC4QWjhOm0

  16. C Language viva questions and answer

    C programs part2. C-M4-1. Problem Solving Using C 2019. Problem Solving Using C 2018. Problem Solving Using C 2016. C strings. Practical lab viva questions are in this pdf but every students must learn and refer other sources to get extra marks language questions and answers programming.

  17. 2019 question bank (with answers) for viva

    This document contains a question bank for a viva on the quantitative techniques course Quantitative Techniques in Management (KMB206). It includes 63 multiple choice questions across two units - Introduction to Operations Research and Linear Programming Problem. The questions cover key concepts in operations research models like linear ...

  18. Problems

    Boost your coding interview skills and confidence by practicing real interview questions with LeetCode. Our platform offers a range of essential problems for practice, as well as the latest questions being asked by top-tier companies. ... Interview. Store Study Plan. See all. Array 1678. String 705. Hash Table 613. Dynamic Programming 510. Math ...

  19. Python Viva Question

    Answer: Using a command os.remove(file name / file path) or os.unlink(file name / file path). Q13: How can you access a module written in Python from C? Answer: If we need to access the logic from a module written in the programming C we can use the "PyImport_ImportModule" function with a parameter name as the module name like below:

  20. Programming tutorials, Coding problems, and Practice questions

    Functional Programming. Practice programming skills with tutorials and practice problems of Basic Programming, Data Structures, Algorithms, Math, Machine Learning, Python. HackerEarth is a global hub of 5M+ developers.

  21. PDF C Programming Viva Questions With Answers

    A Collection of Bit Programming Interview Questions Solved in C++ Antonio Gulli,2014-05-22 Bits is the second of a series of 25 Chapters devoted to algorithms, problem solving, and C++ programming. This book is about low level bit programming Cracking the C Programming Skills Shriram K. Vasudevan,R. Sundaram,Abhishek S. Nagarajan,Subashri

  22. Where is programming logic/problem solving learned?

    The problem you're facing now is taking that and applying it to the Unity projects you've got queued up. The other piece to note, which you need to separate, is domain knowledge as it applies to C#. Knowing how to develop in C# and the domain libraries, terms, and concepts for game programming and graphics are different.

  23. PPS Lab Viva Questions and Answers

    C language viva part-3 | JNTUH

  24. Interview Questions and Answers for an IT Engineer

    The incident sharpened my problem-solving skills, affirming the importance of regular system backups and system health checks. What programming languages are you most comfortable with? Sample answer: My professional journey has seen me become proficient in several programming languages including Python, Java and C++. However, Python ranks ...

  25. PPS Lab Viva Questions and Answers

    C language viva part-2 1-10 questions