Point out the error line in the following program.1 using namespace std;2 int add(int a, int b)3 {4 int c = a + b;5 cout<<"Sum of a and b is "<<c<<"\n";6 }7 int main()8 {9 int sum;10 sum = add(5);11 return 0;12 }
Question
Point out the error line in the following program.1 using namespace std;2 int add(int a, int b)3 {4 int c = a + b;5 cout<<"Sum of a and b is "<<c<<"\n";6 }7 int main()8 {9 int sum;10 sum = add(5);11 return 0;12 }
Solution
The error is in line 10. The function "add" requires two parameters, but only one is provided. It should be something like "sum = add(5, 3);" or any other two numbers.
Similar Questions
#include <iostream>using namespace std;int main() { int a = 10, b = 5, c = 5; int d; d = b + c == a; cout << d;}Options: Pick one correct answer from belowSyntax error1510
This code produces an error message. Where will the error occur, and why?1 bool a = 1;2 int b = 2 + 4;3 float c = 4;4 cout<<a + b<<endl;
#include <iostream>using namespace std;int main(){ int a , b , c; cin >> a >> b >> c; if(a + b <= a + c && a + b <= b + c) cout << a + b << endl; else if(b + c <= a + b && b + c <= c + a) cout << b + c << endl; else if(a + c <= a + b && a + c <= c + b) cout << a + c << endl; return 0;}
What will be the output of the following program?#include <iostream>using namespace std;int main() { int x, y; x = 5; x++ * ++x; cout <<x << " " <<y; return 0; }Select one:307 06 0Compilation error36
What will the output of the following code snippet?void solve() { int a[] = {1, 2, 3, 4, 5}; int sum = 0; for(int i = 0; i < 5; i++) { if(i % 2 == 0) { sum += *(a + i); } else { sum -= *(a + i); } } cout << sum << endl;}215Syntax Error3
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.