Smaller than average Write a program that inputs a number of
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


