• +91 9723535972
  • info@interviewmaterial.com

CPlusPlus Interview Questions and Answers

Question - Write a program that ask for user input from 5 to 9 then calculate the average

Answer - #include "iostream.h" int main() { int MAX = 4; int total = 0; int average; int numb; for (int i=0; i> numb; while ( numb<5 || numb>9) { cout << "Invalid input, please re-enter: "; cin >> numb; } total = total + numb; } average = total/MAX; cout << "The average number is: " << average << "\n"; return 0; }

Comment(S)

Show all Coment

Leave a Comment




NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners