NPTEL Problem Solving Through Programming In C Week 1 Assignment Answers 2024
{Week 1} NPTEL Problem Solving Through Programming In C Assignment Answers 2024
1. Which of the following is a valid C variable name?
a) 2variable
b) variable_2
c) variable-2
d) variable.2
Answer :- b
2. Which of the following functions is used to read a single character from the keyboard in C?
a) printf()
b) scanf()
c) getchar()
d) puts()
Answer :- For Answer Click Here
3. What is the purpose of the #include directive in a C program?
a) To include a library file.
b) To include a library file.
c) To define a constant.
d) To start the main function.
Answer :- For Answer Click Here
4. Which of the following correctly describes the purpose of a compiler in C?
a) To execute the program line by line.
b) To convert source code into machine code.
c) To provide a runtime environment for program execution.
d) To interpret and run the program interactively.
Answer :-
5. Which of the following is true about the execution nature of C programs?
a) C programs are executed in an event-based manner.
b) C programs are executed concurrently.
c) C programs are executed in a multi-threaded manner.
d) C programs are executed sequentially.
Answer :- For Answer Click Here
6. In C programming, what is the best way to comment multiple lines?
a) Using // at the beginning of each line.
b) Enclosing the comments between /* and */.
c) Using # at the beginning of each line.
d) Enclosing the comments between { and }.
Answer :-
7. Which of the following is a characteristic of the ASCII standard?
a) It supports encoding for all the world’s languages.
b) It uses 16-bit encoding for characters.
c) It is a 7-bit character encoding standard.
d) None of the above.
Answer :-
8. Which of the following statements is true regarding variable declaration in C?
a) Variables can be declared at any point in the program.
b) Variables must be declared before they are used.
c) Variables are automatically initialized to zero.
d) Variable names can start with a digit.
Answer :- For Answer Click Here
9.
a) 4
b) 8
c) 16
d) 20
Answer :-
10.
a) 21
b) 28
c) 30
d) 40
Answer :- For Answer Click Here
NPTEL Problem Solving Through Programming In C Week 3 Assignment Answers 2023
1. Which of the following statement is correct?
a) Operator precedence determines which operator is performed first in an expression with more than one operator with different precedence. Associativity is used when two operators of same precedence appear in an expression
b) Operator associativity determines which operator is performed first in an expression with more than one operator with different associativity. Precedence is used when two operators of same precedence appear in an expression
c) Operator precedence and associativity are same.
d) None of the above
Answer :-
2. Find the output of the following C code?
#include <stdio.h>
int main() {
int a = 50, b = 20, c = 6, d = 3, result;
result = a + a * -b / c % d + c * d;
printf("%d", result);
return 0;
}
a) 67
b) -36
c) 66
d) -37
Answer :- For Answer Click Here
3. What is the output of the following C code?
#include <stdio.h>
int main() {
int h = 8;
int b = 4 * 6 + 3 * 4 < h * 5 ? 24 : 3;
printf("%d\n", b);
return 0;
}
a) 0
b) 3
c) 4
d) Compilation error
Answer :-
4. Find the output of the following C code?
#include <stdio.h>
int main() {
int x = 1;
if ((3 * 25) > (2 * 53))
printf("IITKGP\n");
else if (x &= 0)
printf("IITD\n");
else
printf("IITM\n");
return 0;
}
a) IITKGP
b) IITD and IITM
c) IITKGP and IITM
d) IITM
Answer :-
5. What will be the output?
a) Condition is true
b) Condition is false
c) Error
d) No output possible
Answer :-
6. What is the output of the following program?
a) Programming on C 0
b) NPTEL 0
c) NPTEL 3
d) Compilation error
Answer :- For Answer Click Here
7. What is the output of the C program given below
a) true
b) false
c) Compiler dependent
d) Compiler error
Answer :-
8. What will be the output?
a) 0
b) 1
c) 10
d) 30
Answer :-
9. What will be the output
a) TRUE
b) FALSE
c) Syntax Error
d) Compilation Error
Answer :-
10. What is the output of the following C code?
a) 10
b) 11
c) 20
d) Compiler error
Answer :- For Answer Click Here
NPTEL Problem Solving Through Programming In C Week 2 Assignment Answers 2023
1. Which of the following is not a C variable?
a) Count123
b) Count_123
c) Count@123
d) X_123_Count
Answer :-c) Count@123 In C programming, variable names can consist of letters (both uppercase and lowercase), digits, and underscores, but they cannot include special characters like '@' or other symbols. Therefore, "Count@123" is not a valid C variable name. The other options, "Count123," "Count_123," and "X_123_Count," are valid C variable names and can be used in C programming to represent variables.
2. A function
a) is a block of statements to perform some specific task
b) is a fundamental modular unit to perform some task
c) has a name and can be used multiple times
d) All the above options are true
Answer :- d) All the above options are true. All of these options are true when describing functions in programming. A function is a reusable block of code that performs a specific task or operation. It is designed to be modular, which means it can be called multiple times from different parts of the program, promoting code reusability and organization. The function is identified by its name, and when the function is called by its name, the block of code within the function is executed.
3. The execution of any C program is
a) Sequential
b) Parallel
c) Multi-threading
d) None of these
Answer :- a) Sequential The execution of any C program is typically sequential, which means the instructions in the program are executed one after the other, in the order they appear in the source code. Each instruction is executed in a step-by-step manner, and the program follows a specific flow from the start of the main function to its end, unless certain control flow statements like loops or conditional statements cause branching in the execution flow.
4. Syntax error occurs when
a) The rules of grammar of the programming language is violated
b) The statements in the program have no meaning
c) The program gives wrong or undesired output
d) Some illegal operation (e.g. divide by zero) is performed
Answer :- a) The rules of grammar of the programming language are violated Syntax errors occur when the rules of grammar and syntax of the programming language are violated. These errors prevent the program from being successfully compiled or interpreted because the code does not conform to the language's syntax rules. Examples of syntax errors include missing semicolons at the end of statements, mismatched parentheses or brackets, using incorrect keywords, and improper indentation.
5. If integer needs two bytes of storage, then the minimum value of a signed integer in C would be
a) -65535
b) 0
c) -32,767
d) -32,768
Answer :- d) -32,768 If an integer needs two bytes of storage, it means it can store values within a range of 2^15 (because each byte has 8 bits, so 2 bytes have 16 bits, but one bit is reserved for the sign, leaving 15 bits for the magnitude of the integer).
6. What will be the output of the program given below?
a) 9
b) 0
c) 1001
d) Compilation Error
Answer :- d) Compilation Error
7. What is the Output?
a) 8.00
b) 4.00
c) 0.00
d) 16.00
Answer :- d) 16.00
8.
a) a=a-b; b=a-b; a=a+b;
b) a=a%b; b=a+b; a=a/b;
c) a=a+b; b=a-b; a=a-b;
d) None of the above
Answer :- c) a = a + b; b = a - b; a = a - b;
9. What will be the output?
a) 1 3
b) 3 1
c) 1 1
d) 3 3
Answer :- b) 3 1
10. When executed the following code will print_______.
Answer :- 18
NPTEL Problem Solving Through Programming In C Week 1 Assignment Answers 2023
1. What type of device is computer webcam?
a) Memory
b) Output
c) Storage
d) Input
Answer :- d) Input A computer webcam is an input device. It captures video and sometimes audio, allowing users to input live images and video into their computers. It is commonly used for video conferencing, online meetings, video chatting, live streaming, and other applications where real-time video input is required.
2. Set of instructions to be provided to an electronic machine to perform a task is called
a) Programming
b) Processing
c) Computing
d) Compiling
Answer :- a) Programming Programming involves providing a set of instructions to an electronic machine or computer to perform a specific task. These instructions are written in a programming language and are used to control the behavior of the machine, enabling it to execute the desired operations and achieve the intended results. The process of converting the human-readable programming code into machine-executable instructions is known as compiling (option d), but the overall act of providing instructions to perform a task is referred to as programming. Options b and c are related concepts but not the precise term used for this purpose.
3. Which of the following language does the computer understand?
a) Computer understands only C Language
b) Computer understands only Assembly Language
c) Computer understands only Binary Language
d) Computer understands only BASIC
Answer :- c) Computer understands only Binary Language Computers at their core understand and process instructions in binary language, which consists of 0s and 1s. This binary language represents the fundamental building blocks of all data and instructions that computers can interpret and execute. All high-level programming languages, like C, Assembly, BASIC, Python, Java, etc., need to be translated into binary instructions through compilation or interpretation before the computer can execute them. However, it is binary language that the computer's hardware can directly understand and act upon.
4. Which of the following is known as the language made up of binary-coded instructions?
a) High level
b) BASIC
c) C
d) Machine
Answer :- d. Machine The language made up of binary-coded instructions is known as "Machine Language." Machine language is the lowest-level programming language that is directly understood and executed by a computer's hardware. It consists of binary-coded instructions represented in the form of 0s and 1s, which the computer's central processing unit (CPU) can directly interpret and execute.
5. Algorithm is-
a) A process or set of rules to be followed in calculations or other problem-solving operations, especially by a human.
b) A process or set of rules to be followed to solve numerical problems only.
c) A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.
d) A process or set of rules to be followed in to solve logical problems only.
Answer :- c) A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer. An algorithm is a step-by-step procedure or a set of rules to be followed for solving a specific problem or performing a task. It can be used by both humans and computers to arrive at a solution. However, in the context of the given options, option c is the most accurate definition because it explicitly mentions that algorithms can be used by computers in problem-solving operations. Algorithms are essential in computer programming as they define the logic and steps required to achieve a particular goal or outcome.
6. A 2D diagram to represent the steps to be followed to solve a problem is known as
a) Flow-chart
b) Pseudo-code
c) Both (a) and (b)
d) None of these
Answer :- a) Flow-chart A 2D diagram that represents the steps to be followed to solve a problem is known as a flowchart. It is a graphical representation of an algorithm or a process, using various shapes and arrows to depict the sequence of steps and decisions involved in the problem-solving process. Flowcharts are commonly used in programming, software development, and other fields to illustrate the logical flow of operations and to make complex processes more understandable. Pseudo-code (option b) is a high-level, human-readable representation of an algorithm using a combination of natural language and simple code-like statements but not a 2D diagram. So, the correct answer is option
7. Which one of the following statement is the most appropriate?
a) Pseudo code is basically a diagrammatic representation of the algorithm. Whereas in flowchart normal English language is translated into the programming languages to be worked on.
b) Flowchart is diagrammatic representation of the algorithm. Pseudo code is just another name of algorithm.
c) Pseudo code is another name of programming. Whereas in flowchart is diagrammatic representation of algorithm.
d) Flowchart is basically a diagrammatic representation of the algorithm. Whereas in pseudo code normal English language is translated into the programming languages to be worked on.
Answer :- a) Pseudo code is basically a diagrammatic representation of the algorithm. Whereas in flowchart normal English language is translated into the programming languages to be worked on. This statement accurately describes the differences between pseudo code and flowcharts. Pseudo code is a method of representing an algorithm using a combination of natural language and simple code-like statements, making it more readable and understandable for humans. On the other hand, flowcharts are graphical representations of algorithms that use shapes and arrows to depict the sequence of steps and decisions. In flowcharts, normal English language is not directly translated into programming languages; instead, the graphical symbols represent different programmatic constructs.
8. The input N from the user is 6. The output of the following algorithm is
a) 21
b) 720
c) 1
d) 1024
Answer :- c) 1
9. What will be the output of the algorithm given below?
a) 51
b) 52
c) 50
d) Compilation error
Answer :- d) Compilation error
10. The section of the CPU that selects, interprets and sees to the execution of program instructions
a) Memory
b) Register Unit
c) Control Unit
d) ALU
Answer :- c) Control Unit