Question

In: Computer Science

>>>>>C#<<<<< A.     Number Frequency-Arrays Write a program to count the number of 10’s in the given...

>>>>>C#<<<<<

A.     Number Frequency-Arrays

  1. Write a program to count the number of 10’s in the given list of 15 numbers. The output should look like:                                                                                                        [01]
  2. Extend your program to work with a list of n numbers.                                         [01]

                                                                                  

          Random Numbers-Methods

  1. Write a program to generate a 10 Random Numbers:                                           [01]
  2. Extend your program to generate n Random numbers.                                         [01]

B.    Word Count -String Processing

  1. Write a program to count the occurrence of word “an” in the string.               [01]
  2. Extend your program to count the occurrence of string being input in the string.

               [01]

C.      Recursion

          By using recursion, write a program to:

  1. Print digits in a number.                                                                                                                [01]
  2. Find sum of digits of a number.                                                                                                  [01]

D.        Matrix Manipulation

Write a C# program to Perform Matrix Multiplication.                                                                      [02]

Note:-

The matrix multiplication can be performed only if:

  • The number of columns of the first matrix is equal to
  • The number of rows of the second matrix

Ok sorry for that , i need only (A) section.

Solutions

Expert Solution

#include<stdio.h>
main()
{
   int list[15]={33,5,11,10,6,10,54,1,2,10,45,55,10,14,51},i,c=0;//initially count of 10's is 0
   for(i=0;i<15;i++)
   {
       if(list[i]==10)
           c++; //counts no.of 10's in an array
   }
   printf("number of 10's in the given list of 15 numbers: %d",c);
}

#include<stdio.h>
main()
{
   int n,i,c=0;//initially count of 10's is 0
   printf("Enter number of elements in list: ");
   scanf("%d",&n);
   int list[n];//declaring an array
   printf("Enter elements in list:\n");
   for(i=0;i<n;i++)
   {
       scanf("%d",&list[i]);  
   }
   for(i=0;i<n;i++)
   {
       if(list[i]==10)
           c++; //counts no.of 10's
   }
   printf("number of 10's in the given list: %d",c);
}

#include <stdio.h>
#include <stdlib.h>
main()
{
   int i, r;
   printf("10 random numbers between 0 t0 100:\n");
    for (i=1;i<=10;i++)
   {
   r=rand() % 100 + 1;//generates random number b/w 0 to 100
   printf("%d ",r);
}
}

#include <stdio.h>
#include <stdlib.h>
main()
{
   int i, n,r;
   printf("Enter no.of random numbers you want to generate:");
   scanf("%d",&n);
   printf("%d random numbers between 0 t0 500:\n",n);
    for (i=1;i<=n;i++)
   {
   r=rand() % 500 + 1;//generates random number b/w 0 to 500
   printf("%d ",r);
}
  
}


Related Solutions

C LANGUAGE ONLY Write a C program to count the frequency of each element in an...
C LANGUAGE ONLY Write a C program to count the frequency of each element in an array. Enter the number of elements to be stored in the array: 3 Input 3 elements of the array: element [0]: 25 element [1]: 12 element [2]: 43 Expected output: The frequency of all elements of an array: 25 occurs 1 times 12 occurs 1 times 3 occurs 1 times
In C++ For this assignment, you will write a program to count the number of times...
In C++ For this assignment, you will write a program to count the number of times the words in an input text file occur. The WordCount Structure Define a C++ struct called WordCount that contains the following data members: An array of 31 characters named word An integer named count Functions Write the following functions: int main(int argc, char* argv[]) This function should declare an array of 200 WordCount objects and an integer numWords to track the number of array...
2.c++ if and loop statement Write a program that will count the number of even number...
2.c++ if and loop statement Write a program that will count the number of even number and odd numbers between two inputted numbers. Display the numbers and compute the sum and average of all the even numbers and the sum and average all the odd numbers. Sample outputs: Enter starting number:3 Enter starting number:4 Enter ending number:10 Enter ending number:10 odd numbers Even number 3 4 5 6 7 8 9 10 number of even numbers=4 number of even numbers=4...
Count the number of 1’s and 0’s Write a MIPS program that will ask the user...
Count the number of 1’s and 0’s Write a MIPS program that will ask the user to enter an integer, and then output the number of 1’s and 0’s that are present in the integer’s signed 32-bit binary representation. For example, 15 has a binary representation of 0000 0000 0000 0000 0000 0000 0000 1111, which has 28 zeroes and 4 ones. We have provided you the starter code that deals with the input/output logic. The integer input is saved...
Given a string, such as x = ‘itm330’, write a Python program to count the number...
Given a string, such as x = ‘itm330’, write a Python program to count the number of digits and the number of letters in it. For example, in ‘itm330’, there are 3 letters and 3 digits. Hint: Very similar to page 11 on the slides. To check if a character c is a digit, use c.isdigit(). If c is a digit, c.isdigit() will be a True.
C LANGUAGE ONLY Write a C program to count the total number of duplicate elements in...
C LANGUAGE ONLY Write a C program to count the total number of duplicate elements in an array. Enter the number of elements to be stored in the array: 3 Input 3 elements in the arrangement: element [0]: 5 element [1]: 1 element [2]: 1 Expected output: The total number of duplicate elements found in the array is: 1
In this program: ================================================================== /* Program to count number of occurrences of a given string in...
In this program: ================================================================== /* Program to count number of occurrences of a given string in original string*/ #include <iostream> #include <cstring> #include <stdio.h> #include <iostream> using namespace std; int main() { const int SIZE = 40; char str[SIZE]; char str1[SIZE]; char searchString[SIZE]; int n; int l1, l2; int count = 0; printf("Enter a sentence: \n"); fgets(str,SIZE,stdin); printf("Enter a search word: \n"); fgets(searchString,SIZE,stdin); if (str1[strlen(str1) - 1] == '\n') { str1[strlen(str1)-1] = '\0'; } if (str[strlen(str) - 1] == '\n')...
write a program in c language to count the number of spaces ina sentence .the sentence...
write a program in c language to count the number of spaces ina sentence .the sentence is saved in the string 'sentence' write it in a repl.it and along with input,output and algorithm
Write a C program. Problem 1: You are given two sorted arrays, A and B, and...
Write a C program. Problem 1: You are given two sorted arrays, A and B, and A has a large enough buffer at the end to hold B. Write a method to merge B into A in sorted order without using any other array space. Implementation instruction: (1) Define one array of size 18 for A and the other array of size 5 for B. (2) Initialize A by inputting 13 integers in the ascending order, and Initialize B by...
Write a C program. Problem 1: You are given two sorted arrays, A and B, and...
Write a C program. Problem 1: You are given two sorted arrays, A and B, and A has a large enough buffer at the end to hold B. Write a method to merge B into A in sorted order without using any other array space. Implementation instruction: (1) Define one array of size 18 for A and the other array of size 5 for B. (2) Initialize A by inputting 13 integers in the ascending order, and Initialize B by...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT