write a program using 2 D that searches a number and display
the number of items 12 inputs values
input 15,20, 13, 30, 38, 40,16, 18, 20 ,18 ,20
enter no. to search : 20
Answer / Vishal Kumar Rai
Here is a simple C++ code for searching a specific number in a 2D array and displaying its count:n```cppn#include <iostream>nconst int size = 4;nint arr[size][size] = {n{15, 20, 13, 30},n{38, 40, 16, 18},n{20, 18, 20, 38},n{15, 30, 40, 16}n};nint search(int num){n int count = 0;n for (int i = 0; i < size; ++i) {n for (int j = 0; j < size; ++j) {n if (arr[i][j] == num) {n count++;n }n }n }n return count;n}nint main() {n int num;n std::cout << "Enter a number to search: ";n std::cin >> num;n std::cout << "The number of occurrences for " << num << " is: " << search(num) << '.'n return 0;n}n```
| Is This Answer Correct ? | 0 Yes | 0 No |
how to write a program that opens a file and display in reverse order?
What output does this program generate as shown? Why? class A { A() { cout << "A::A()" << endl; } ~A() { cout << "A::~A()" << endl; throw "A::exception"; } }; class B { B() { cout << "B::B()" << endl; throw "B::exception"; } ~B() { cout << "B::~B()"; } }; int main(int, char**) { try { cout << "Entering try...catch block" << endl; A objectA; B objectB; cout << "Exiting try...catch block" << endl; } catch (char* ex) { cout << ex << endl; } return 0; }
write a function -oriented program that generates the Fibonacci, the current numbers of n(as input) and display them (series). In Fibonacci, the current third number is the sum of the previous number.
Code for Small C++ Class to Transform Any Static Control into a Hyperlink Control?
write a program that can locate elements in array.
Min-Max Write an algorithm that finds both the smallest and largest numbers in a list of n numbers and calculate its complexity T(n).
1 Answers Infosys, Qatar University,
Write a program using one dimensional array that searches a number and display the number of times it occurs on the list of 12 input values. Sample input/output dialogue: Enter 12 values: 13 15 20 13 30 35 40 16 18 20 18 20 Enter number to search: 20 Occurences: 3
Complexity T(n) Write a linear-time algorithm that sorts n distinct integers, each of which is between 1 and 500. Hint: Use a 500-element array. (Linear-time means your algorithm runs in time c*n + b, where c and b are any constants that do not depend on n. For example, your algorithm can run in time n, or time 2n + 1, or time 5n + 10, or time 100n + 6, but not time c*n*n = c*n?.)
1+1/2!+1/3!+...+1/n!
Algorithm in O(2n) Presently we can solve in our hypothetical machine problem instances of size 100 in 1 minute using algorithm A, which is a O(2n). We would like to solve instances of size 200 in 1 minute using algorithm A on a new machine. What is the speed of the new machine should be?
2 Answers ABC, Qatar University,
Given 1 to n random number, find top 10 maximum numbers and explain the time complexity of the algorithm.
write a program to calculate the amount of investment after a period n years if the principal investors was p and interest is calculated using compound interest,formular=a=p(1+r)^n
1 Answers Jomo Kenyatta University,