For loop, if you have to fill water in a bucket three times, It will fill water in a bucket three times. While loop, If you have to take water from the well multiple times but stop when the water is empty in the well.
Explanation:
- For loop is used mostly static way of programming.
- While loop is used for dynamic approach of programming.
- Static approach has fix number of times the task is done.
- Dynamic approach is conditional attempt to complete the entire task.
- For loop uses discrete which means it uses the count approach.
- While loop is basis on characteristic, It works mostly with alphabet.
- Functions play major role in while loop to take a dynamic approach.
Is there anything about this question?
Answer:
Check the explanation
Explanation:
#include <bits/stdc++.h>
using namespace std;
class Rectangle{
public:
int length;
int breadth;
Rectangle(int l,int b){
length = l;
breadth = b;
}
int area(){
return length*breadth;
}
int perimeter(){
return 2*(length+breadth);
}
bool equals(Rectangle* r){
// They have the exact same length and width.
if (r->length == length && r->breadth == breadth)
return true;
// They have the same area
if (r->area() == area())
return true;
// They have the same perimeter
if (r->perimeter() == perimeter())
return true;
// They have the same shape-that is, they are similar.
if (r->length/length == r->breadth/breadth)
return true;
return false;
}
};
int main(){
Rectangle *r_1 = new Rectangle(6,3);
Rectangle *r_2 = new Rectangle(3,6);
cout << r_1->equals(r_2) << endl;
return 0;
}
Answer:
True
Explanation:
A single file can be used to record/ store all the information regarding a transaction because in a transaction there are less complexities. a simple transaction involves an exchange/communication between a buyer and a seller which involves exchange in finances between the buyer and the seller.
An employee can be involved in several activities like work activities and multiple transactions while a single inventory part record is different from an employee's record and any other form of transaction. hence separate files have to be created for each of these activities.
To have an easy access to this information when needed a master file is created to store all the individual files.