1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kotykmax [81]
2 years ago
15

Why use fflush(stdin) in C programming language?

Computers and Technology
1 answer:
vlabodo [156]2 years ago
7 0
<span>It is a a function which helps us  you to clean the input buffer.
you can  use this function if you are thinking that there might be some problem creating data  during  user inputs from stdin. </span>
You might be interested in
Write a program to read as many test scores as the user wants from the keyboard (assuming at most 50 scores). Print the scores i
Oksana_A [137]

Answer: Provided in the explanation segment

Explanation:

Below is the code to carry out this program;

/* C++ program helps prompts user to enter the size of the array. To display the array elements, sorts the data from highest to lowest, print the lowest, highest and average value. */

//main.cpp

//include header files

#include<iostream>

#include<iomanip>

using namespace std;

//function prototypes

void displayArray(int arr[], int size);

void selectionSort(int arr[], int size);

int findMax(int arr[], int size);

int findMin(int arr[], int size);

double findAvg(int arr[], int size) ;

//main function

int main()

{

  const int max=50;

  int size;

  int data[max];

  cout<<"Enter # of scores :";

  //Read size

  cin>>size;

  /*Read user data values from user*/

  for(int index=0;index<size;index++)

  {

      cout<<"Score ["<<(index+1)<<"]: ";

      cin>>data[index];

  }

  cout<<"(1) original order"<<endl;

  displayArray(data,size);

  cout<<"(2) sorted from high to low"<<endl;

  selectionSort(data,size);

  displayArray(data,size);

  cout<<"(3) Highest score : ";

  cout<<findMax(data,size)<<endl;

  cout<<"(4) Lowest score : ";

  cout<<findMin(data,size)<<endl;

  cout<<"(5) Lowest scoreAverage score : ";

  cout<<findAvg(data,size)<<endl;

  //pause program on console output

  system("pause");

  return 0;

}

 

/*Function findAvg that takes array and size and returns the average of the array.*/

double findAvg(int arr[], int size)

{

  double total=0;

  for(int index=0;index<size;index++)

  {

      total=total+arr[index];

  }

  return total/size;

}

/*Function that sorts the array from high to low order*/

void selectionSort(int arr[], int size)

{

  int n = size;

  for (int i = 0; i < n-1; i++)

  {

      int minIndex = i;

      for (int j = i+1; j < n; j++)

          if (arr[j] > arr[minIndex])

              minIndex = j;

      int temp = arr[minIndex];

      arr[minIndex] = arr[i];

      arr[i] = temp;

  }

}

/*Function that display the array values */

void displayArray(int arr[], int size)

{

  for(int index=0;index<size;index++)

  {

      cout<<setw(4)<<arr[index];

  }

  cout<<endl;

}

/*Function that finds the maximum array elements */

int findMax(int arr[], int size)

{

  int max=arr[0];

  for(int index=1;index<size;index++)

      if(arr[index]>max)

          max=arr[index];

  return max;

}

/*Function that finds the minimum array elements */

int findMin(int arr[], int size)

{

  int min=arr[0];

  for(int index=1;index<size;index++)

      if(arr[index]<min)

          min=arr[index];

  return min;

}

cheers i hope this help!!!

8 0
3 years ago
Which of the following is a quick way to restore the arrow pointer after you have used it for drawing?
Oxana [17]
A quick way to restore the arrow pointer after you have used it for drawing is to press the esc key.  The esc key is <span>used for any of the different </span>functions<span>, as to interrupt or cancel the current process or running program, or to close a pop-up window.</span>
7 0
2 years ago
When did mac start? when did windows start? when did lynux start?
ale4655 [162]

Answer: Macintosh start January 24, 1984

Windows start November 20, 1985

Linux start October 5, 1991

7 0
3 years ago
Read 2 more answers
any one that owns a chrome book there is a new update there is new features and there is a game on settings where you see what y
timama [110]

Answer:

THANK YOU SO MUCH! I AM ON MY CHROME BOOK RIGHT NOW AND WAS HESITATING TO DOWNLOAD THE UPDATE!

Explanation:

4 0
2 years ago
Read 2 more answers
What are the data types in access​
Julli [10]

Answer:

Data type in Microsoft Access Database

Text  

Memo  

Byte  

Integer

Long  

Single  

Double  

Currency  

AutoNumber  

Date/Time  

Yes/No  

Ole Object  

Hyperlink  

Lookup Wizard

Explanation:

4 0
3 years ago
Other questions:
  • The number of bits used to store color information about each pixel is called ____.
    13·1 answer
  • Search the internet for news of a motor vehicle collision in your community involving drugs or alcohol. Keeping in mind that you
    8·1 answer
  • Who is the owner of microsoft company​
    12·1 answer
  • On most computers, the default font size in Word is ____. 8 11 14 16
    6·1 answer
  • Go online and research the computer topic
    6·1 answer
  • To communicate with an expansion card, one part of the ____ bus runs between RAM and the processor; the other part runs between
    13·1 answer
  • Is there a relationship between cybercrime and traditional crime?
    6·1 answer
  • Jason Has A Science Video Project, As He Creats His Project, He Saves, Then Comes Back A Minute Later. The File Is Now Unreadabl
    8·2 answers
  • The inFS.open(str) function has a string parameter str that specifies the _____ of the file to open.
    10·1 answer
  • Lasses give programmers the ability to define their own types. <br><br> a. True<br> b. False
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!