Sign Up

Sign In

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Sorry, you do not have permission to ask a question, You must login to ask a question.

SIKSHAPATH Latest Articles

NPTEL Problem Solving Through Programming In C Week 7 Assignment Answers 2022

NPTEL Problem Solving Through Programming In C Week 7 Assignment Answers

Q1. Which of the following statements are correct?

i. A string is a collection of characters terminated by 10′.

ii. The format specifier %s is used to print a string.

iii. The length of the string can be obtained by strlen().

iv. The pointer cannot work on string

a. i, ii
b. i, ii, iii
c. ii, iv
d. i, iii

Answer: b. i, ii, iii

For More Updates Follow Us on Telegram


Q2. The right method of initializing a 2D array is

a. int abc[2][2] = {1, 2, 3, 4}
b. int abc[][] = {1,2,3,4}
c. int abc[2][] = {1,2,3,4}
d. all of the above

Answer: a. int abc[2][2] = {1, 2, 3,4}


Q3. The array passed as an argument to a function is interpreted as

a. Address of all the elements in an array

b. Value of the first element of the array

c. Address of the first element of the array

d. Number of elements of the array

Answer: c. Address of the first element of the array


Q4. What will be the output?

#include<stdio.h> 
int main()
{ 
int disp[3][4]={{5, 
6,8,2},{4,5,3,7}, {1,10,13,15}}; 
printf("%d\n",disp[2][3]); return 0;
}

Answer: 15


Q5. What will be the output?

#include <stdio.h>
int main()
{
char str1[]="Live and let live";char str2[]={'L', 'ï', 'v', 'e', ' ', 'a', 'n', 'd', ' ', 'l', 'e', 't',' ','l', 'i', 'v', 'e'};
int n1=
sizeof(str1)/sizeof(str1[0]);
int n2=
sizeof(str2)/sizeof(str2[0]);
printf("n1=%d, n2=%d",nl,n2); return 0; }

a. n1=18, n2=17

b. n1=18, n2=18

c. n1=17, n1=17

d) n1=17, n2=18

Answer: a. n1=18, n2=17


Q6. What will be the value of ‘i’ after the execution of the C code fragment given below?

static char str1[]="dills";
static char str2[20];
static char str3[]="daffo";
int i;
i=strcmp(strcat(str3, strcpy(str2,str1)),"daffodills");

Answer: 0


Q7. Consider the following C program segment:

#include<stdio.h>
#include<string.h>
int main()
{
char p[20];
char s[]="string";
int length=strlen(s);
int i;
for(i=0;i<length;i++)
p[i]=s[length-i];
printf("%s",p);
return 0;
}

The output would be:

a. gnirts
b. gnirt
c. string

d. no output is printed

Answer: d. no output is printed


Q8. What will be the output?

#include<stdio.h>
void swap(char*str1,char*str2)
{
char*temp=strl;
str1=str2;
str2 =temp;
}
int main()
{
char*str1="Swayam";
char*str2="2022";
swap(str1,str2);
printf("str1 is %s, str2 is %s",str1,str2);
return 0;
}

a. str1 is Swayam, str2 is 2022

b. str1 is 2022, str2 is Swayam

c. str1 is Swayam, str2 is Swayam

d. str1 is 2022, str2 is 2022

Answer: a. str1 is Swayam, str2 is 2022


Q9. What would you put in place of “****” to print “Two”?

#include<stdio.h>
int main()
{
char arr[]="TwentyTwo";
printf("%s",****);
  return 0;
}

a. arr
b. arr+5

c. arr+6
d. Not possible

Answer: c. arr+6


Q10. If the starting address of an float array Arr[10][10] is 2000, what would be the memory address of the element Arr[5][6]? (float takes 4 bytes of memory)

a. 2268
b. 2120
c. 2224
d. 2144

Answer: c. 2224


Disclaimer: These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself.


Also Available:

Joy of Computing Using Python NPTEL Assignment Answers Week 7

Problem Solving through Programming in C NPTEL Week 8 Assignment Answers

Related Posts