LogoLogo

C Interview Questions — 2022

Prasun Das| July 1, 2022 at 5:50 AM | 3 minutes Read

C is a general purpose high-level language most popular amongst coders, it is the most compatible, easy to learn and effective programming language. It is a successor of the B language that came out way back in the 70s and has been the most popular programming language ever since.

Following are some important C Interview Questions


1. When should we use pointers in a C program?

a. To get address of a variable

b. For achieving pass by reference in C: Pointers allow different functions to share and modify their local variables.

c. To pass large structures so that complete copy of the structure can be avoided.

d. To implement “linked” data structures like linked lists and binary trees.


2.Write a program to print "hello world" without using a semicolon?

Ans: 




3.What is NULL pointer?

Ans: NULL is used to indicate that the pointer doesn’t point to a valid location. Ideally, we should initialize pointers as NULL if we don’t know their value at the time of declaration. Also, we should make a pointer NULL when memory pointed by it is deallocated in the middle of a program.


4.What is Dangling pointer?

Ans: Dangling Pointer is a pointer that doesn’t point to a valid memory location. Dangling pointers arise when an object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory. Following are examples.



5.What is memory leak? Why it should be avoided

Ans: Memory leak occurs when programmers create a memory in heap and forget to delete it. Memory leaks are particularly serious issues for programs like daemons and servers which by definition never terminate.


6.What is difference between i++ and ++i? 

a) The expression ‘i++’ returns the old value and then increments i. The expression ++i increments the value and returns new value. 

b) Precedence of postfix ++ is higher than that of prefix ++. 

c) Associativity of postfix ++ is left to right and associativity of prefix ++ is right to left. 

d) In C++, ++i can be used as l-value, but i++ cannot be. In C, they both cannot be used as l-value. 



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



8.What is typecasting?

The typecasting is a process of converting one data type into another data type. Suppose If we want to store the floating type value to an int type, then we will use typecasting to convert floating point data type into int data type explicitly.

Ex: int i = (int) 3.4


9.Difference between malloc() and calloc() functions?



10.What is dynamic memory allocation?


In dynamic memory allocation, memory is allocated at runtime. We can increase memory while executing the program. The malloc() or calloc() function is used to allocate the memory at the runtime. Dynamic memory allocation is used in linked list.



11.What is static memory allocation?


In static memory allocation, memory is allocated during compile time. And we cannot increase memory while executing the program. Array use the static memory allocation. lifetime of a variable in static memory is the lifetime of the program. It applies to global variables, file scope variables etc.The static memory is implemented using stacks or heap.

For example: int arr[20]; The above example creates an array of integer type, and the size of an array is fixed, i.e., 20.

12.Differentiate between getch() and getche().

Ans. The only difference between the two roles is that one reads characters from the keyboard and the other does not. getch() is a function that reads characters from the keyboard without using any buffers. As a result, no data is shown on the computer. getche() uses a buffer to read characters from the keyboard. As a result, information is shown on the projector.



#c#interview questions#interview preparation#fundamentals to learn
View Count:3.6k
0

Comments

Similar Articles

PWC Placement Experince

PricewaterhouseCooper Pvt Ltd (PwC Pvt Ltd) is a leading multinational professional service network of firms, operating as partnerships under the PwC ......

Cover image

DSA Cheatsheet Curated list (Leetcode)

If you're looking to prepare for a job in the tech industry, Data Structures and Algorithms (DSA) are essential to master. Practising problems on plat......

Cover image

How to Start with DSA

Each and every programmer needs a strong grasp in DSA to write efficient and optimised codes. However, DSA has a reputation of being one of the most f......

Cover image

Campus Placement Roadmap for Batch 2024

Its that time round the calendar again, but different for you all as for the first time now. You all will be facing the on campus placement season.Wit......

Cover image

Busting myths about web3

WHAT IS WEB3?Web3 is the catch-all term for the vision of an upgraded version of the internet aimed at giving power back to the users. It is truly the......

Cover image

Operating System INTERVIEW QUESTIONS

Operating Systems is one of the core subjects for a computer science student. As such a lot of important questions are asked on this subject in interv......

Cover image

Cognizant previous year QnA and Interview Experience

Cognizant helps organizations remain ahead of the competition by modernizing technology, reinventing processes, and redefining customer experiences. I...

Cover image

Cloud Computing Cheatsheet

Getting started with cloud computing ?The words "cloud" and "web" will be interchangeable. What kind of business operates today without the internet? ...

Cover image

Software Engineering — SOFTWARE MAINTENANCE [Part-4]

SOFTWARE MAINTENANCE:Software Maintenance can be defined as the process of modifying a software product after its delivery. The main purpose of softwa...

Cover image

Software Engineering — Software Process Activities [Part - 3]

A quick summary upto what we did this far  from this series:Software EngineeringSoftware engineering is a discipline of engineering concerned wit...

Cover image

Capgemini Previous Year Questions with Study Materials

Capgemini is a global leader in consulting, digital transformation, technology, and engineering services. In the rapidly evolving world of cloud, digi...

Cover image

MINDTREE Interview Experience and Previous Year Questions Part 2

Technical Round :Candidates who pass the online test will be invited to the technical interview...

Cover image

MINDTREE Interview Experience and Previous Year Questions Part 1

About Mindtree:Mindtree Ltd, located in Bangalore, India, is a prominent Indian multinational information technology and outsourcing company. The&nbsp...

Cover image

TCS NQT Latest Questions and Answers

TCS NQT Interview kicks off with the aptitude test. The test follows the following pattern : TCS uses the TCS-iON software for their online aptit...

Cover image

INTERVIEW TIPS AND TRICKS FOR FRESHERS

Increased competition for fewer jobs in the current economy means that just being right for the role on paper, is not enough on its own anymore. You h...

Cover image

TCS NINJA INTERVIEW EXPERIENCE [2023]

About TCS NinjaTCS administers the NQT to select candidates for a variety of positions (National Qualifier Test). Tens of thousands of people apply fo...

Cover image

Understanding Time Complexity with Interview Examples

Introduction:Understanding time complexity of a function is imperative for every programmer to execute a program in the most efficient manner. Time co...

Cover image

Software Engineering — Software Development lifecycle and software process(Part 2)

 Software MethodologyA software methodology (which is also known as software process) is a set of related development Phases that leads to the pr...

Cover image

TCS Digital Interview Experience [2023]

About TCS DigitalTCS selects applicants for a variety of jobs by conducting the NQT (National Qualifier Test). About 10,000-15,000 job applicants subm...

Cover image

Software Engineering [Part 1] - Introduction

Software Engineering is a subject that requires when you are a software developer as well as when you are in your college preparing for a semester or ...

Cover image

SQL Interview Questions

Are you getting ready for your SQL developer job interview?You've come to the correct place.This tutorial will assist you in brushing up on your SQL s...

Cover image

SQL CHEATSHEET

Introduction: What is SQL?To understand SQL, we must first understand databases and database management systems (DBMS).Data is essentially a collectio...

Cover image

TCS NQT Technical Interview Questions

TCS Recruitment ProcessInterview RoundsInterview round 1:  TCS NQTTCS NQT (National Qualifier T...

Cover image

TCS NQT Aptitude Questions

TCS NQT Aptitude has three sections, namely the Numerical Ability, Verbal Ability, and Reasoning Abi...

Cover image

TCS NQT Interview Experience [2023]

About TCS NQTTCS NQTs, also known as TCS National Qualifier Tests or Tata Consultancy Services Natio...

Cover image

Computer Networking Cheatsheet (Last Minute Notes)

 Networking: Importance in real life!Using a computer for work, as well as for personal use, ha...

Cover image

Database Management System Last Minute Notes [Part - 2]

ER-DiagramWhat are ER Models ?An Entity Relationship Diagram (ERD) is a visual representation of dif...

Cover image

Database Management System Last Minute Notes [Part - 1]

What is actually DBMS?A Database Management System (DBMS) is system software used to manage the orga...

Cover image

Final year Placement Roadmap in India

Nowadays students tend to go more for off campus placements rather than on campus placements.One of ...

Cover image

C Cheatsheet

C CHEATSHEETINTRODUCTION:C programming language was developed by Dennis Ritchie of Bell Labs in 1972...

Cover image

Cognizant GenC Next Interview

What is GenC and GenC Next?GenC stands for Generation Cognizant. It basically means the fresher hiri...

Cover image

C++ STL Cheat Sheet

C++ programming language has templates which basically allows functions and classes to work with gen...

Cover image

C++ CHEAT SHEET

C++ was conceived in the late 1970s to overcome the limitations of C. It  is an extension of th...

Cover image

Python [Advanced] Interview Questions — 2022

Interview Questions are a great source to test your knowledge about any specific field. But remember...

Cover image

Basic Python [Core] Interview Questions for Freshers and Short Sample Answers — 2022

The most popular high-level, multipurpose programming language right now is Python.Python supports p...

Cover image

Python Cheat Sheet - Learn the basics of Python

IntroductionPython is a high-level programming language with dynamic binding and high-level inherent...

Cover image

Basic Java Interview Questions for Freshers and Short Sample Answers — 2022

Interview Questions are a great source to test your knowledge about any specific field. But remember...

Cover image

Java OOP Cheat Sheet — A Quick Guide to Object-Oriented Programming in Java

Object-Oriented Programming or better known as OOPs is one of the major pillars of Java that has lev...

Cover image

Learn Java: Basics to Advanced Concepts [Java Cheatsheet]

Java is a high-level programming language known for its robustness, object-oriented nature, enhanced...

Cover image

A Complete Roadmap for On-Campus Placements

Placements are an important part of engineering life, and while everyone hopes to be placed in a reputable company, only a few are successful. This is primarily due to a...

Cover image