Saturday, 22 February 2014

write a program tocheck whether entered character is uppercase lowercase,integer,special character.


/*check whether entered character is uppercase lowercase,integer,special character*/
#include<stdio.h>
main()
{
char ch,x;

printf("enter the character:");
scanf("%c",&ch);
x=ch;
(x>=65 && x<91)?(printf("uppercase\n")):((x>=97 && x<122)?printf("lowercase\n"):((x>=48 && x<57)?printf("Integer\n"):printf("special character")));

}

write a program that accept marks in five subject and calculate percentage and respective grade


/*write a program that accept marks in five subject and calculate percentage and respective grade*/
#include<stdio.h>
main()
{
int a,b,c,d,e;
float per;
printf("enter marks in first subject:");
scanf("%d",&a);
printf("enter marks in 2nd subject:");
scanf("%d",&b);
printf("enter marks in 3rd subject:");
scanf("%d",&c);
printf("enter marks in 4th subject:");
scanf("%d",&d);
printf("enter marks in 5th subject:");
scanf("%d",&e);
per=(a+b+c+d+e)/(float)5;
printf("percentage=%f\n",per);
if(per<40)
{
printf("fail\n");
}
if(per<50)
{
printf("third\n");
}
if(per<60)
{
printf("second\n");
}
if(per<70)
{
printf("first\n");
}
}


Friday, 21 February 2014

C-test-2

             
           C-test-2 ...........................................................................Start Test

Wednesday, 19 February 2014

write a program to find area of equilateral triangle.


#include<stdio.h>
main()
{
float side,area;
printf("enter the side of equilateral:");
scanf("%f",&side);
area=1.73/4*(side*side);
printf("area of equilateral triangle =%f",area);
}

write a program to find the area of a parallelogram


#include<stdio.h>
main()
{
float base,height,area;
printf("enter the base and height of parallelogram:");
scanf(" %f%f",&base,&height);
area=base*height;
printf("area of parallelogram=%f\n",area);
}

write a program to find radius of circum-circle in a equilateral triangle of given side.


#include<stdio.h>
main()
{
float a,circumcircle;
printf("enter the side of equilateral triangle:");
scanf("%f",&a);
circumcircle=a/1.73;
printf("radius of circumcircle of a equilateral triangle of side a:%f",circumcircle);
}

write a program to find radius of incircle of equilateral triangle of given side.


#include<stdio.h>
main()
{
float a,rad_of_incircle;
printf("enter the side of equilateral triangle:");
scanf("%f",&a);
rad_of_incircle=a/(2*1.73);
printf("radius of incircle of an equilateral triangle of side a:%f",rad_of_incircle);
}

write a program to find the area and perimeter of a rectangle.


include<stdio.h>
main()
{
   float len,bre,area,peri;
   printf("enter the length and breadth of a rectangle:",len,bre);
   scanf(" %f%f",&len,&bre);
   area=(len*bre);
   peri=2*(len+bre);
   printf("area of a rectangle =%f\n",area);
   printf("perimeter of rectangle=%f\n",peri);
}

write a program to find area of rhombus.


#include<stdio.h>
main()
{
float diagonal ,area;
printf("enter the diagonal of rhombus:");
scanf(" %f",&diagonal);
area=1.0/2*(diagonal*diagonal);
printf("area of rhombus=%f",area);
}

write a program to find the area and circumference of semi-circle.


#include<stdio.h>
main()
{
float rad,area,peri;
printf("enter the radius of semi-circle:");
scanf("%f",&rad);
area=(3.14*rad*rad)/2;
peri=3.14*rad;
printf("area of semi-circle=%f\n:",area);
printf("circumference of a semi-circle=%f:\n",peri);
}

write a program to find the area of triangle.


#include<stdio.h>
main()
{
float base,height,area;
printf("enter the base and height of triangle:");
scanf(" %f %f",&base,&height);
area=(1.0/2.0*(base*height));
printf("area of triangle= %f\n",area);
}

write a program to find the area of trapezium.


#include<stdio.h>

main()
{
float side1,side2,dist_side,area;
printf("enter the side1:");
scanf("%f",&side1);
printf("enter the side2:");
scanf("%f",&side2);
printf("enter the distance between parallel side:");
scanf("%f",&dist_side);
area=1.0/2*(side1+side2)*dist_side;
printf("area of trapezium=%f ",area);
}

write a program to find the area of square.


#include<stdio.h>
main()
{
float side,area;
printf("enter the side of a square:");
scanf("%f",&side);
area=side*side;
printf("area of square= %f",area);
}

Program on Area and Volume

write a program to find area and perimeter of circle.

#include<stdio.h>
main( )
{
float rad,area,perimeter;
printf("enter radius of a circle:");
scanf("%f",&rad);
area=3.14*rad*rad;
perimeter=2*3.14*rad;
printf(" Area of circle =%f  and Perimeter =%f",area,perimeter);
}

Program on Function

write a program to find factorial of a entered number using function.


/* write a program to find factorial of a number*/
#include<stdio.h>
int fact(int);
main()
{
int num;
printf("enter the number:");
scanf("%d",&num);
printf(" factorial=%d",fact(num));
return 0;
}
int fact(int n)
{
int i ,res=1;
if(n==0)
return 1;
else
for(i=1;i<=n;i++)
{
res*=i;
}
return res;
}

write a program to check one string is found in other string or not using function(without using library function).


/* write a program to make a function to compare two string */
#include<stdio.h>
 char * xstrstr(char *,char *);
  main()
{
char s1[100],s2[100],*p;
puts("enter the first string:");
gets(s1);
puts("enter the second string:");
gets(s2);
p=s1;
if(xstrstr(p,s2)==NULL)

{
printf("%s  not found in %s",s2,s1);
}
else
{
printf("%s is found in %s",s2,s1);
}
}

char * xstrstr(char*s1, char*s2)
{
int i,j;
for(i=0;s1[i];i++)
{
if(s1[i]==s2[0])
{
  for(j=1;s2[j];j++)
  {
    if(s1[i+j]!=s2[j])
      break;
}
     if(s2[j]=='\0')
    break;
}
}
if(s1[i]=='\0')
  return NULL;
else 
return s1+i;
}


write a program to check entered number is even or odd using function.


# include<stdio.h>
void check(int);
main()
{
int num;
printf("enter the number:");
scanf("%d",&num);
check(num);
return 0;
}
void check(int n)
{
if(n%2==0)
{
printf("%d is even number",n);
}
else
{
printf("%d is odd number\n",n);
}
}

write a program to find how many time a character occure in a string using functon (without use of predefined library functon).


#include<stdio.h>
int xstrchr(char*,char);
int main()
{
char s[100],ch,*p;
int n;
printf("enter the string:\t");
gets(s);
printf("enter the character:");
scanf("%c",&ch);
n=xstrchr(s,ch);
printf("character %c is found %d times in given string",ch,n);
return  0;
}
int xstrchr(char*s,char ch)
{
int i,j,num=0;
for(i=0;s[i];i++)
{
if(s[i]==ch)
{
num++;
}
}
return num;
}

write a program to copy one string to other string using function .(without use of predefined library function).


/* write a program to make a function to copy a string*/
#include<stdio.h>
#include<stdio.h>
char*fstrcpy(char*,char*);
main()
{
char s1[100],s2[100],*p,temp[100]={0};
puts("enter first string:");
gets(s1);
puts("enter the second string:");
gets(s2);
p=s1;
p=fstrcpy(p,s2);
printf("%s",p);
}  // end of main function

char*fstrcpy(char*s1,char*s2)
{
int i,n;
n=strlen(s1);
for(i=0;i<n;i++)
{        
                            
s1[i]=s2[i];
}

return s1;
}

write a program to find length of string using function(without use of string library function)


#include<stdio.h>
int xstrlen(char*s1);
main()
{
char s[100],*p;
int len;
puts("enter the character:");
gets(s);
len=xstrlen(s);
printf("length of strings is %d \n",len); 
return 0;
}
int xstrlen(char*s1) 

{
int n=0 ,i;
for(i=0;s1[i];i++)

{
n++;

}
return n;
}

Tuesday, 18 February 2014

write a program to find prime number in a given range.


/* c code to find prime number in a given range*/
#include<stdio.h>
main()
{
int i,num,deep;
int min,max;
printf("enter the min number");
scanf("%d",&min);
printf("enter the max number");
scanf("%d",&max);
printf("the prime  number in a given range is :");
for(num=min;num<=max;num++)
{
deep=num;
for(i=2;i<deep;i++)
{
if(deep%i==0)
{
break;
}
}
if(num==i)
{
printf("%d\n",num);
}
}
}

write a program to check entered number is prime number or not.


/* c code for prime number*/
#include<stdio.h>
main()
{
int num,i;
printf("enter the number");
scanf("%d",&num);
for(i=2;i<num;i++)
{
if(num%i==0)
{
break;
}
}
if(num==i)
{
printf("number you entered is prime number");
}
else
{
printf("number you entered is not a prime number");

}
}

write a program to check entered number is perfect number or not.


/* write a  code for perfect number*/
#include<stdio.h>
main()
{
int i,num,sum=0;
printf("enter the number");
scanf("%d",&num);
for(i=1;i<num;i++)
{
if(num%i==0)
{
sum=sum+i;
}}
if(sum==num)
{
printf("perfect number");
}
else
{
printf("not a perfect number");
}

}

write a program to check entered character is alphabet or non alphabet.


#include<stdio.h>
main()
{
char ch;
int x;
printf("enter the character:");
scanf("%c",&ch);
x=ch;
(x>=65 && x<=122)?printf("ALPHABET\n"):printf("NOT A ALPHABET\n");
}

write a program to find the number of even or odd number in entered array.


#include<stdio.h>
main()
{
int arr[10],even=0,odd=0;
int i;
for(i=0;i<10;i++)
{
printf("enter a number for array arr[%d]:",i);
scanf("%d",&arr[i]);
 if(arr[i]%2==0)
even++;
else
odd++;
}
printf("no. of even number is %d and number of odd number is %d\n",even,odd);
}

write a program to find number of occrance of character in a entered array


#include<stdio.h>
main()
{
char a[10];
char ch;
int i,count=0;
for(i=0;i<10;i++)
{
printf("enter the character in array a[%d]=",i);
scanf(" %c",&a[i]);
}
printf("enter the charcter u want to search:");
scanf(" %c",&ch);
for(i=0;i<10;i++)
{
if(a[i]==ch)
{
count++;
}
}
printf("number of occurance of your entered character is %d",count);
}

Thursday, 13 February 2014

write a program to print pattern 2.

write a program to print a pattern like                     *
                                                                          * *
                                                                       * * *  
                                                                    * * * *
                                                                 * * * * *

#include<stdio.h>
main()
{
int n,i,j;
printf("n:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=n;j>=1;j--)
{
if(j>i)
printf(" ");
else
printf("*");
}
printf("\n");
}
}

write a program to print pattern1.

/*     write a program to print pattern like          *   *   *   *   *
                                                                            *   *   *   *
                                                                                 *   *   *
                                                                                      *   *
                                                                                           *


#include<stdio.h>
main()
{
int n,i,j;
printf("enter the number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<i;j++)
{
printf(" ");
}
for(j=0;j<=n-i;j++)
{
printf("*");
}
printf("\n");
}
}

write a program to print hourglass pattern.

             *     *     * 
                 *    *
                    *
                 *    *
             *     *    *
      /* write a program to print star in hour glass*/
#include<stdio.h>
main()
{
int n,j,i;
printf("enter the number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<i;j++)
{
printf(" ");
}
for(j=0;j<=n-i;j++)
{
printf("* ");
}
printf("\n");
}

for(i=1;i<n;i++)
{
for(j=1;j<n-i;j++)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
printf("* ");
}
printf("\n");
}
}

write a program to print rhombus


/* write a program to print rhombus                       * 
                                                                              *     *
                                                                            *    *   *
                                                                              *     *            
                                                                                  *
#include<stdio.h>
main()
{
int n,i,j;
printf("enter the number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf(" ");  //loop for spaces
}
for(j=1;j<=i;j++)
{
printf("* ");    //after star there is a single space required
}
printf("\n");
}
for(i=1;i<n;i++)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(j=1;j<=n-i;j++)
{
printf("* ");   //after star there is a single space required
}
printf("\n");
}
}


//program is tested on gcc compiler

Program on Pattern

write a program to input 10 character into array and calculate the no.of alphabets,numeric,and special character


/* input 10 character into array and calculate the no.of alphabets,numeric,and special character*/
#include<stdio.h>
main()
{
char a[10];
int i,x=0,y=0,z=0;
for(i=0;i<10;i++)
{
printf("enter the array of character a[%d] =",i);
scanf(" %c",&a[i]);
}
for(i=0;i<10;i++)
{
if(a[i]>=48 && a[i]<=57)
{
x++;}
else if((a[i]>=65 && a[i]<=90)||(a[i]>=97 &&a[i]<=122))
{
y++;
}
else
{
z++;
}
}
printf("number of numeric char is %d\n:",x);
printf("number of alphabet char is %d\n:",y);
printf("number of special char is %d\n:",z);
}

Wednesday, 12 February 2014

Program on Array

write a program to find whether your cpu follow Little endian or Big endian .


#include<stdio.h>
main()
{
int v=1,bit;
char  *p;
char temp;
p=&v;
(*p==1)?printf("your cpu follow little endian\n"):printf("your cpu follow big endian\n");
for(bit=31;bit>=0;bit--)
{
printf("%d",(v>>bit)&1);
if(bit%8==0)
{
printf(" ");
}
}
printf("\n");
temp=*p;
*p=*(p+3);
*(p+3)=temp;
temp=*(p+2);
*(p+2)=*(p+1);
*(p+1)=temp;
(*p==1)?printf("now your cpu follow little endian\n"):printf("now your cpu follow big endian\n");
for(bit=31;bit>=0;bit--)
{
printf("%d",(v>>bit)&1);
if(bit%8==0)
{
printf(" ");
}
}

}

write a program to swap two number without third variable.


/*swap a number without third variable*/
#include<stdio.h>
main()
{
int a,b;
printf("enter the first number:");
scanf("%d",&a);
printf("enter the second number:");
scanf("%d",&b);
a=a+b;
b=a-b;
a=a-b;
printf("a=%d b=%d",a,b);
}

write a program to convert temperature from celcius to fahrenheit


/* wp to convert temp. in celcius into fahrenheit*/
#include<stdio.h>
main()
{
int temp;
float fahrenheit;
printf("enter the temp in celsius:");
scanf("%d",&temp);
fahrenheit=(30+1.81*temp);
printf("fahrenheit=%f\n",fahrenheit);
}

write a program to swap two strings.



#include<stdio.h>
#include<string.h>

main()
{
char s1[10]="welcome";
char s2[10]="guest";
char temp[10];
strcpy(temp, s1);
strcpy(s1, s2);
strcpy(s2 ,temp);
}
printf("%s %s",s1,s2);
}
output:s1=guest
          s2=welcome

Program on String

Tuesday, 11 February 2014

online test




write a program to convert binary to decimal number

/* write a program to convert binary to decimal*/
#include<stdio.h>
main()
{
int n,temp,j=1,sum=0,rem,d;
printf("enter the binary number:");
scanf("%d",&n);
temp=n;
while(n)
{
rem=n%10;
d=rem*j;
sum=sum+d;
j=j*2;
n=n/10;
}
printf("%d",sum);
}

write a program to find largest of three number.

/* find largest of three */
#include<stdio.h>
main()
{
int a,b,c;
printf("enter three number:");
scanf(" %d %d %d",&a,&b,&c);
if(a>b)
{
if(a>c)

printf("a is bigger\n");

else

printf("c is bigger\n");

}
else
{
if(b>c)

printf("b is bigger");

else

printf("c is bigger");

}
}

write a program to find a factorial of a entered number.

/*wp for factorial of a entered number*/
#include<stdio.h>
main()
{
int n, a,b,fact=1;
printf("enter the number:");
scanf("%d",&n);
for(a=1;a<=n;a++)
{
fact=fact*a;
}
printf("factorial=%d\n",fact);
}

Basic program list


Write a program to find perfect number in given range.
write a program to find whether your cpu follow Little endian or Big endian .









write a program to find area and perimeter of a circle.

/* wp to find area and perimeter of a circle */
#include<stdio.h>
main()
{
float rad,area,peri;
printf("enter the radius of a circle:");
scanf("%f",&rad);
area=3.14*rad*rad;
peri=2*3.14*rad;
printf("area=%f\n perimeter=%f\n",area,peri);
}

write a program to find fibonacci series.

/* write a program for faboniic series*/
#include<stdio.h>
main()
{
int num,r,a=0,b=1,c;
printf("enter the min:");
scanf("%d",&num);
for(r=2;r<=num;r++)
{
c=a+b;
a=b;
b=c;
printf("%d ,",c);
}
}


write a program to find armstrong number in a given range.

/* c code for find a armstrong number in a given range*/
#include<stdio.h>
main()
{
int dig,temp,num,sum;
int min,max;
printf("enter the min no.:");
scanf("%d",&min);
printf("enter the max no.:");
scanf("%d",&max);
printf("the armstrong number in a given range are ");
for(num=min;num<=max;num++)
{
temp=num;
sum=0;
while(temp!=0)
{
dig=temp%10;
temp=temp/10;
sum=sum+(dig*dig*dig);

}

if(num==sum)
{
printf("%d\n",num);
}
}
}

write a program to check entered number is armstrong or not.

/* c code for armstrong number*/
#include<stdio.h>
main()
{
int dig,deep,num,sum=0;
printf("enter the number");
scanf("%d",&num);
deep=num;
while(num!=0)
{
dig=num%10;
num=num/10;
sum=sum+(dig*dig*dig);
}
if(deep==sum)
{
printf("armstrong number");
}
else
{
printf("not a armstrong number");
}
}


write a program to check entered character is vowel or not.a

#include<stdio.h>
main()
{
char a[10];
char b[10]={'a','e','i','o','u','A','E','I','O','U'};
char x,y;
int i,j;
int count=0;
for(i=0;i<10;i++)
{
printf("enter the character a[%d]=",i);
scanf(" %c",&a[i]);
}
for(i=0;i<10;i++)
{
for(j=0;j<10;j++)
{
if(a[i]==b[j])
{

count++;
}}
}
printf("number of vowel is %d",count);
}


Sunday, 9 February 2014

C interview asked question




              C INTERVIEW ASKED QUESTION -ANSWER



1.Why C Language?
C is one of the high level languages. It is a general purpose language, which means it can be used to write programs of any sort.

2.What are the advantages of c language?
• Easy to write
• Rich set of operators and functions that are built–in
• Support for bit–wise operation
• Flexible use of pointers
• Direct control over the hardware
• Ability to access BIOS/DOS routines
• Interacting using Interrupts
• Ability to write TSR programs
• Ability to create .COM files
• Ability to create library files (.LIB)
• Ability to write interface programs

3.What are the disadvantages of c language?
• C is considered difficult to learn
• Because of its conciseness, the code can be difficult to follow
• It is not suited to applications that require a lot of report formatting and data file
manipulation

4.What are the salient features of c languages?
• The following are the salient features of C language are :
• C is called a middle level language
• C supports structured design approach
• C is extensible
• C is rich in data types and operators
• C is portable

5.What is C token?
The smallest individual units of a C program are known as tokens.

6.List the different types of C tokens?
• Constants
• Identifiers
• Keywords
• Operators
• Special symbols
• Strings

7.What is string?
A string is a sequence of characters ending with NULL. It can be treated as a one–dimensional
array of characters terminated by a NULL character.

8.What is NULL character?
The NULL character is an escape sequence with ASCII value 0 and is different from the ASCII character'0'.

9.What is Pointer?
Pointer is a variable which store the address of other variable.Since pointer is a variable it has also its address.

10.What is Array?
Array is collection of multiple member of same type,stored in consecutive locations.Array can have more than one dimension.One dimension array is known as vector and two dimensional array is known as matrix.

11.What is Function?
Function is collection of statement which are use in order to perform specific task or operation.

12.Why we use Variable?
Variable is a identifier which are use for store and modify the data.

13.What is a Constant?
A constant is a value that does not change during the program execution. A constant used in
C does not occupy memory.

14.What are global variables?
Global Variables are those, which are required to be acccessed by all the functions defined after their declaration. So, the variables declared before the main {) can be acccessed by all the functions, which follow their declaration.
or ,you can say it in simple word a variatble which are declare outside the function is known as global variable .Global variable is store in data section of memory

15.What is a keyword?
Keywords are those words of C which have predefined meaning assigned by the C language.They form a part of the database required by the C compiler.or you can also state as keyword are the word whose meaning has already explained to the C compiler.

16.Give the rules for variable declaration?
• The rules for variable declaration in C are given below :
• A variable name consists of alphabets, digits and the underscore (_) character
• The length of variable should be kept upto 8 characters though your system may allow
upto 40 characters
• They must begin with an alphabet
• Some systems also recognize an underscore as the first character
• White space and commas are not allowed
• Any reserved word (keyword) cannot be used as a variable name.

17.What is data types?
Data types refer to the classes of data that can be manipulated by C programs. The three fundamental data types supported by C are character, integer and real type.

18.What is Recursion?
Recursion may be defined as when a function calling itself is known as recursion funtion.

19.Give the type of storage classes in C.
a)Automatic storage class.
b)Register storage class.
c)Static storage class.
d)External storage class.

20.What is difference between while and do-while?
In case of while first check condition given if true then loop execute if false then loop will not execute.But in case of do-while atleast one time loop will execute then after it check the condition.

21.Rule for constructing Real constant.
a)A real constant must have at least one digit.
b)It must have a decimal point.
c)It could be either positive or negative.
d)Default sign is positive.
e)No comma or blanks are allowed within a real constant.

22.What is data types?
Data types refer to the classes of data that can be manipulated by C programs. The three fundamental data types supported by C are character, integer and real type.

23.What are the different types of errors?
• Compile–Time Errors
• Linker Errors
• Runtime Errors
• Logical Errors

24.What are the type of data type in C?

  • float
  • integer
  • double
  • character
  • void
25.What is break statement?
When a break is encountered inside a loop, the loop is terminated and the control passes to
the statement following the body of the loop.

26.What is goto statement?
This is an unconditional control statement that transfers the flow of contorl to another part of the program.

27.what is continue statement?
The  continue statement is used when we want to go to the next iteration of the loop after skipping some statement of the loop.

28.What is the difference between break and continue statement?
The difference between break and continue is that when break is encountered the loop terminates and the control is transferred to the next statement following the loop,but when a continue statement is encountered the loop is not terminated and the next iteration of the loop starts.

29.What is nesting of loops?
When a loop is written inside the body of another loop,it is known as nesting of loops.

30.What is loop?
Loops are used when we want to execute a part of the program or a block of statements several times.

31 .What is macro?
The second preprocessor function is macro definition. A macro is formal syntax that can be used to generate statements for use in a program. For the C language, the macro generates C statements.

32.What is the difference between c &c++?
c++ is an object oriented programing but c is a procedure oriented programing.c is super set of c++. c can't suport inheritance,function overloading, method overloading etc. but c++ can do this.In c-programe the main function could not return a value but in the c++ the main function should return a value

33.What is friend function?
The function declaration should be preceded by the keyword friend.The function definitions does not use either the keyword or the scope operator :: The functions that are declared with the keyword friend as friend function.Thus, a friend function is an ordinary function or a member of another class

34.What is the use of getchar() function?
It returns a character just entered from the standard input unit, that is, keyboard. The entered character can be either assigned to a character variable or echoed to the computer screen.

35.What is the difference between single charater constant and string constant?
• A single character constant consists of only one character and it is enclosed within a
pair of single quotes.
• A string constant consists of one or more characters and it is enclosed within a pair of
double quotes.

36.What is numeric constant?
Numeric constants consist of numeric digits ,they may not have decimal points(.).

37.What is real constant?
Real constants are numeric constants that contain decimal point.

38.What is Whitespace character?
Space character ,newline characterhorizontal tab,vertical tab,and form feed are known as Whitespace character.

39.What are the different categories of functions in C?
• In C, the functions can be divided into the following categories :
• Functions with no arguments and no return values
• Functions having arguments but no return values
• Functions having arguments and return values also

40.What is compiler?
The compiler converts high lev el code to machine's assembly language code.

41.What is memory layout of C program?

  • text or code segment
  • initialized data segment
  • uninitialized data segment
  • stack
  • heap(unreserved section of memory)
42.What is signed and unsigned?

A numeric value, may have a positive or a negative sign. In the memory, for a variable, one bit is used exclusively to maintain the sign of the data. If we don't have sign, the sign bit also may be used for data. If the value is negative, the sign bit is 1, and if it is positive, it will be 0.

43.What is Lvalue require?
When the leftside value is not assigned then the Lvalue error occured.

44.What is typecasting?
Temporary change the type of data is known as typecasting.

45.What is the use of typedef?
The typedef help in easier modification when the programs are ported to another machine.A descriptive new name given to the existing data type may be easier to understand the code.

46.What is type of typecasting?

  • Implicit typecasting
  • Explicit typecasting
47.What is meant by type specifiers?

Type specifiers decide the amount of memory space occupied by a variable. In the ease of integral types; it also explicitly states the range of values that the object can hold..

48.What are the types of type specifiers?
• The available data type specifiers are :
• Short
• Long
• Signed
• Unsigned

49.What is heap section of memory?
Unreserved area of the memory is known as heap section.

50.What is masking?
Masking is a process in which a given bit pattern is partly extracted into another bit pattern by means of a logical bitwise operation

51.What is getch() function?
It returns a character just entered from the standard input unit. The entered character is not echoed on the screen. It reads a single character the moment it is typed without waiting for the Enter key to be hit.

52.What is putchar() function?
It prints the character constant or the character variable to the standard output device. The function putchar( ) has the following form : putchar (var name)

53.What is the use of bitwise operator?
The bitwise operator performs the operation on bits (i.e. bit by bit). Using the bitwise operators we can set / reset / check any bit in the value of the variable.

54.What is unary operator?
The operators that act upon a single operand to produce a new value are known as unary operators.

55.What is macro?
A macro is a fragment of code which has been given a name.Whenever the name is used,it is replace by the content of the macro

56.List the different type of C tokens.

  • identifier
  • keywords
  • variable
  • constants
  • operators
57.What is need of formate identifier?

To inform printf and scanf .printf for output and scanf for input.

58.What is local block?
A local block is any portion of C program that is enclosed by the left brace({) and the right brace(}).

59.What are the types of unary operators?
• C support unary operators are :
• minus operator -
• increment operator + +
• decrement operator –
• size operator
• (type) operator

60.What is fuction of Linker?
All program written in C use library function which is precompiled and their object code is stored in library file with .lib extension .Linker combine object code of library function with the object code of our program.

61.What is address operator?
It is given as' &' which returns the address of a variable when placed before it.This operator can be read as"the address of" so &age means address of variable age.

62.When and who developed the C language?
In 1970s at AT&T Bell laboratories by Dennis Ritchie.

63.What is assembly Language?
Modified form of machine level language called assembly language.In assembly language instructions are given in english like words such as MOV,SUB etc.so it is easier to write and understand .

64.What is role of translators?
We know that computer can only understand machine language,which is in binary code 0or 1.The code written in high level and low level language should be translated into machine language and translator are used for this purpose.

65.What are the advantages of the functions?
• It reduces the complexity in a program by reducing the code
• Function are easily understanding and reliability and execution is faster
• It also reduces the time to run a program.In other way, Its directly proportional to complexity
• It’s easy to find-out the errors due to the blocks made as function definition outside the  main function.

66.What is else if ladder?
The else if ladder helps select one out of many alternative blocks of statements for execution depending on the mutually exclusive conditions

67.What is predefined function?
function which is already written,compiled&linked together with our program at time of linking called predefined function.

68.What is the difference between arrays and pointers?
Array is collection of similar datatype. it is a static memory allocation means we can not increment and decrement the arry size once we allocated. and we can not increment the base address, reassign address.
Pointer is a dynamic memory allocation. we can allocate the size as we want, assigning into another variable and base address incrementation is allowed.






              C INTERVIEW ASKED QUESTION -ANSWER



1.Why C Language?
C is one of the high level languages. It is a general purpose language, which means it can be used to write programs of any sort.

2.What are the advantages of c language?
• Easy to write
• Rich set of operators and functions that are built–in
• Support for bit–wise operation
• Flexible use of pointers
• Direct control over the hardware
• Ability to access BIOS/DOS routines
• Interacting using Interrupts
• Ability to write TSR programs
• Ability to create .COM files
• Ability to create library files (.LIB)
• Ability to write interface programs

3.What are the disadvantages of c language?
• C is considered difficult to learn
• Because of its conciseness, the code can be difficult to follow
• It is not suited to applications that require a lot of report formatting and data file
manipulation

4.What are the salient features of c languages?
• The following are the salient features of C language are :
• C is called a middle level language
• C supports structured design approach
• C is extensible
• C is rich in data types and operators
• C is portable

5.What is C token?
The smallest individual units of a C program are known as tokens.

6.List the different types of C tokens?
• Constants
• Identifiers
• Keywords
• Operators
• Special symbols
• Strings

7.What is string?
A string is a sequence of characters ending with NULL. It can be treated as a one–dimensional
array of characters terminated by a NULL character.

8.What is NULL character?
The NULL character is an escape sequence with ASCII value 0 and is different from the ASCII character'0'.

9.What is Pointer?
Pointer is a variable which store the address of other variable.Since pointer is a variable it has also its address.

10.What is Array?
Array is collection of multiple member of same type,stored in consecutive locations.Array can have more than one dimension.One dimension array is known as vector and two dimensional array is known as matrix.

11.What is Function?
Function is collection of statement which are use in order to perform specific task or operation.

12.Why we use Variable?
Variable is a identifier which are use for store and modify the data.

13.What is a Constant?
A constant is a value that does not change during the program execution. A constant used in
C does not occupy memory.

14.What are global variables?
Global Variables are those, which are required to be acccessed by all the functions defined after their declaration. So, the variables declared before the main {) can be acccessed by all the functions, which follow their declaration.
or ,you can say it in simple word a variatble which are declare outside the function is known as global variable .Global variable is store in data section of memory

15.What is a keyword?
Keywords are those words of C which have predefined meaning assigned by the C language.They form a part of the database required by the C compiler.or you can also state as keyword are the word whose meaning has already explained to the C compiler.

16.Give the rules for variable declaration?
• The rules for variable declaration in C are given below :
• A variable name consists of alphabets, digits and the underscore (_) character
• The length of variable should be kept upto 8 characters though your system may allow
upto 40 characters
• They must begin with an alphabet
• Some systems also recognize an underscore as the first character
• White space and commas are not allowed
• Any reserved word (keyword) cannot be used as a variable name.

17.What is data types?
Data types refer to the classes of data that can be manipulated by C programs. The three fundamental data types supported by C are character, integer and real type.

18.What is Recursion?
Recursion may be defined as when a function calling itself is known as recursion funtion.

19.Give the type of storage classes in C.
a)Automatic storage class.
b)Register storage class.
c)Static storage class.
d)External storage class.

20.What is difference between while and do-while?
In case of while first check condition given if true then loop execute if false then loop will not execute.But in case of do-while atleast one time loop will execute then after it check the condition.

21.Rule for constructing Real constant.
a)A real constant must have at least one digit.
b)It must have a decimal point.
c)It could be either positive or negative.
d)Default sign is positive.
e)No comma or blanks are allowed within a real constant.

22.What is data types?
Data types refer to the classes of data that can be manipulated by C programs. The three fundamental data types supported by C are character, integer and real type.

23.What are the different types of errors?
• Compile–Time Errors
• Linker Errors
• Runtime Errors
• Logical Errors

24.What are the type of data type in C?

  • float
  • integer
  • double
  • character
  • void
25.What is break statement?
When a break is encountered inside a loop, the loop is terminated and the control passes to
the statement following the body of the loop.

26.What is goto statement?
This is an unconditional control statement that transfers the flow of contorl to another part of the program.

27.what is continue statement?
The  continue statement is used when we want to go to the next iteration of the loop after skipping some statement of the loop.

28.What is the difference between break and continue statement?
The difference between break and continue is that when break is encountered the loop terminates and the control is transferred to the next statement following the loop,but when a continue statement is encountered the loop is not terminated and the next iteration of the loop starts.

29.What is nesting of loops?
When a loop is written inside the body of another loop,it is known as nesting of loops.

30.What is loop?
Loops are used when we want to execute a part of the program or a block of statements several times.

31 .What is macro?
The second preprocessor function is macro definition. A macro is formal syntax that can be used to generate statements for use in a program. For the C language, the macro generates C statements.

32.What is the difference between c &c++?
c++ is an object oriented programing but c is a procedure oriented programing.c is super set of c++. c can't suport inheritance,function overloading, method overloading etc. but c++ can do this.In c-programe the main function could not return a value but in the c++ the main function should return a value

33.What is friend function?
The function declaration should be preceded by the keyword friend.The function definitions does not use either the keyword or the scope operator :: The functions that are declared with the keyword friend as friend function.Thus, a friend function is an ordinary function or a member of another class

34.What is the use of getchar() function?
It returns a character just entered from the standard input unit, that is, keyboard. The entered character can be either assigned to a character variable or echoed to the computer screen.

35.What is the difference between single charater constant and string constant?
• A single character constant consists of only one character and it is enclosed within a
pair of single quotes.
• A string constant consists of one or more characters and it is enclosed within a pair of
double quotes.

36.What is numeric constant?
Numeric constants consist of numeric digits ,they may not have decimal points(.).

37.What is real constant?
Real constants are numeric constants that contain decimal point.

38.What is Whitespace character?
Space character ,newline characterhorizontal tab,vertical tab,and form feed are known as Whitespace character.

39.What are the different categories of functions in C?
• In C, the functions can be divided into the following categories :
• Functions with no arguments and no return values
• Functions having arguments but no return values
• Functions having arguments and return values also

40.What is compiler?
The compiler converts high lev el code to machine's assembly language code.

41.What is memory layout of C program?

  • text or code segment
  • initialized data segment
  • uninitialized data segment
  • stack
  • heap(unreserved section of memory)
42.What is signed and unsigned?

A numeric value, may have a positive or a negative sign. In the memory, for a variable, one bit is used exclusively to maintain the sign of the data. If we don't have sign, the sign bit also may be used for data. If the value is negative, the sign bit is 1, and if it is positive, it will be 0.

43.What is Lvalue require?
When the leftside value is not assigned then the Lvalue error occured.

44.What is typecasting?
Temporary change the type of data is known as typecasting.

45.What is the use of typedef?
The typedef help in easier modification when the programs are ported to another machine.A descriptive new name given to the existing data type may be easier to understand the code.

46.What is type of typecasting?

  • Implicit typecasting
  • Explicit typecasting
47.What is meant by type specifiers?

Type specifiers decide the amount of memory space occupied by a variable. In the ease of integral types; it also explicitly states the range of values that the object can hold..

48.What are the types of type specifiers?
• The available data type specifiers are :
• Short
• Long
• Signed
• Unsigned

49.What is heap section of memory?
Unreserved area of the memory is known as heap section.

50.What is masking?
Masking is a process in which a given bit pattern is partly extracted into another bit pattern by means of a logical bitwise operation

51.What is getch() function?
It returns a character just entered from the standard input unit. The entered character is not echoed on the screen. It reads a single character the moment it is typed without waiting for the Enter key to be hit.

52.What is putchar() function?
It prints the character constant or the character variable to the standard output device. The function putchar( ) has the following form : putchar (var name)

53.What is the use of bitwise operator?
The bitwise operator performs the operation on bits (i.e. bit by bit). Using the bitwise operators we can set / reset / check any bit in the value of the variable.

54.What is unary operator?
The operators that act upon a single operand to produce a new value are known as unary operators.

55.What is macro?
A macro is a fragment of code which has been given a name.Whenever the name is used,it is replace by the content of the macro

56.List the different type of C tokens.

  • identifier
  • keywords
  • variable
  • constants
  • operators
57.What is need of formate identifier?

To inform printf and scanf .printf for output and scanf for input.

58.What is local block?
A local block is any portion of C program that is enclosed by the left brace({) and the right brace(}).

59.What are the types of unary operators?
• C support unary operators are :
• minus operator -
• increment operator + +
• decrement operator –
• size operator
• (type) operator

60.What is fuction of Linker?
All program written in C use library function which is precompiled and their object code is stored in library file with .lib extension .Linker combine object code of library function with the object code of our program.

61.What is address operator?
It is given as' &' which returns the address of a variable when placed before it.This operator can be read as"the address of" so &age means address of variable age.

62.When and who developed the C language?
In 1970s at AT&T Bell laboratories by Dennis Ritchie.

63.What is assembly Language?
Modified form of machine level language called assembly language.In assembly language instructions are given in english like words such as MOV,SUB etc.so it is easier to write and understand .

64.What is role of translators?
We know that computer can only understand machine language,which is in binary code 0or 1.The code written in high level and low level language should be translated into machine language and translator are used for this purpose.

65.What are the advantages of the functions?
• It reduces the complexity in a program by reducing the code
• Function are easily understanding and reliability and execution is faster
• It also reduces the time to run a program.In other way, Its directly proportional to complexity
• It’s easy to find-out the errors due to the blocks made as function definition outside the  main function.

66.What is else if ladder?
The else if ladder helps select one out of many alternative blocks of statements for execution depending on the mutually exclusive conditions

67.What is predefined function?
function which is already written,compiled&linked together with our program at time of linking called predefined function.

68.What is the difference between arrays and pointers?
Array is collection of similar datatype. it is a static memory allocation means we can not increment and decrement the arry size once we allocated. and we can not increment the base address, reassign address.
Pointer is a dynamic memory allocation. we can allocate the size as we want, assigning into another variable and base address incrementation is allowed.




Contact Form

Name

Email *

Message *