In this article, you will find basic to most puzzled interview queries questions. This article is very useful for those who are preparing for an interview in IT company. Whether you are experienced or fresher, this article will cover all C programming interview questions from basic to advanced level.
1 2 3 4 |
#include <stdio.h> void main(void) { printf("Hello World"); //printing a string } |
A preprocessor directive starts from # in C and is used to modify C program. The preprocessor directive is not a part of the compiler but is an instruction to compiler before the program is executed to include header files. In short, pre-processing is done when # is used.
In C programming, we have:
Single line comment in C can be added using double slash //.
Example:
// This is Single line comment
Multi-Line comments in C can be added using /* at beginning and */ and ending of the comment.
Example:
/* This is
Multi line comment */
Keywords are the reserved words that are predefined and have special meaning and purpose whereas, identifiers are the names of user-defined functions, variables, and constants, etc.
A variable is the one whose value can be changed as the name says during the execution of the program. The value of a constant cannot be changed once it is defined.
The following are some of the keywords in C:
while: is used to use the while loop in C.
default: is used in switch statement. When all the cases are false, the default part is executed.
int: is used to declare a variable of integer type.
void: is a data type which means nothing.
When declaring variables data types are used to specify the type of the variable and to reserve space in memory according to type of variable. The following are some of the data types in C:
To specify the data type and name of variable is called variable declaration. A variable can be declared in C as follows:
int blue;
Here int is data type and blue is the name of variable.
Declaring and initializing a variable is called definition of variable.
Variables in same scope cannot have same name but variables in different scope can have same names.
In C programming, data can be displayed on output screen using printf() statement. The syntax of printf() is as follows:
printf("format string", variableName);
format string can have a message that you want to display and format specifiers and escape sequences. Format specifiers are for value of variable.
format string can have a message that you want to display and format specifiers and escape sequences. Format specifiers are for value of variable.
You can get user input by using the scanf() statement. The syntax of scanf() is as follows:
scanf("format string", &variableName);
Strings can be read from output screen by using the gets() function and you can display strings on output screen by using puts() statement.
The & operator is an address operator. The & operator ensures to store the entered value into the corresponding memory location.
23 January 2019 2275 Written By: Rohit
Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer & technology lovers. http://www.techstudy.org/.
© 2020 Tech Study. All rights reserved |
Developed by Tech Study| Privacy Policy
| Sitemap |