Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that reads in an integer and displays a diamond pattern as descr

ID: 3570774 • Letter: W

Question

Write a program that reads in an integer and displays a diamond pattern as described below. The integer determines the the number of plus characters in the widest (center) part of the diamond. The program should use nested loops. You can assume the number read in is odd.

#include
using namespace std;
int main(){
int a;
cin >> a;

a = a/2; a++;
for (int b = 1; b <= a; b++){
for (int c = 0; c cout << " ";
for (int c = 0; c<2 * b - 1; c++)
cout << "+";
cout << endl;}
for (int b = a - 1; b>0; b--){
for (int c = 0; c cout << " ";
for (int c = 0; c<2 * b - 1; c++)
cout << "+";
cout << endl;}
return 0;}

This is my code, and it works in visual studio, however, My Programming Lab returns an error saying:

Explanation / Answer

instead of writing "#include <iostream>" u should write "#include<iostream.h>"

and don't use "using namespace std;" use "#include<stdio.h>"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote