NPTEL Problem Solving Through Programming in C | NPTEL Week 7 Quiz Assignment | NPTEL Assignment Solutions

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


problem solving through programming in C nptel


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


Q.1: Which of the following statement/s are false?
    I. Array elements are stored in memory in contiguous locations.
    II. An integer array always terminates with '\0' (NULL).

Options are:

 a) I
 b) II
 c) Both I and II
 d) None

Answer is: (b) II



Q.2: If two strings are identical, then strcmp() function returns. Options are:

 a) 1
 b) 0
 c) -1
 d) None of these

Answer is: (b) 0 



Q.3: Which of the following function is more appropriate for reading in a multi word string? 

(a) scanf()
(b) gets()
(c) printf()
(d) puts()

Options are: 

 a) Option (a)
 b) Option (b)
 c) Option (c)
 d) Option (d)

Answer is: (b) Option (b) 


Q.4: What will be printed after execution of the following code?

#include<stdio.h>
int main()
{
int a[20] = {10, 20, 30, 40, 50, 60}; 
printf("%d", 3[a]);
return 0;
}

Answer is: 40



Q.5: What will be the output of the program ?

#include<stdio.h>
int main()
{
char str[] = "Array\0String";
printf("%s", str);
return 0;
}

Options are:

 a) Array
 b) Array String
 c) Array\0String
 d) Compilation error

Answer is: (a) Array



Q.6: What will be the output ?

#include<stdio.h>
int main()
{
char str1[20] = "Programming", str2[20] = "Language";
printf("%s",strcpy(str2,strcat(str1,str2)));
return 0;
}


Options are:

 a) Programming
 b) Language
 c) ProgrammingLanguage
 d) LanguageProgramming


Answer is: (c) ProgrammingLanguage 



Q.7: What will be the output?

#include <stdio.h>
int main()
{
char str1[] = "I-LOVE-C";
char str2[] = {'I', '-', 'L', 'O', 'V', 'E', '-', 'C'};
int n1 = sizeof(str1)/sizeof(str1[0]);
int n2 = sizeof(str2)/sizeof(str2[0]);
printf("n1=%d, n2=%d", nl, n2); 
return 0;
}


Options are:

 a) n1= 8, n2=8
 b) n1=9, n2=9
 c) n1=8, n2=9
 d) n1=9, n2=8

Answer is: (d) n1=9, n2=8



Q.8: What will be the output?

#include <stdio.h> 
int main()
{
int i, m=1, num[6] = {1,2,3,4,5,6};
for(i=0; i<=5; i++) 
m=m*num[i];
printf("%d", m);
return 0;
}

Answer is: 720



Q.9: What will be the output?

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

Options are: 

 a) assignment
 b) tnemngissa
 c) nothing will be printed
 d) tttttttttt

Answer is: (c) nothing will be printed



Q.10: What will be the output?

#include<stdio.h> 
#include<string.h>
int main()
{
char p[] = "welcome", q[]="welcome";
if(p==q)
{
printf("Two strings are equal");
}
return 0;
}

Options are:

 a) Two strings are equal
 b) Two strings are not equal
 c) Would not print anything
 d) Compilation error

Answer is: (c) Would not print anything


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

Post a Comment

0 Comments