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