0 ratings0% found this document useful (0 votes) 27 views31 pagesC Programming Interview Question
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
‘1123/01, 7-48 PM Programming Inierview Questions (2021) -javatpoint
C Programming Interview Questions
C Programming
CS Interview
Questions
A list of 50 top frequently asked C programming interview questions and answers are given below.
1) What is C language?
Cis 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. More details.
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. More details.
3) Why is C called a mid-level programming language?
Cis 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. More details.
SCROLL TO TOP
htpsswwjavatpointcomvinterview-questions‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
4) Who is the founder of C language?
Dennis Ritchie. More details
5) When was C language developed?
C language was developed in 1972 at bell laboratories of AT&T. More details.
6) What are the features of the C language?
The main features of C language are given below:
ple: C is a simple language because it follows the structured approach, ie, a program is
broken into parts
© Portable: C is highly portable means that once the program is written can be run on any
le or no modifications.
htpsswwjavatpointcomvinterview-questions a6‘1129908, 748 PME Programming Inierview Questions (2021) -javatpoint
© 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
More details.
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: Itis a format specifier used to print a string,
© %e:Itis 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.
More details.
8) What is the difference between the local variable and global variable in
Cc?
Following are the differences between a local variable and global variable:
Basis for Local variable Global variable
comparison
htpsswwjavatpointcomvinterview-questions 4136‘asia, 748 PME
Declaration
Scope
Access
Life
Storage
More details.
Programming Inierview Questions (2021) -javatpoint
A variable which is declared inside
function or block is known as a local
variable,
The scope of a variable is available within
a function in which they are declared,
Variables can be accessed only by those
statements inside a function in which they
are declared.
Life of a variable is created when the
function block is entered and destroyed
on its exit.
Variables are stored in a stack unless
specified.
9) What is the use of a static variable in C?
A variable which is declared outside
function or block is known as a
global variable.
The scope of a variable is available
throughout the program
Any statement in the entire program
can access variables.
Life of a variable exists until the
program is executing.
The compiler decides the storage
location of a variable.
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
2 can access a static variable anywhere in the program.
htpsswwjavatpointcomvinterview-questions‘1129908, 748 PME Programming Inierview Questions (2021) -javatpoint
© 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.
More details.
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, ie, it breaks the big task into smaller tasks so
that it makes the C program more understandable
More details.
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 value Call by reference
Description When a copy of the value is passed to When a copy of the value is passed to
the function, then the original value is the function, then the original value is
not modified, modified
Memory Actual arguments and formal arguments Actual arguments and _—_ formal
location are created in separate memory arguments are created in the same
locations memory location.
Safety In this case, actual arguments remain In this case, actual arguments are not
+s they cannot be modified.
htpsswwjavatpointcomvinterview-questions
reliable, as they are modified
66‘asia, 748 PME (Programming Interview Questons (2021) -javatpoint
Arguments The copies of the actual arguments are The addresses of actual arguments are
passed to the formal arguments. passed to their respective formal
arguments.
Example of call by value:
Hinclude
void change(int,int);
int maing
{
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;
}
Value
Value of b 20
Example of call by reference:
ROLL TO TOP
htpsswwjavatpointcomvinterview-questions
7136‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
#include
void change(int*,int*);
int maind)
{
int a=10,b=20;
change(8a,8b); // calling a function by passing references of variables.
printf("Value of a is: %d",a);
printf("\n");
printf(*Value of b is: 96d",b);
return 0;
}
void change(int *xint *y)
{
*x=13;
*y=17;
Output:
Value of
s: 2B
Value of b
CROLL TO TOP
htpsswwjavatpointcomvinterview-questions‘ines, 748 PM Programming Interview Questions (202%) -jvatpoint
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:
1. Winding phase
2, 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
#include
int calculate fact(int);
int maing
{
int n=5,f,
f=calculate_fact(n); // calling a function
printf("factorial of a number is %d"
return 0;
}
int calculate_fact(int a)
{
ifla
{
return 1;
ROLL TO TOP
htpsswoujavatpointcominterview-questions‘vaas, 748 PM Programming Interview Questons (2021) jvatpoint
else
return a*calculate_fact(a-1); //calling a function recursively.
}
Output:
More details.
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.
Syntax:
data type array_namesize];
© Multidimensional array: Multidimensional array is an array that contains more than one
htpsswwjavatpointcomvinterview-questions 1096‘12321, 748 PM € Programming Interview Questons (2021 -javatpoint
Syntax:
data type array_name{size);
Example of an array:
Hinclude
int maind
{
int arr{5}=(1,2,3,4.5); //an array consists of five integer values.
for(int i=0i<5;i++)
{
printf("%ed "arti
)
return 0;
Output:
12345
More details.
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
ROLL TO TOP
htpsswwjavatpointcomvinterview-questions nn6‘1129908, 748 PME Programming Inierview Questions (2021) -javatpoint
Example of pointer
#include
int maino)
{
int *p; //pointer of type integer.
int a=5;
p=8a;
printf("Address value of 'a' variable is %u",p);
return 0;
Output:
More details.
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, ete.: 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
value to a pointer of any type, then it becomes a Null pointer.
htpsswwjavatpointcomvinterview-questions 1296‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
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
void maing
{
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, ie., 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
#include
void maind
{
malloc(constant value); //allocating a memory space.
ptr becomes a dangling pointer.
1
tps: ww javatpointcomcinterview-questions 19196‘ines, 748 PM Programming Interview Questions (202%) -jvatpoint
ptr=NUI
//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:
#include
int main
{
int a=10;
int *ptr,“*pptr; // *ptr is a pointer and **pptr is a double pointer.
ptr=8a;
pptr=8ptr;
printf("value of a is:%d",a);
printf("\n");
printf(‘value of *ptr i
printf("\n");
printf(’value of **pptris : 96d",**pptr);
:%d"*ptr);
return 0;
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.
More details.
ROLL TO Top ¢ memory allocation?
htpsswwjavatpointcomvinterview-questions 14196‘1129908, 748 PME Programming Inierview Questions (2021) -javatpoint
© 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.
© Instatic 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, Le, 10.
More details.
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. Itis used in the linked list.
© The malloc( or calloc() function is required to allocate the memory at the runtime.
© Anallocation 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.
More details.
htpsswwjavatpointcomvinterview-questions 1996‘1129908, 748 PME Programming Inierview Questions (2021) -javatpoint
22) What functions are used for dynamic memory allocation in C language?
1. malloc)
© 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.
© Itretums a null pointer if it could not be able to allocate the requested space.
Syntax
ptr = (cast-type*) malloc(byte-size) // allocating the memory using malloc() function.
2. calloci)
© The calloc( is same as malloc() function, but the difference only is that it initializes the
memory with zero value
Syntax
ptr = (cast-type)calloc(n, element-size);// allocating the memory using calloc() function.
3, realloc)
© 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.
Syntax
ptr = realloc(ptr, newsize); // updating the memory size using realloc( function
In the above syntax, ptr is allocated to a new size.
4, free():The free() function releases the memory allocated by either calloc() or malloc() function.
Syntax
freafnte\ 1 memory is released using free() function
htpsswwjavatpointcomvinterview-questions 1696‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
The above syntax releases the memory from a pointer variable ptr.
More details.
23) What is the difference between malloc() and calloc()?
calloc() malloc()
Description The malloc) function allocates a The calloc( function allocates multiple
single block of requested memory. _ blocks of requested memory.
Initialization It initializes the content of the It does not initialize the content of
memory to zero. memory, so it carries the garbage value
Number of It consists of two arguments. It consists of only one argument.
arguments
Return It returns a pointer pointing to the It returns a pointer pointing to the
value allocated memory. allocated memory.
More details.
24) What is the structure?
© The structure is a user-defined data type that allows storing multiple types of data ina single
unit, It occupies the sum of the memory of all members.
embers can be accessed only through structure variables,
htpsswwjavatpointcomvinterview-questions 796‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
© 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
ple exampl
#include
struct student
{
char name[10]; _// structure members declaration.
tage;
jst; //structure variable
int maind)
{
printf("Enter the name");
scanf('%s",s1.name);
printf(‘\n"s;
print("Enter the age");
scanf("
printf
printf(’Name and age of a student: %s,%d",s .name,s1.age);
return 0;
Outout:
htpsswwjavatpointcomvinterview-questions
1896‘1129908, 748 PME
More details.
25) What is a union?
Programming Inierview Questions (2021) -javatpoint
© 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
union data
{
int a; //union members declaration,
float b;
char ch;
: .
tps: javatpointcominterview-questions
1996‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
{
union data d; —_ //union variable.
printf(’value of a is %d"d.a);
printf("\n");
printf(’value of b is %f",d.b);
printf("\n");
print{("value of ch is %c",d.ch);
return 0;
value of ch is a
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.
More details.
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?
ROLL TO TOP
htpsswwjavatpointcomvinterview-questions 20836‘ines, 748 PM Programming Interview Questions (202%) -jvatpoint
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.
Syntax
int sprintf ( char * str, const char * format, ..)
Let's see a simple example
#include
int maing)
rintf(a,"javaToint");
printf("value of n is %d",n);
return 0;)
Output:
value
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 main0 function, For
example
#include
#define start main
void start() {
printf("Hello");
ROLL TO TOP
htpsswwjavatpointcomvinterview-questions 298‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
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:
1. Identifiers: Identifiers refer to the name of the variables.
2. Keywords: Keywords are the predefined words that are explained by the compiler.
3. Constants: Constants are the fixed values that cannot be changed during the execution of a
program.
4, Operators: An operator is a symbol that performs the particular operation.
5, 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:
int count, char *args{]){
//code to be executed
}
More details.
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(Q) function reads a single character from the keyboard. It doesn't use any buffer, so
be displayed on the output screen
htpsswwjavatpointcomvinterview-questions 2236‘ines, 748 PM Programming Interview Questions (202%) -jvatpoint
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.
Let's see a simple example
#include
#include
int maing)
{
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=getcheQ; // taking an user input and then displaying it on the screen.
printf(’\nvalue of ch is %c’,ch);
return 0;
}
Output:
enter
Enter
value
In the above example, the value entered through a getch0) 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
ROLL TO TOP
htpsswwjavatpointcomvinterview-questions 236‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
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?
Avirtual 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?
itis 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.
Syntax
(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?
OLL TO TOP
ase address of array into a pointer, we can access the array using a pointer.
htpsswwjavatpointcomvinterview-questions 2098‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
40) What is an infinite loop?
A loop running continuously for an indefinite number of times is called the infinite loop.
Infinite For Loop:
forint
/Icode to be executed
}
Infinite WI
Loop:
while(1){
//code to be executed
}
Infinite Do-While Loop:
dot
//code to be executed
Jwhile(1);
41) Write a program to print "hello world" without using a semicolon?
#include
void main
if(printf(‘hello world")){} // It prints the ?hello world? on the screen.
}
More details.
OLL TO TOP
htpsswwjavatpointcomvinterview-questions
25136‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
42) Write a program to swap two numbers without using the third variable?
#include
#include
maind
(
int a=10, b=20; //declaration of variables.
cirscrQ; _//lt clears the screen.
printf(’Before swap a=%d b=%d" a,b);
=a+bj//a=30 (10+20)
b=a-b;//b=10 (30-20)
-b;//a=20 (30-10)
printf("\nAfter swap a=%d b=%d"ab);
getch0;
}
More details.
43) Write a program to print Fibonacci series without using recursion?
#include
#include
void main(,
{
int n1=0,n2=1,n3,,number;
clrscr;
printf("Enter the number of elements");
scanf("%d" number);
printf(’\n%d %d",n1,n2);//printing 0 and 1
for(i=2:icnumber;++i)//loop starts from 2 because 0 and 1 are already printed
OLL TO TOP
htpsswoujavatpointcominterview-questions‘ays, 748 PM © Programming Interview Questons (2021) -jvatpoint
n3=n1+n2;
printf(® %d",n3);
nt=n2;
n2=n3;
}
getcho;
)
More details.
44) Write a program to print Fibonacci series using recursion?
#include
#include
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= nt +2;
nt = n2;
n2 = n3;
printf("%d "n3);
printFibonacci(n-1); _ //calling the function recursively.
}
void main0{
intn;
clrser(;
printf("“Enter the number of elements: ");
scanf("%d",8an);
printf("Fibonacci Series:
printf("%d %d “,0,1);
printFibonacci(n-2);//n-2 because 2 numbers are already printed
OLL TO TOP
Me
htpsswwjavatpoint comcinterview-questions 27198‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
1
More details.
45) Write a program to check prime number in C Programming?
#include
#include
void main)
(
int n,m=0,flag=0; //declaration of variables.
clrscr(; _//It clears the screen.
printf("Enter the number to check primes");
scanf("%d",8n);
m=n/2;
for(i=2;i<=1
(
if(n%i==0)
(
printf(’Number is not prime");
myi++)
flag=1;
break; //break keyword used to terminate from the loop.
)
}
if(flag==0)
printf("Number is prime");
getch0; _//It reads a character from the keyword.
}
More details.
46) Write a program to check palindrome number in C Programming?
+#include
OLL TO TOP
htpsswwjavatpoint comv-interview-questions 2036‘asia, 748 PME Programming Interview Questons (2021) -javatpoint
{
int nysum=0,temp;
dlrser();
printf(“enter the number
scanf("%d",8n);
temp=n;
while(n>0)
{
r=n%10;
sum=(sum*10)+r;
printf("palindrome number ");
else
printf("not palindrome");
getch0;
}
More details.
47) Write a program to print factorial of
recursion?
#include
#include
void main0{
ifact=1,number,
clrser(;
printf(“Enter a number: ");
scanf("%d number);
for
ji<=numberi+ +)
OLL TO TOP
1
htpsswwujavatpoint cominterview-questions
given number without using
20836‘asian, 748 PM {Programming Interview Questions (2021) -javtpoint
printf(’Factorial of %d is: 9d" number fact);
getch0;
}
More details.
48) Write a program to print factorial of given number using recursion?
#include
#include
long factorial(int n) _// function to calculate the factorial of a given number.
{
(n == 0)
return 1;
else
return(n * factorial(n-1)); _//calling the function recursively.
}
void main
{
int number; //declaration of variables.
long fact;
clrscrQ;
printf("Enter a number: ");
scanf("%d", &number);
fact = factorial(number); _//calling a function.
printf(’Factorial of %d is %ld\n", number, fact);
getch0; //It reads a character from the keyword.
}
More details.
49) Write a program to check Armstrong number in C?
htpsswwjavatpoint comv-interview-questions 036‘ines, 748 PM Programming Interview Questions (202%) -jvatpoint
main()
{
int nsum=0,temp; _//declaration of variables.
clrscrQ; //It clears the screen.
printf("enter the number=
scanf(‘%dl"
temp=n;
while(n>0)
{
r=n%10;
sum=sums(r*r*1);
n=n/10;
printf(‘armstrong number");
else
printf(’not armstrong number’);
getchQ; //It reads a character from the keyword
}
More details.
50) Write a program to reverse a given number in C?
#include
#include
main
{
int n, reverse=0, rem; //declaration of variables.
clrscr(); // It clears the screen.
printf("Enter a number: ");
scanf("%d", Bin);
while(n!=0)
OLL TO TOP
bee
htpsswwjavatpoint comv-interview-questions a8‘asia, 748 PME
reverse=reverse*10+rem;
n/=10;
}
printf("Reversed Number: %d",reverse);
getch0; // It reads a character from the keyword.
}
More details.
Java Interview Que:
Java Multithreading Questions
Java Collection Interview Questions
Servlet Interview Questions
Spring Interview Questions
PL/SQL Interview Questions
Oracle Interview Questions
SQL Server Interview Questions
You mav also like:
SCROLL TO TOP
uestions
htpsswwjavatpointcomvinterview-questions
Programming Inierview Questions (2021) -javatpoint
C++ Interview Questions
Java String & Exception Questions
JDBC Interview Questions
JSP Interview Questions
Hibernate Interview Questions
SQL Interview Questions
Android Interview Questions
MySQL Interview Questions
a236