Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C examn Question 11 pts What does the following code print: unsigned int x = -1;

ID: 3918165 • Letter: C

Question

C examn

Question 11 pts

What does the following code print:

unsigned int x = -1;
int y = !-0;
if (x == y)
printf("same");
else
printf("not same");

Flag this Question

Question 21 pts

Which of the following is not a valid declaration in C?
1. short int x;
2. signed short x;
3. short x;
4. unsigned short x;

Flag this Question

Question 31 pts

What does the following lines of code print:
int const a = 5;
a++;
printf(“%d”,a);

Flag this Question

Question 41 pts

Choose the correct option for the following program:
int *p, **q;

printf("%u ", sizeof(p));
printf("%u ", sizeof(q));

Flag this Question

Question 51 pts

Which of the following can be included in a variavble name?

Flag this Question

Question 61 pts

Which of the options are correct for the following code?
char a = 'a'; // line 1
char b = b; // line 2
char c = '1'; // line 3
int d = 1; // line 4

Flag this Question

Question 71 pts

What is the output of a program with the following lines of code?

char s[] = "Fine";
*s = 'N';
printf("%s", s);

Flag this Question

Question 81 pts

Which of the following operator can be used to access value at address stored in a pointer variable?

Flag this Question

Question 91 pts

Which option is correct for calling the following function from another function?

int function(int *a, int *b) {
int temp = (*a)+(*b);
*a = 3*temp - (2*(*b))%9;
*b = (*a)%temp;
printf("a = %d, b = %d ", *a, *b);
return (*a) - (*b);
}

Flag this Question

Question 101 pts

Which option is correct for calling the following function from another function?


void function(int array[], int length) {
int i;
int temp[length];
for (i=0; i<length; i++)
temp[i] = array[array[i]];
for (i=0; i<length; i++)
   array[i] = temp[i];
for (i=0; i<length; i++)
   printf("%d ", array[i]);
printf(" ");
}

int values[] = {3, 0, 4, 5, 1, 2};

function(values[], 6);

Flag this Question

Question 111 pts

extern int fun(); - The declaration indicates the presence of a global function defined outside the current module or in another file.

Flag this Question

Question 121 pts

In this code segment, which line causes an array index "out of bounds" first?

int nums[10], i; // line 1
for (i=1; i<10; i++) // line 2
   nums[i-1] = 2*i+5; // line 3
i = 0; // line 4
while (i < 10) {   // line 5
   int t = nums[i+1]; // line 6
nums[i] = nums[t];   // line 7
i++; // line 8
}

Flag this Question

Question 131 pts

Which of the following correctly opens the file "num.txt" to read from?

Flag this Question

Question 141 pts

What is the output of the following lines of code when fun2 is called from a main() function in a c program?


line 1: void fun1(int *a)
line 2: {
line 3: a = (int*)malloc(sizeof(int));
line 4: }

line 5: int fun2()
line 6: {
line 7: int *p;
line 8: fun1(p);
line 9: *p = 6;
line 10: printf("%d ",*p);
line 11: return(0);
line 12: }

Flag this Question

Question 151 pts

What does the following function do?

1. void f(int array[], int length) {
2. int i;
3. int temp = array[0];
4. for (i=0; i<length-1; i++)
5. array[i] = array[i+1];
6. array[length-1] = temp;
7. }

Flag this Question

Question 161 pts

Given the function x below, what is the value of the expression: x(x(1,2), x(4,3))

1. int x(int a, int b) {
2. if (a < b)
3. return a + b;
4. return a*b;
5. }

Flag this Question

Question 171 pts

Which of the following reads in one integer from the file
pointed to by ifp into the variable num?

Flag this Question

Question 181 pts

What restriction on the contents of array guarantees that accessing any elements of array
will not cause an array out of bounds error, assume that length is the length of the array?

Flag this Question

Question 191 pts

Which of the below three functions are likely to cause problems with pointers?


1.   [PI] int * g (void)
2. {
3. int x= 10;
4. return (&x);
5. }

1.   [P2] int * g (void)
2. {
3. int * px;
4. *px= 10;
5. return px;
6. }

1.   [P3] int *g (void)
2. {
3. int *px;
4. px = (int *) malloc (sizeof(int));
5. *px= 10;
6. return px;
7. }

Flag this Question

Question 201 pts

Which of the following is/are true?

Flag this Question

Question 211 pts

What is the return type of malloc() or calloc() ?

Flag this Question

Question 221 pts

What is the problem with following code?

int *p = (int *)malloc(sizeof(int));
p = NULL;
free(p);

Flag this Question

Question 231 pts

Assume that base address of arr is 2000 and size of integer is 32 bit. What is the output of the followinf program?

int arr[5];
arr++;
printf("%u", arr);

Flag this Question

Question 241 pts

What will the following code print?

1. int i;
2. int arr[5] = {1};
3. for (i = 0; i < 5; i++)
4. printf("%d ", arr[i]);

Flag this Question

Question 251 pts

Which of the following statements creates a multidimensional array with 3 rows, where the first row contains 1 element, the second row contains 4 elements and the final row contains 2 elements?

Flag this Question

Question 261 pts

Flag this Question

Question 271 pts

C library function __________ is used for comparing arrays of characters to determine whether they are equal and have the same contents.

Flag this Question

Question 281 pts

When fopen() is not able to open a file, it returns

Flag this Question

Question 291 pts

In fopen(), the open mode "wx" is sometimes preferred "w" because.

1) Use of wx is more efficient.
2) If w is used, old contents of file are erased and a new empty file is created. When wx is used, fopen() returns NULL if file already exists.

Flag this Question

Question 301 pts

Which of the following is not a storage class specifier in C?

Flag this Question

Question 311 pts

Information is passed to a function in ________.

Flag this Question

Question 321 pts

The parameters in the function declaration and the arguments in the function call must agree in:

Flag this Question

Question 331 pts

What is the output of the following problem ?

1. int main()
2. {
3. func(1);
4. return 0;
5. }

6. func(int i){
7. static char *str[] = {"One","Two", "Three", "Four"};
8. printf("%s ",str[i++]);
9. return;
10. }

Flag this Question

Question 341 pts

What is the output of the following C Program?


int main()
{
static char names[5][20]={"Orlando","Atlanta","Austin","New York","Los Angeles"};
int i; char *t; t=names[3];
names[3]=names[4];
names[4]=t;
for (i=0;i<=4;i++)
printf("%s",names[i]);
return 0;
}

Flag this Question

Question 351 pts

The expression ((fpt = fopen ("Samples", "w")) == NULL) would be true if

Flag this Question

Question 361 pts

x = fopen (b, c) what is b?

Flag this Question

Question 371 pts

float x, y, z;
scanf ("%f %f", &x, &y);

If input stream contains "4.2 3 2.3 ..."
What will x and y contain after scanf?

Flag this Question

Question 381 pts

What is the output of the following 'C' function when called?

1. void function() {
2. int x = 10,y = 10, z = 5, i;
3. i = x;
4. printf("%d",i==x);
5. }

Flag this Question

Question 391 pts

In a C program, if the initialization statement is:

int x,y=2,z,a;

What would be the value of x when the following line of code is executed?

x = (y*=2) + (z=a=y);

Flag this Question

Question 401 pts

Given the struct xx with the following members:

int x=3;
char name[]="hello";

What would be the output of the following program?

1. void main()
2. {
3. struct xx *s=malloc(sizeof(struct xx));
4. printf("%d",s->x);
5. printf("%s",s->name);
6. }

same.

Explanation / Answer

Since you have uploaded a large set of questions so as per the guidelines i can answer first four part. But i have answered 10 parts.

here are the answers..

========================================================

Ans:1

not same

Ans:2

2. signed short x;

option 2 is correct.

Ans:3

option A: compiler: increment of read-only variable ‘a’ .

Ans:4

Both the printf() will print the same value.

8

8

Ans:5

_ (underscore)

Ans:6

Code at line 2 fails to compile.

Ans:7

Nine

Ans:8

&&

Ans:9

int a = 2, b = 1;
b = function(&a, &b);

Ans:10

int values[] = {3, 0, 4, 5, 1, 2};
function(values, 6);

========================================================

Kindly Check and Verify Thanks..!!!