im not getting what im doing wrong, coding for c++   Write a program whose inputs are three integers, and whose output is the smallest of the three values. Ex: If the input is: 7 15 3 the output is: 3 #include using namespace std; int main() {        int a = 3, b = 15, c = 7;        cout << a << b << c;    cin >> 3 >> 15 >> 7;   //a = 3, b = 15, c = 7        if (a <  b && a < c)       cout << " a " << 3;             }        else if (b > a && b < c)       cout << " b " << 7;             }        else (c < a && c < b)       cout << " c " << 15;           }                  return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

im not getting what im doing wrong, coding for c++

 

Write a program whose inputs are three integers, and whose output is the smallest of the three values.

Ex: If the input is:

7 15 3

the output is:

3

#include <iostream>
using namespace std;

int main() {
   
   int a = 3, b = 15, c = 7;
   
   cout << a << b << c;
   cin >> 3 >> 15 >> 7;   //a = 3, b = 15, c = 7
   
   if (a <  b && a < c)
      cout << " a " << 3; 
       
   }
   
   else if (b > a && b < c)
      cout << " b " << 7;
        
   }
   
   else (c < a && c < b)
      cout << " c " << 15;
      
   }
   
   
     
   return 0;
}

 

 

Expert Solution
Step 1: Errors in the given Code

There are several issues with your code. I'll correct them step by step:

  1. You should remove the initial assignments to a, b, and c because you want to take user inputs for these values.
  2. You should use appropriate variables in your if conditions.
  3. You need to use && for the conditions properly.
  4. You should remove unnecessary numbers from the cin statement.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

this is the error im getting now 

 

main.cpp:16:4: error: expected unqualified-id before ‘else’
   16 |    else if (b <= a && b <= c)
      |    ^~~~
main.cpp:19:4: error: expected declaration before ‘}’ token
   19 |    }
      |    ^
main.cpp:21:4: error: expected unqualified-id before ‘else’
   21 |    else {
      |    ^~~~
main.cpp:27:4: error: expected unqualified-id before ‘return’
   27 |    return 0;
      |    ^~~~~~
main.cpp:28:1: error: expected declaration before ‘}’ token
   28 | }
      | ^

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Guessing the output
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education