0% Programming Skills - NAT (National Aptitude Test)Programming Skills refers to the Computer Science portion of the National Aptitude Test (NAT), a standardised test for admissions in Pakistan. 1 / 50What does the ++ operator do? Increases the value of a variable by 1. Adds 2 to a variable. Compares two values for equality. Multiplies a variable by itself. 2 / 50A function is defined as int calculate(int a, int b). What does the int before calculate signify? The function takes integer inputs. The function returns an integer value. The function has internal integer variables. The function name is an integer. 3 / 50How many times will the body of this loop execute? for(int i=5; i>0; i--) { } 4 times 5 times Infinite times 6 times 4 / 50In an array, all elements must be of the same? Size Index Value Data Type 5 / 50What is the term for a variable that is declared inside a function? Global Variable Local Variable External Variable Constant Variable 6 / 50What is the role of a compiler? To translate high-level code into machine code all at once. To execute the program line by line. To find and fix logical errors in the code. To design the user interface for the program. 7 / 50What is the main purpose of an algorithm? To declare variables. To draw a flowchart. To write code in a specific programming language. To provide a step-by-step procedure for solving a problem. 8 / 50What is the primary purpose of a variable in programming? To create loops To perform mathematical calculations To define functions To store and manipulate data 9 / 50Which data type is most suitable for storing a single character like 'A'? int char float string 10 / 50What is the value of result? int result = (10 == 10); 10 1 0 True 11 / 50What is the primary goal of a sorting algorithm? To arrange the elements of a list in a specific order (ascending/descending). To combine two lists into one. To reduce the memory used by an array. To search for an element in a list. 12 / 50Which keyword is used to define a constant value that cannot be changed? static const or final variable fixed 13 / 50 In a do-while loop, the condition is checked? In the middle of the loop. At the end of the loop. It is not checked at all. At the beginning of the loop. 14 / 50What is the value of arr[2] after the code int arr[] = {10, 20, 30, 40}; is executed? 40 20 10 30 15 / 50Which of the following is a key step in the Linear Search algorithm? Repeatedly swap adjacent elements. Check each element in the list one by one. Compare the target value with the middle element. Divide the list into smaller sub-lists. 16 / 50Which of the following is the correct way to write an assignment statement? x == 5; x : 5; x -> 5; x = 5; 17 / 50 In programming, a sequence of characters is called a? Word Character Text String 18 / 50The process of combining two strings is called? Linking Adding Merging Concatenation 19 / 50 If a is 10 and b is 3, what is the value of a % b? 0 1 30 3 20 / 50 In a flowchart, what shape is used to represent a decision? Parallelogram Rectangle Diamond Oval 21 / 50What is the purpose of an if statement? To define a function. To make a decision based on a condition. To declare a variable. To repeat a block of code. 22 / 50What will this loop print? for(int i=0; i<3; i++) { printf("%d ", i); } 1 2 3 0 1 2 3 0 1 2 1 2 23 / 50Which of the following is a syntactically correct variable name? total_score my variable int 1stNumber 24 / 50What is the result of the expression 15 / 4 in integer division? 4 2 6 3 25 / 50The expression !(5 > 3) evaluates to: 3 False True 5 26 / 50Which of the following is a logical operator? + && == = 27 / 50What is the purpose of the else part in an if-else statement? To terminate the program. To execute code only if the if condition is true. To check another condition. To execute code only if the if condition is false. 28 / 50In a switch statement, which keyword is used to terminate a case? stop break end exit 29 / 50What is the purpose of comments in source code? To explain the code and make it more readable for programmers. To instruct the compiler to ignore syntax errors. To increase the execution speed of the program. To declare constants. 30 / 50What is the primary characteristic of the Bubble Sort algorithm? It divides the array into halves. It uses a pivot element to partition the array. It swaps adjacent elements if they are in the wrong order. It selects the minimum element and swaps it with the first. 31 / 50Which protocol is primarily used for securely transferring web pages over the internet? HTTP FTP SMTP HTTPS 32 / 50Which of the following best describes an algorithm? A type of computer hardware A set of rules to solve a problem in a finite number of steps The final output of a program A programming language 33 / 50Which symbol is commonly used in pseudocode to represent an output operation? IF OUTPUT or PRINT SET INPUT 34 / 50What does the following code do? while(condition) { // code } Executes the code a fixed number of times. Executes the code exactly once. Executes the code only if the condition is false. Repeatedly executes the code as long as the condition is true 35 / 50What is the final value of x after this code executes? int x = 5; x = x + 2; 2 5 10 7 36 / 50Which loop is best used when the number of iterations is unknown beforehand? while loop for loop Both B and C do-while loop 37 / 50Which control structure is used to execute a block of code a specific number of times? switch statement if-else statement for loop while loop 38 / 50Which of these is a Boolean data type? Can hold values like true and false. Can hold decimal numbers. Can hold a single character. Can hold whole numbers. 39 / 50 In pseudocode, the statement SET count = 0 is equivalent to? while count < 0 input count count = 0; in a programming language. if count == 0 40 / 50A flowchart symbol shaped as a parallelogram typically represents: A decision The start or end An input/output operation A process 41 / 50 Which searching algorithm requires the list to be sorted for it to work? Binary Search Bubble Search Sequential Search Linear Search 42 / 50In an array int scores[5];, what is the index of the first element? 0 5 6 1 43 / 50Which of the following is a valid function call for a function defined as void display()? display(); int x = display(); display; void display(); 44 / 50The process of finding and fixing errors in a program is called? Debugging Interpreting Executing Compiling 45 / 50The printf function in C is used for? Defining a new function Getting input from the user Performing calculations. Displaying output on the screen. 46 / 50Which data type is used to store decimal numbers like 3.14? double or float bool int char 47 / 50Which part of a function is known as its signature? The return statement The comment above the function The function's name and its parameter list The code inside the curly braces {} 48 / 50Which operator has the highest precedence in the expression 5 + 3 * 2? () (Parentheses) + (Addition) * (Multiplication) = (Assignment) 49 / 50Which of the following is a comparison operator? = ! >= & 50 / 50What is the main advantage of using a function in a program? It automatically fixes logical errors. It makes the program run faster. It increases the memory usage. It reduces code redundancy and improves reusability. Your score isThe average score is 62% 0% Restart quiz