Given the following program interface and btnProcess() code, write the code for
ID: 3762007 • Letter: G
Question
Given the following program interface and btnProcess() code, write the code for count() which counts the number of times the entered number occurs in the array.
Dim intNum() As Integer = {4, 5, 6, 3, 5, 4, 7, 6, 8, 7, 2, 1, 3, 2, 5, 6, 7, 4, 5, 3, 2, 8, 9, 7, 8, 6}
Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
Dim intTarget As Integer
Dim intPos As Integer
intTarget = Convert.ToInt32(TextBox1.Text)
TextBox2.Text = count(intTarget)
End Sub
Enter a number Process Dste Resuts 4Explanation / Answer
# include <stdio.h>
# define N 1000
int main (void)
{
int a[N], i=0, num_int, count=0, counters[11] = {0};
printf("Enter no. of integers to be inputted : ");
scanf("%d",&num_int);
for (i=0; i<num_int; i++){
a[i] = rand() % 10 + 1;
}
for( i = 1; i <num_int; i++ )
++counters[a[i]];
printf(" ");
for (i=0; i<num_int; i++){
printf("%d occurs %d times ", a[i], counters[i]);
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.