Sunday, 31 January 2016

I BCom Cs C Language Viva Questions

C Viva Questions
1.      What are Translators?
2.      Difference between Interpreter and Compiler.
3.      Features of “C” Language.
4.      Applications of “C” language?
5.      Structure of “C” program.
6.      What is an Escape Sequence, What are they?
7.      What is Character set?(about ASCII)
8.      Mention ‘C’ tokens.
9.      What are Keywords and Identifiers? Mention some of them.
10.  What are constants?                                                            11.  What are Integer Constants?
12.  What are Single character Constants?                              13.  What are string constants?
14.  What are variables? Types of variables?
15.  What are different data types that ‘C’ supports?
16.  What are fundamental datatypes?                                   17.  What is declaration of variables?
18.  What are various operators supported by ‘C’ , Explain with syntax and example.
(Arithmetic operators, Relational operators, Logical operators, Assignment operators, Increment and Decrement operators, Bitwise operators).
19.  Precedence of Arithmetic operators.
20.  Mathematical Functions.
21.  Reading a character(Explain ‘getchar’).
22.  Reading string of characters (Explain ‘gets()’).
23.  Formatted Input (Explain ‘scanf’).
24.  Writing a character (Explain ‘putchar()’).
25.  Writing string of characters (Explain ‘puts()’).
26.  Writing a formatted output (printf).
27.  Explain ‘if’ structure.
28.  Explain ‘if-else’ structure.
29.  Explain ‘else-if’ structure.
30.  Explain ‘Switch’ statement with syntax.
31.  Explain ‘GoTo’ statement.
32.  What is looping? Types of looping statements.
33.  Explain ‘While’ statement with syntax and example.
34.  Explain ‘do-While’ statement with syntax and example.
35.  Explain ‘for’ statement with syntax and example.
36.  What is an array?       
37.  What are various string functions?
38.  What is a function declaration or prototype? 
39.  What is a function?
40.  What are the parts of Function definition?
41.  Explain the function concept.
42.  Explain category of functions.                                
43.  What is a ‘call by value’ or ‘pass by value’?
44.How is an array element referred?
45.What does an array name contains?
46.Uses of arrays
47.What are one dimensional arrays?
48.what are two dimensional arrays?
49.What are multidimensional arrays?
50.What is the difference between getch() and gets()
51.How any array is passed as an argument to a functions?
52.What is scope of a variable?
53.What is visibility of a variable?
54.What is lifetime of a variable?
55.What are the various storage classes?
56.What are qualifiers?
57.What are external and register variables?
58.What are automatic and static variables?
59.What are local and global variables?
60.What is a structure?
61.Compare arrays and structures?
62.How elements of structure variables are referred?
      What are bit fields?
63.What is a Union?
64.Compare Structure and Union?
65.What are pointers?
66.How pointers variables are declared?
67.What do pointer variables contain?
68.How do we access value pointed to by a pointer variable?
69.What can be assigned to a pointer variable?
70.what operations can be performed on pointer variables?
71.Compare pointers and arrays?
72.What is a NULL value?
73.What operations are not allowed on pointer variables?
74. What is preprocessor?
75. What is # include statement?
76. What is # define or symbolic constant statement?
      What is a macro substitution?
77. What is conditional compilation in preprocessor?

78. What are .h files and what they contain? (Ans : stdio.h, conio.h, math.h, string.h,type.h etc)

Tuesday, 19 January 2016

Library Mathematical and Date functions in C Language

Library Mathematical Functions
Following are the functions defined in the header math.h −
S.N.
Function & Description
1
Returns the arc cosine of x in radians.
2
Returns the arc sine of x in radians.
3
Returns the arc tangent of x in radians.
4
Returns the arc tangent in radians of y/x based on the signs of both values to determine the correct quadrant.
5
Returns the cosine of a radian angle x.
6
Returns the hyperbolic cosine of x.
7
Returns the sine of a radian angle x.
8
Returns the hyperbolic sine of x.
9
Returns the hyperbolic tangent of x.
10
Returns the value of e raised to the xth power.
11
The returned value is the mantissa and the integer pointed to by exponent is the exponent. The resultant value is x = mantissa * 2 ^ exponent.
12
Returns x multiplied by 2 raised to the power of exponent.
13
Returns the natural logarithm (base-e logarithm) of x.
14
Returns the common logarithm (base-10 logarithm) ofx.
15
The returned value is the fraction component (part after the decimal), and sets integer to the integer component.
16
Returns x raised to the power of y.
17
Returns the square root of x.
18
Returns the smallest integer value greater than or equal to x.
19
Returns the absolute value of x.
20
Returns the largest integer value less than or equal to x.
21
Returns the remainder of x divided by y.

Date and Time functions in C
  Time functions in C are used to interact with system time routine and formatted time outputs are displayed. Example programs for the time functions are given below.
S.no
Function
Description
1
setdate()
This function used to modify the system date
2
getdate()
This function is used to get the CPU time
3
clock()
This function is used to get current system time
4
time()
This function is used to get current system time as structure
5
difftime()
This function is used to get the difference between two given times
6
strftime()
This function is used to modify the actual time format
7
mktime()
This function interprets tm structure as calendar time
8
localtime()
This function shares the tm structure that contains date and time informations
9
gmtime()
This function shares the tm structure that contains date and time informations
10
ctime()
This function is used to return string that contains date and time informations
11
asctime()
Tm structure contents are interpreted by this function as calendar time. This time is converted into string.

Example program for setdate() function in C:

This function is used to modify the system date. Please note that other C compilers may not support this setdate() function except turbo C.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<stdio.h>
#include<dos.h>
#include<conio.h>
int main()
{
   struct date dt;

   printf("Enter new date in the format(day month year)");
   scanf("%d%d%d",&dt.da_day,&dt.da_mon,&dt.da_year);

   setdate(&dt);

   printf("Now, current system date is %d-%d-%d\n",dt.da_day,dt.da_mon,dt.da_year);
   return 0;
  }

  

Output:

Enter new date in the format (day month year)
01 12 2012
Now, current system date is 01-12-2012

Example program for getdate() function in C:

This function is used to get the CPU time. Please note that other C compilers may not support this getdate() function except turbo C.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include<stdio.h>
#include<dos.h>
int main()
{
   struct date dt;

   getdate(&dt);

   printf("Operating system's current date is %d-%d-%d\n"
   ,dt.da_day,dt.da_mon,dt.da_year);

   return 0;
}

Output:

Operating system’s current date is 12-01-2012