Problem Solving Through Programming In C Nptel Week 12 Assignment Answers
Are you looking for the Problem Solving Through Programming In C Assignment 12 Answers ? You’ve come to the right place! This resource offers comprehensive solutions to the Week 12 assignment questions, focusing on fundamental concepts in C programming.
Table of Contents
Problem Solving Through Programming In C Assignment 12(Jan-Apr 2025)
Course Link: Click Here
1) Which of the following are themselves a collection of different data types?
a. String
b. Array
c. Character
d. Structure
2) Which of the following comments about the usage structures is true?
a. Storage class can be assigned to individual member
b. Individual members can be initialized within a structure type declaration
c. The scope of the member name is confined to the particular structure, within which it is defined
d. None
3) What will be output of the program?
#include <stdio.h>
#include <stdlib.h>
int main() {
int i;
int *ptr = (int *) malloc(5 * sizeof(int));
for (i=0; i<5; i++)
*(ptr+i) = i;
printf("%d ", *ptr++);
printf("%d ", (*ptr)++);
printf("%d ", *ptr);
printf("%d ", *++ptr);
printf("%d ", ++*ptr);
return 0;
}
a. Error
b. 0 1 2 3 4
c. 1 2 3 4 5
d. 0 1 2 2 3
4) What will be output of the program?
#include <stdio.h>
int fun(int arr[]) {
arr = arr + 1;
printf("%d ", arr[0]);
}
int main() {
int arr[3] = {5, 10, 15};
fun(arr);
printf("%d ", arr[0]);
printf("%d ", arr[1]);
return 0;
}
a. 5 10 10
b. 10 5 15
c. 10 5 10
d. 10 1 55
5) What is the output of the following C code? Assume that the address of x is 2000 (in decimal) and an integer requires four bytes of memory
#include <stdio.h>
int main() {
unsigned int x[4][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
printf("%u, %u, %u", x+3, *(x+3), *(x+2)+3);
}
a. 2036 2036 2036
b. 2012 4 2204
c. 2036 10 10
d. 2012 4 6
Problem Solving Through Programming In C Assignment 12
6) The program will allocate …….bytes to ptr. Assume sizeof(int)=4.
#include<stdio.h>
#include<stdlib.h>
int main() {
int *ptr;
ptr = (int*)malloc(sizeof(int)*4);
ptr = realloc(ptr,sizeof(int)*2);
return 0;
}
a. 2
b. 4
c. 8
d. None
7) What is the output of the following C program?
#include <stdio.h>
int main() {
int *p, a = 10;
p = &10;
printf("%d", *p);
return 0;
}
a. 10
b. a
c. address of a
d. compilation error
8) What is the output?
#include<stdio.h>
int main() {
struct xyz { int a; };
struct xyz obj1 = {11};
struct xyz obj2 = obj1;
printf("%d", obj2.a);
obj2.a = 101;
printf("%d", obj1.a);
printf("%d", obj2.a);
return 0;
}
a. 1111011
b. 1111101
c. 1110111
d. 1110011
9) Calling a function f with an array variable a[3] where a is an array, is equivalent to
a. f(a[3])
b. f((a+3))
c. f(3[a])
d. all of the mentioned
10) What is the output of the following C program?
#include <stdio.h>
struct p {
int x;
char y;
};
int main() {
struct p p1[] = {1, 2, 69.42, 64};
struct p *ptr1 = p1;
int x = (sizeof(p1) / 4);
if (x == sizeof(int) + 2 * sizeof(char))
printf("True");
else
printf("False");
return 0;
}
a. True
b. False
c. No output
d. Compilation error
Problem Solving Through Programming In C Assignment 12
More NPTEL Solution: https://progiez.com/nptel
Problem Solving Through Programming In C Assignment 12