7.1 Programming Techniques
1. A programmer creates this function shown in Fig. 5 using a high-level language.
function mystery(x,y) total = x + y while x >= 10 then x = x – 10 y = y – 10 total = total + x + y endwhile return total endfunctionThe programmer creates another function to count and return how many capital letters are in a string that is passed into the function as a parameter.
The asc() function takes in a character and returns its ASCII value. For example asc("A") returns 65. Capital letters have ASCII values between 65 and 90 inclusive.
Complete the function below
function countCapitals(text) // initialise counter to 0 capCount = 0 // loop through each character in the string passed in for x = 0 to text.length-1 c = text.subString(x, 1) // check if character is a capital if asc(c) >= 65 …………………………………………………………… // if so, increment counter ………………………………………………………………………… endif next x …………………………………………………………………… endfunctionAi এর মাধ্যমে
১০ লক্ষ+ প্রশ্ন ডাটাবেজ
প্র্যাকটিস এর মাধ্যমে নিজেকে তৈরি করে ফেলো
উত্তর দিবে তোমার বই থেকে ও তোমার মত করে।
সারা দেশের শিক্ষার্থীদের মধ্যে নিজের অবস্থান যাচাই
No related questions found