Smaller than average Write a program that inputs a number of

Smaller than average Write a program that inputs a number of integer values, computes the average and outputs that average along with all the values that are smaller than the average. The end-of-array dilemma Write a program that defines an array of type integer. Print out the array elements and go deliberately *beyond* the end of the array, i.e. read/output array elements with indexes that are not accommodated by the array definition. Now extend your program to continuously write beyond the end of the array. Output the indices of the elements that you wrote and check, how many elements you can get away with writing at illegimate locations. What are your conclusions of what you see? Search an array for a target value

Solution

Program that inputs a number of integer values computes the average and outputs that average along with all values that are smaller than average values

#include <iostream.h>

void main()

{

float value, sum;

float average, minimum, maximum;

int count;

       sum = 0.0;

count = 0;

cout << \"Enter a value: \";

cin >> value;

minimum = value;

maximum = value;

while (value >= 0.0)

    {

        

      sum += value;

      count++;

      if (value > maximum)

         maximum = value;

      else if (value < minimum)

        minimum = value;

        

      cout << \"Enter a value: \";

      cin >> value;

    }

if (count == 0)

    cout << \"No data entry\" << endl;

else

    {

      average = sum / count;

      cout << \"There were \" << count << \" numbers\" << endl;

      cout << \"Average was \" << average << endl;

      cout << \"Minimum was \" << minimum << endl;

      cout << \"Maximum was \" << maximum << endl;

    }

}

program that reads a string from the keyboard. pass the string to a function that determines the length of the string

#include <stdio.h>

int main()

{

    char text[100];

    int index= 0;

    printf(\"Enter any string: \");

    gets(text);

    while(text[index]!=\'\\0\')

    {

        index++;

    }

    printf(\"Length of \'%s\' = %d\", text, index);

    return 0;

}

C program to find length of a string using strlen() function

#include <stdio.h>

#include <string.h>

int main()

{

    char text[100];

    int length;

    printf(\"Enter any string: \");

    gets(text);

    length = strlen(text);

    printf(\"Length of \'%s\' = %d\", text, length);

    return 0;

}

A program to create a matrix multiplication table

 Smaller than average Write a program that inputs a number of integer values, computes the average and outputs that average along with all the values that are s
 Smaller than average Write a program that inputs a number of integer values, computes the average and outputs that average along with all the values that are s
 Smaller than average Write a program that inputs a number of integer values, computes the average and outputs that average along with all the values that are s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site