63 046
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #39812 in C++ for Lisa

Question #39812
Hi i am a 1st year at varsity and I have a assignment on basic programming principles. I am really lost with some of the questions. Can please someone help me. 1st question states: enter an integer value for the variable called num that contains a value between 35 and 74. Determine if the 'tens' digit is equal to,grater than or less than the 'ones' digit. 2nd question
N: do the planing and write algorithms to solve the following: the user wants to display a message a fixed number of times. Ask the user to enter the message and the number of times it must be displayed. Display the message the required number of times. That's all plz help me plz
Expert's answer
//Answer on Question#39812 - Programming - C++
//enter an integer value for the variable called num that contains a value between 35 and 74.
//Determine if the 'tens' digit is equal to,grater than or less than the 'ones' digit.
//the user wants to display a message a fixed number of times.
//Ask the user to enter the message and the number of times it must be displayed. Display the message the required number of times.
#include <iostream>
#include <conio.h>
#include <string>

using namespace std;

int main()
{
//First part
int num;
cout<<"Enter num between 35 and 74 : ";
cin>>num;
while(num<35 || num>74)
{
cout<<"Invalid num!Try again :";
cin>>num;
}
int d1,d2;
d1 = num / 10;
d2 = num % 10;
if (d1 > d2)
cout<<"'tens' are greater than 'ones'! "<<endl;
else if(d1 < d2)
cout<<"'tens' are less than 'ones'! "<<endl;
else
cout<<"'tens' are equal to 'ones'! "<<endl;

//Secod part
string str;
int amount;

cout<<"Enter the string : ";
cin.ignore();
getline(cin, str);
cout<<"Enter amount of times it should be displayed : ";
cin>>amount;
for(int i=0; i<amount; i++)
cout<<str<<endl;

_getch();
return 0;

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions