0% found this document useful (0 votes)
35 views2 pages

C++ Basic Calculator and Symbol Printer

The document contains two C++ programs. The first program performs basic arithmetic operations based on user input, but contains an error in the division case where it incorrectly uses assignment instead of comparison. The second program prints a specified symbol a given number of times based on user input.

Uploaded by

marinadi2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

C++ Basic Calculator and Symbol Printer

The document contains two C++ programs. The first program performs basic arithmetic operations based on user input, but contains an error in the division case where it incorrectly uses assignment instead of comparison. The second program prints a specified symbol a given number of times based on user input.

Uploaded by

marinadi2009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

/*dz 1 ya ne znala chto mojno ispolzovat krome char*/

#include <iostream>
using namespace std;

int main() {
int num1;
int num2;
char operation;

cout<<"Enter first number:";


cin>>num1;
cout<<"Enter second number:";
cin>>num2;
cout<<"Enter (+, -, *, /) ";
cin>>operation;

switch(operation) {
case '+':
cout<<"Result:"<<num1 + num2<<endl;
break;
case '-':
cout<< "Result:"<<num1 - num2<<endl;
break;
case '*':
cout<<"Result:"<<num1 * num2<<endl;
break;
case '/':
if (num2 = 0)
cout<<"Result:"<<num1 / num2<<endl;
else
cout<<"Error"<<endl;
break;
}

return 0;
}

/*dz 2*/

#include <iostream>
using namespace std;

int main()
{
int length;
char symb;

cout<<"Enter length: ";


cin>>length;
cout<<"Enter symbol: ";
cin>>symb;

for(int i = 0; i < length; ++i)


{
cout<<symb<<endl;
}
return 0;
}

You might also like