Professional Documents
Culture Documents
Q1-Ans:
Example:
int ProcessId=0;
double check[MAXVAL];
Q2-Ans:
The auto and register specifiers give the declared objects automatic storage
class, and maybe used only with in functions.
These declarations also serve as definitions and cause storage to be
reserved.
int (*DayofMonth)[13];
and int *Dayofmonth[13];
Q4-Ans:
Q5-Ans:
Q6-Ans:
Q7-Ans:
Example:
int amt[2][3][2]= {
{
{12,14},
{15,16},
{17,18}
},
{
{19,20},
{21,22},
{23,24}
}
};
Q8-Ans:
Q9-Ans:
Q10-Ans:
ungetc pushes c (converted unsigned char) back onto stream. This character
will be returned on the next read.
Q11-Ans:
lnclude file "stdarg.h" contains macros va_start, va_arg and va_list used to
solve the variable number of arguments passed to a function.
Q1-Ans:
Q2-Ans:
If static is used, the function can be called only by any other function with in
the File. No other function from another file can call this.
Q3-Ans:
Q4. Write an alogorithm to find out the number of 0's and 1's in a given
number?
Q4-Ans:
(alternate) : Doing "AND" with value 1, fetches the result as odd or even.
step 4: Display the count of 1's and 0's.
Q5. C and Unix. (One process is opening and writing a file which is
more than 2 GB ). If the file size is limited to 2GB for some machine ,
how should we solve this situation??
Q5-Ans:
-Algorithm:-
1. Open new file.
2. call "system" function to do the following.
cat 'old_file' >> new_file.
trunc old_file,
3. close the new_file.
4. Find that fseek(FILE *stream) is pointed to 0th position.
5. Start writing from 0th position.
Q6-Ans:
realloc changes the size of the object pointed to by p to size. the contents are
unchanged. If the new size is larger, the new space is uninitialized.
new size cannot be smaller.
Q7-Ans:
#
has no effect on the program code.
Q8. What does this statement do void *calloc(size_t nobj, size_t size)?
Q8-Ans:
calloc returns a pointer to space for an array of "nobj" objects , each of size
size. or NULL if request failed. The space is initialized to zero bytes.
Q9-Ans:
malloc returns a pointer to space for an object of size size. the space is
uninitialized.
Q10-Ans:
Q11-Ans:
Q12-Ans:
ftell returns the current file position for stream., -1L on Error.
Q13-Ans:
Q14-Ans:
main()
{
int *p;
int (*func_ptr) (); /* prototype declaration , tells the compiler that
there is a pointer to function coming ahead.*/
int *func_ptr()
{
printf( " This is to test Pointers to functions\n");
}
Normal Questions:
Q1. what does function labs (long n) do?
Q1-Ans:
Q2-Ans:
This function echos the input character when pressed from an input device.
No need to give ENTER.
j=&a;
z=&j;
Q3-Ans:
Q4. what is the difference between "r" and "r+" in file operations?
Q4-Ans:
"w" -- create text file for writing, discard previous contents if any.
"w+" -- create text file for update; discard previous contents if any.
same with append "a" -- append at the end of file for writing.
"a+" -- append at the end of file for updating.
differences of r+ , w+... :
r+ cannot create a file for writing.
w+ will create a file if the file-name does not exist.
%+d -- Plus prefix specifies that the number will always be printed
with a sign.
%0d -- zero prefix specifies padding to the field width with leading
zeros.