Skip to content

MyUstaadG

Learn to Serve

  • Computer Science
    • Software
    • Computer Tips
    • Coding
      • Conditional Structures Exercises
      • Loops Exercises
      • Arrays Exercises
      • Python Exercises
    • Microsoft Office
      • MS Excel
      • MS Word
  • Videos
    • Funny Videos
    • Health and Fitness Videos
    • PUBG Videos
    • Technology Videos
  • News
  • Funny
  • Memes
  • Playwright Tutorials
  • Tutorials
  • Toggle search form

Write a program that inputs 10 values using the while loop. It finds out and display the largest and the smallest values

Posted on October 1, 2021 By myustaadg.com
Spread the love

Write a program that inputs 10 values repeatedly in a single variable using the ‘while’ loop structure. It finds out the largest and the smallest input values inside the body of loop and displays these values when loop is terminated.

We learn Programming to solve problems using Computers. A Computer Program is the set of instructions that are given to a computer so that it can solve problems. To solve problems is our primary goal in Computer Science.

C++ is the most fundamental language to learn programs. C++ is the High-Level Language.  It is very easy to instruct computers using C++ Programming Language. My goal is to provide Practice Programs. Because As we know practice is the most fundamental aspect to learn how to program. I will provide solved programming exercises to help students.

What is Compiler?

A Compiler is computer software that is used to convert a C++ language program to a computer’s native language which is binary language. It is a translator program. It is used to convert Source Code into Object Code.

What is Source Code?

Any instruction that is written in High-Level Language i.e. C++ or C is known as Source Code.

What is Object Code?

Any Code that is written in Low-Level Language i.e. Assembly Language or Binary Language is known as Object Code.

Conditional Structure Programming Exercises

So we will use Dev C++ Compiler for C++ Programming.

What is Loop in C++?

In some cases, we have to repeat a statement or set of statements a certain number of times. This repetition is known as a loop. Commonly loop has three main parts

  1. Initialization
  2. Condition
  3. Increment / Decrement

There are thee main types of Loops.

  1. While Loop
  2. Do-While loop
  3. For Loop

While Loop

While loop is used to repeat a statement or set of statements again and again until the condition remains true. While loop checks the condition first and then executes the statements. While loop is used when the number of iterations is unknown in advance.

Syntax of While Loop

while(condition)
{
      //body
      //increment/Decrement
}

Do while Loop

The do-While loop is used to repeat a statement or set of statements again and again until the condition remains true. Do-While loop first executes the body of the loop then checks the condition. Do-While Loop is used when the number of iterations is unknown.

Syntax of Do-While Loop

do
{
   //body of do-while loop
}while(condition);

For Loop

The For loop is used to repeat a statement or set of statements again and again until the condition remains true. For Loop is used when the number of iterations is known.

Syntax of For Loop

for(initialization, condition, increment/.decrement)
{
  //body of For Loop
}

So Let’s Write Some Code.

Write a program that inputs 10 values repeatedly in a single variable using the ‘while’ loop structure. It finds out the largest and the smallest input values inside the body of loop and displays these values when loop is terminated.

#include<iostream>
using namespace std;
main()
{
int n, count, largest, smallest;
cout<<count<<" Enter a value ? ";
cin>>n;
largest = smallest = n;
count = 1;
while(count<10)
{
cout<<count<<" Enter a value ? ";
cin>>n;
if(n > largest)
largest = n;
if(n < smallest)
smallest = n;
count++;

}
cout<<" Largest value is : "<<largest<<endl;
cout<<" Smallest value is : "<<smallest;


}

We will Cover the Following topics or tags on this website.

Basic Programs In C++

C++ Coding Guideline

Class Programs In C++

Coding Convention C++ Namespace

Coding Examples C++

Coding Ground C++

Coding In C++ For Beginners

Coding In C++ Online

Coding With C++

Coding Websites C++

Complex Number Program In C++

Constructor Programs In C++

Data Structures Programs In C++

Example Programs In C++

Programs In C++ Examples

Exception Handling Programs In C++

For Loop Programs In C++

Function Overloading Programs In C++

Function Programs In C++

Game Programs In C++

Graphics Programs In C++

How To Create Programs In C++

How To Make Programs In C++

How To Write Programs In C++

Huffman Coding In C++

If Else Programs In C++

If Programs In C++

Implementation Of Stack Using Array In C++ Programs

In C++ Programs The Keyword Friend Appears In The

Inheritance Programs In C++

Interview Programs In C++

Number Pattern Programs In C++

Oops Programs In C++

Operator Overloading Programs In C++

Pattern Programs In C++

Programming In C++ Questions And Answers

Programs In C++ For Beginners

Programs In C++ Pdf

Programs In C++ Using Class

Programs In Turbo C++

Programs Of C++

Programs Of C++ Language

Writing Programs In C++

Structure Programs In C++

Template Program In C++

String Programs In C++

Stack Programs In C++

Sorting Programs In C++

Simple Programs In C++

Queue Program In C++

While loop Programming Exercises

Do While Loop Programming Exercises

For Loop Programming Exercises

Loops Exercises Tags:Basic Programs In C++, C++ Coding Guideline, Class Programs In C++, Coding Convention C++ Namespace, Coding Examples C++, Coding Ground C++, Coding In C++ For Beginners, Coding In C++ Online, Coding Websites C++, Coding With C++, Complex Number Program In C++, Constructor Programs In C++, Data Structures Programs In C++, Dev C++, Do While Loop Programming Exercises, Example Programs In C++, Exception Handling Programs In C++, For Loop Programming Exercises, For Loop Programs In C++, Function Overloading Programs In C++, Function Programs In C++, Game Programs In C++, Graphics Programs In C++, How To Create Programs In C++, How To Make Programs In C++, How To Write Programs In C++, Huffman Coding In C++, If Else Programs In C++, If Programs In C++, Implementation Of Stack Using Array In C++ Programs, In C++ Programs The Keyword Friend Appears In The, Inheritance Programs In C++, Interview Programs In C++, mohammad umar, myustaadg, Number Pattern Programs In C++, Object Code, Oops Programs In C++, Operator Overloading Programs In C++, Pattern Programs In C++, Programming In C++ Questions And Answers, Programs In C++ Examples, Programs In C++ For Beginners, Programs In C++ Pdf, Programs In C++ Using Class, Programs In Turbo C++, Programs Of C++, Programs Of C++ Language, Queue Program In C++, Sorting Programs In C++ Simple Programs In C++, Source Code, Stack Programs In C++, String Programs In C++, Structure Programs In C++, Template Program In C++, While loop Programming Exercises, Writing Programs In C++

Post navigation

Previous Post: How to Recover Unsaved file or Documents in MS Word | Find the Original Document | Recover a Damage Document | Backup Copies of Document
Next Post: Write a program that displays prime numbers between 2 and 100 using the while loop

More Related Articles

Write a program that displays prime numbers between 2 and 100 using the while loop Loops Exercises
Write a program that calculates and displays the product of the even numbers from 1 to 8 using the while loop Loops Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme