asadullah.ansari's Avatar, Join Date: Jan 2008
TechCake
Question 6:
Choice 4 fread()
Note : Protype of this function is as :
size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);

Question 7:
Choice 4 printf("\"My salary was increased by 15%%!\"\n");

Question 8:
Choice 4 A declaration occurs once, but a definition may occur many times.

Question 9:
Choice 5 11

Question 10:

21 , 11, 13, 13
asadullah.ansari's Avatar, Join Date: Jan 2008
TechCake
Question 10 :

Depends on compiler also. Expression evaluatio starting from left side or right side.Depernds on parse tree provided by compiler.

If expression is evaluating from left side then

output will be

21 11 13 13
oogabooga's Avatar
Ambitious contributor
I should have made it more evident that I _meant_ for the code to be broken. It was just for humhain... to run and see the problem, that it gets different results. I've edited the post.
humhaingaurav's Avatar, Join Date: Jan 2008
Newbie Member
#include <stdio.h>

void f(int a, int b) { printf("%d %d\n", a, b); }

int main() {
int a;
a = 1; printf("Pre: f(++a, a) --> "); f(++a, a);
a = 1; printf(" f(a, ++a) --> "); f(a, ++a);
a = 1; printf("Post: f(a++, a) --> "); f(a++, a);
a = 1; printf(" f(a, a++) --> "); f(a, a++);
}
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
:!./a.out
Pre: f(++a, a) --> 2 2
f(a, ++a) --> 2 2
Post: f(a++, a) --> 1 2
f(a, a++) --> 2 1

Press ENTER or type command to continue


-------------------------------------------------------------------------------------------------
See dude my compiler is still giving different output then yours. Well, I am using UNIX machine I don't know if that matters. But oh well here is the output from my system .
omlavs's Avatar, Join Date: Jan 2012
Newbie Member
hi need immediately ans for the following questions in c plz help me

void freeList( struct node *n )
{
while( n )
{
????
}
}
Which one of the following can replace the???? for the function above to release the memory allocated to a linked list?

a)n = n->next; b) node m = n; c)struct node m = n;
free( n ); n = n->next; free( n );
free( m ); n = m->next;

d)free( n ); e)struct node m = n;
n = n->next; free( m );
n = n->next;

What are two predefined FILE pointers in C?

a)stdout and stderr c)stdout and stdio
b)console and error d)stdio and stderr e)errout and conout

u32 X (f32 f)
{
union {
f32 f;
u32 n;
} u;
u.f = f;
return u.n; }
Given the function X(), defined above, assume that u32 is a type-definition indicative of a 32-bit unsigned integer and that f32 is a type-definition indicative of a 32-bit floating-point number. Which one of the following describes the purpose of the function defined above?

a)X() effectively rounds f to the nearest integer value, which it returns.
b)X() effectively performs a standard typecast and converts f to a roughly equivalent integer.
c)X() preserves the bit-pattern of f, which it returns as an unsigned integer of equal size.
d)Since u.n is never initialized, X() returns an undefined value. This function is therefore a primitive pseudorandom number generator.
e)Since u.n is automatically initialized to zero (0) by the compiler, X() is an obtuse way of always obtaining a zero (0) value.


Which one of the following is a true statement about pointers?

a)They are always 32-bit values.
b)For efficiency, pointer values are always stored in machine registers.
c)With the exception of generic pointers, similarly typed pointers may be subtracted from each other.
d)A pointer to one type may not be cast to a pointer to any other type.
e)With the exception of generic pointers, similarly typed pointers may be added to each other



All of the following choices represent syntactically correct function definitions. Which one of the following represents a semantically legal function definition in Standard C?

a)Code: b)Code: c)Code:
int count_digits (const char * buf) { int count_digits (const char * buf) { int count_digits (const char * buf) {
assert(buf != NULL); int cnt = 0; int cnt = 0, i;
int cnt = 0, i; assert(buf != NULL); assert(buf != NULL);
for (i = 0; buf[i] != '\0'; i++) for (int i = 0; buf[i] != '\0'; i++) for (i = 0; buf[i] != '\0'; i++)
if (isdigit(buf[i])) if (isdigit(buf[i])) if (isdigit(buf[i]))
cnt++; cnt++; cnt++;
return cnt; return cnt; return cnt;
} } }

d)Code: e)Code:
int count_digits (const char * buf) { int count_digits (const char * buf) {
assert(buf != NULL); assert(buf != NULL);
for (i = 0; buf[i] != '\0'; i++) int cnt = 0;
if (isdigit(buf[i])) for (int i = 0; buf[i] != '\0'; i++)
cnt++; if (isdigit(buf[i]))
return cnt; cnt++;
} return cnt;
}