Intelenet Global Services C Language Interview Questions

Intelenet Global Services Most Frequently Asked C Language Interview Questions Answers

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.

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

int temp;

temp = num1;

num1 = num2;

num2 = temp;

Write a program to print Fibonacci series using recursion?

#include<stdio.h> 
#include<conio.h> 
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.
    } 

void main(){ 
    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(); 

Intelenet Global Services Most Frequently Asked C Language Interview Questions Answers
Intelenet Global Services Most Frequently Asked C Language Interview Questions Answers

Write a program to check prime number in C Programming?

#include<stdio.h> 
#include<conio.h> 
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.
}

Write a program to check palindrome number in C Programming?

#include<stdio.h>
#include<conio.h>
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");
getch();
}

Mention The Characteristics Of Arrays In C?

An array holds elements that have the same data type.
Array elements are stored in subsequent memory locations.
Two-dimensional array elements are stored row by row in subsequent memory locations.
Array name represents the address of the starting element.
Array size should be mentioned in the declaration. Array size must be a constant expression and not a variable.
Differentiate Between A Linker And Linkage?

A linker converts an object code into an executable code by linking together the necessary build in functions. The form and place of declaration where the variable is declared in a program determine the linkage of variable.

What Are The Advantages Of Auto Variables?

The same auto variable name can be used in different blocks.
There is no side effect by changing the values in the blocks.
The memory is economically used.
Auto variables have inherent protection because of local scope.

What Is Storage Class And What Are Storage Variable?

A storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope and linkage. There are five types of storage classes.

auto.
static.
extern.
register.
typedef.

Which Expression Always Return True? Which Always Return False?

expression if (a=0) always return false.
expression if (a=1) always return true.

Post a Comment

Previous Post Next Post