Hello dear...
Here is the C++ program to print the largest number among 100 integers using the conditional Ternary operatot. I have also written comments for better understanding. Also attached images of output and code for comfort of reading. Hope you will like it.
I have tested the program with an array of 100 random integers. Maximum value in the array is 295.
main.cpp
//import required libraries
#include <iostream>
using namespace std;
//main method
int main(){
//declare and initislise required variables
int n = 100, largest=0, i;
//creating an array of 100 random integers
int array[n] = { 240, 128, 239, 29, 232, 198, 294, 194, 136, 59, 173, 119, 241, 20, 16, 100, 17, 267, 267, 188, 268, 280, 285, 287, 84, 117, 142, 203, 6, 255, 281, 217, 275, 110, 22, 122, 289, 226, 128, 66, 1, 140, 212, 223, 176, 152, 186, 137, 295, 71, 255, 121, 215, 282, 124, 97, 49, 116, 137, 288, 291, 218, 42, 117, 81, 104, 258, 175, 21, 33, 12, 94, 110, 142, 149, 28, 158, 213, 107, 135, 293, 51, 233, 94, 160, 269, 238, 239, 98, 197, 245, 138, 280, 127, 257, 65, 21, 178, 97, 184 };
//for loop traverse though all the 100 integers
for(i=0; i<n; i++){
//conditional terinary operator
//it updates value of 'largest' if 'largest' is less than current number
//else 'largest' is 'largest'
largest = (largest < array[i]) ? array[i] : largest;
}
//print the largest number in the array to console ouput
cout << "largest number in all 100 integers is : " << largest;
//end
return 0;
}
Output:
Image of Code:
Hope you like it.
If you have any doubts ask me in comment section.
If you like my work, please give me a like and feedback. That helps me a lot. Thank you.
All the best.
Program written in C ++ to print the largest number among 100 integers using the conditional...
Write a complete C++ program to ask the user to enter 4 integers. The program must use a function to find the smallest integer among them and print it on the screen. Typical output screen should be as following: Write a complete C++ program to ask the user to enter 4 integers. The program must use a functionto find the smallest integer among them and print it on the screen. Typical output screen should be as following: Note: the code...
Write a complete C++ program to ask the user to enter 4 integers. The program must use a function to find the LARGEST integer among them and print it on the screen. Typical output screen should be as following: Note: the code must contain function to find the LARGEST number. Enter four integers 1 2 4 0 Largest integer is 4
Write a complete C++ program to ask the user to enter 4 integers. The program must use a function to find the largest integer among them and print it on the screen. Typical output screen should be as following: Note: the code must contain function to find the largest number. Enter four integers 1 2 4 0 Largest integer is 4 03 (35 points)
(+30) Provide a python program which will Populate an array(list) of size 25 with integers in the range -100 (negative 100) to +100 inclusive Display the array and its length (use the len function) Display the average of all the integers in the array Display the number of even integers (how many) Display the number of odd integers (how many) Display the number of integers > 0 (how many) Display the number of integers < 0 (how many) Display the...
IN PERL Write a program that will ask the user for a number and will print all the integers in order starting from 1 until the number. Use the <> operator to ask for the user's input. For this program you will write a countdown timer. Your time will count down from 1 minute (60 seconds) to 0. Once the timer gets to 0 seconds the system will display a message that reads: RING RING RING! -using do while-
Prime Number Programing in C Note: The program is to be written using the bitwise operation. Use an integer array (not a Boolean array) and a bit length (for instance 32 bits). In this program you will write a C program to find all prime numbers less than 10,000. You should use 10,000 bits to correspond to the 10,000 integers under test. You should initially turn all bits on (off) and when a number is found that is not prime,...
in C The preceding LML program reads two numbers from the keyboard and determines and prints the larger value. Note the use of the instruction +4107 as a conditional trans- fer of control, much the same as C's if statement. In-Class Tasks Write LML programs that accomplish each of the following tasks: Use a sentinel-controlled loop to read 10 positive integers and compute and print their sum 1. 2. Use a counter-controlled loop to read seven numbers, some positive and...
A. Create a java program that generates 1000 random integers. Write the 1000 random integers to a file using the Formatter class. B. Create a second java program that opens the file with the 1000 integers using the Scanner class. Read in the integers and find and print out the largest, smallest and the average of all 1000 numbers. C. Repeat A from above but use the BufferedWriter class B. Repeat B from above but use the BufferedReader class.
Write a program that creates a list of 20 integers (between 1 and 40) using a random number generator function. Write a function that returns the index (position) of the third largest element from the list of integers. If there are more than one third largest number, return the index of the first occurrence of that number. Eg: Assume that your main function has created the following list of integers generated from the random number function. [12, 30, 28, 4,...
Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...