Problem Solving Through Programming in C Nptel Assignment Answers 2022 Week 12 | NPTEL Week 12 Quiz Assignment | NPTEL Assignment Solutions

NPTEL Problem Solving Through Programming in C Week 12 Quiz Assignment | NPTEL Swayam Assignment Answers


problem solving through programming in c nptel assignment answer week 12 2022



Join Us On Telegram

     ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡

telegram


Join Us On Youtube

     ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡ðŸ‘‡
youtube



MCQs (multiple choice questions) Nptel Week 12 Quiz Answers:


Q.1: Which of the following are themselves a collection of different data types? Options are:

(a) String
(b) Array
(c) Character
(d) Structure


Answer is: (d) Structure



Q.2: Which of the following comments about the usage structures is true? Options are:

(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 of the above


Answer is: (c) The scope of the member name is confined to the particular structure, within which it is defined



Q.3: What is actually passed if you pass a structure variable to a function? Options are:

(a) Copy of structure variable
(b) Reference of structure variable
(c) Starting address of structure variable
(d) Ending address of structure variable


Answer is: (a) Copy of structure variable


Q.4: 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;
}


Answer is: 8



Q.5: Find the output of the following program.

#include<stdio.h>
int main()
{
char A[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'};
char *p = A;
++p;
while(*p!= 'e')
 printf("%c", *p++); 
return 0;
}

Options are:

(a) abcd
(b) bcd
(c) cd
(d) abcdfgh


Answer is: (b) bcd



Q.6: What is the output? 

#include<stdio.h>
int main()
struct xyz{ int a;};
struct xyz obj1={1}; 
struct xyz obj2 = obj1; 
printf("%d", obj2.a); 
obj2.a = 100; 
printf("%d", obj1.a); 
printf("%d", obj2.a); 
return 0; 
}


Options are:

(a) 11100
(b) 11
(c) 11001
(d) 11000

Answer is: (a) 11100



Q.7: 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.

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);
}

Options are:

(a) 2036, 2036, 2036
(b) 2012, 4, 2204
(c) 2036, 10, 10
(d) 2012, 4, 6

Answer is: (a) 2036, 2036, 2036



Q.8: What does fp point to in the program?

#include<stdio.h> 
int main()
{
FILE  *fp;
fp=fopen("hello", "r");
return 0;
}


Options are:

(a) The first character in the file
(b) A structure which contains a char pointer which points to the first character of a file.
(c) The name of the file.
(d) The last character in the file


Answer is: (b) A structure which contains a char pointer which points to the first character of a file.


Q.9: Choose a correct statement about C structure? 

int main()
{
struct hello {};
return 0;
}


Options are:

(a) It is wrong to define an empty structure
(b) Member variables can be added to a structure even after its first definition
(c) There is no use of defining an empty structure
(d) None of the above


Answer is: (c) There is no use of defining an empty structure



Q.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, 90, 62, 33, 3, 34}; 
struct p *ptrl=p1; 
int x = (sizeof(p1)/3); 
if (x == sizeof(int) + sizeof(char)) {
printf("True");}
else{
printf("False");
}
return 0;
}


Options are:

(a) True
(b) False
(c) No output
(d) Compilation error


Answer is: (b) False



If you are facing any queries regarding this assignment solutions, then please drop comment in comment section.

Post a Comment

0 Comments