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

(18) User Defined Function-a-funei on defned e s 2) Write a \'for\' loop to prin

ID: 3591332 • Letter: #

Question

(18) User Defined Function-a-funei on defned e s 2) Write a 'for' loop to print the numbers from 75 to 50, in descending order with each number in a separate line (10 Points). e.g. 75 74 73 50 3) Using the following strings, Answer the following questions(20 Points) Given the string variables str1 and str2 contain "you ought to start with logic" and "ou respectively, what is the result of each of the following expressions? a. stri.length0 b. str1.find(str2) c. str1.substr(4, 25) d. strl.substr(4, 25).find(str2) e. str1.substr.(str1.find("logic"), 3)

Explanation / Answer

Program for 1st question:

#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
   int i=75;
   for(;i>=50;i--)
   {
       cout<<i<<" ";
   }
}

Program for 2nd question:

#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main()
{
   string str1="you ought to start logic";
   string str2="ou";
   cout<<"str1.length()==>"<<str1.length();
   cout<<" ";
   cout<<"str1.find(str2)==>"<<str1.find(str2);cout<<" ";
   cout<<"str1.substr(4,25)==>"<<str1.substr(4,25);cout<<" ";
   cout<<"str1.substr(4,25).find(str2)==>"<<str1.substr(4,25).find(str2);cout<<" ";
   cout<<"str1.substr.(str1.find('logic'),3)==>"<<str1.substr(str1.find("logic"),3);
}

PLease go through both and give ur feedback to us. Thank u.