Answer:
Option 2 i.e., instance methods is the correct answer to the following question.
Explanation:
Because the instance method or function is the function that needed the class object to be called.
<u>For Example:</u>
//header file
#include <iostream>
using namespace std;
//define class
class Test
{
public:
//instance method
void getins()
{
cout<<"I AM Instance method";
}
};
int main()
{
//creating object
Test obj;
//calling of instance method through class object
obj.getins();
}
<u>Output</u>:
I AM Instance method
Answer:
#program in python.
#variables
slice_area=14.125
pi=3.14159
#read diameter
d=int(input("Enter diameter of pizza:"))
#area of pizza
area=pi*(d/2)*(d/2)
#number of slice
no_slice=int(area/slice_area)
#print slice
print("total silce are:",no_slice)
Explanation:
Declare and initialize a variable "slice_area" with 14.125 which is the area of a pizza slice.Initialize a variable "pi" with 3.14159.Then read the diameter of pizza.Find the area of pizza as "area=pi *d/2*d/2".Divide the total area with area of pizza slice.This will be the number of slice.
Output:
Enter diameter of pizza:20
total silce are: 22
Answer:
Delegate is a function pointer which points the address of a function.
Explanation:
Let the function to compare two integers takes two integers as arguments
C#.net syntax:
delegate void Del(int,int);
Here delegate is the keyword. Del is the name of the delegate which stores the address of the function whose return type is void and which takes 2 integer arguments.
public void CompareIntegers(int x, int y)
{
if (x>y) Console.WriteLine("X is greater");
else Console.WriteLine("Y is greater");
}
delegate void Del(int,int);
void main(){
Del del1=new Del(CompareIntegers);
}
Answer:
num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
choice = input("Do you want to multiply them?: ")
if choice.capitalize() == "Yes":
print(num1 * num2)
else:
print("Peace out.")
Explanation:
Gg ez.
(I wrote the it in python because I don't know what language you want it in. Next time, say what language you want.)