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
1
Expert's answer
2014-03-24T11:02:58-0400
//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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS