Answer:
To check if the year comes under each 100th year, lets check if the remainder when dividing with 100 is 0 or not.
Similarly check for 400th year and multiple 0f 4. The following C program describes the function.
#include<stdio.h>
#include<stdbool.h>
bool is_leap_year(int year);
void main()
{
int y;
bool b;
printf("Enter the year in yyyy format: e.g. 1999 \n");
scanf("%d", &y); // taking the input year in yyyy format.
b= is_leap_year(y); //calling the function and returning the output to b
if(b==true)
{
printf("Thae given year is a leap year \n");
}
else
{
printf("The given year is not a leap year \n");
}
}
bool is_leap_year(int year)
{
if(year%100==0) //every 100th year
{
if(year%400==0) //every 400th year
{
return true;
}
else
{
return false;
}
}
if(year%4==0) //is a multiple of 4
{
return true;
}
else
{
return false;
}
}
Explanation:
Output is given as image
Answer:
Written using C++
/*Enter Your Details Here*/
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
//1
float side;
cout<<"Enter the side of a square: ";
//2
cin>>side;
//3
float perimeter = 4 * side;
cout<<"The perimeter is "<<perimeter<<endl;
//4
float area = side *side;
cout<<"The area is "<<area<<endl;
//5
float diagonal = sqrt(2 * side * side);
cout<<"The length of the diagonal is "<<diagonal;
return 0;
}
Explanation:
<em>I've added the full source code as an attachment where I used more comments to </em><em>explain </em><em>difficult line</em>
This question belongs to scratch programming. This programming language has various instructions to carry out various tasks. There are different types of repeat statement available. This statement or instruction allows the user / programmer to repeat certain line of statements to a number of times. Here, according to the question, we need to use “Repeat after me”
If you take a music note, the tempo, timing and pitch needs to be mentioned clearly and “:” represents that a particular note to be repeated only once.
Answer:
The three options are:
1. Avoid sharing files and folders over the network without the permission of your administrators. You might fall in trouble otherwise.
2. Never share your credit card details with a third party through the internet. You can lose a lot of or all your money.
3. Always ensure that your password is strong enough or else your account can be hacked, And never share them with anybody.
Explanation:
Please check the answer.
Answer:
The method in python is as follows:
class myClass:
def printRange(min,max):
for i in range(min, max+1):
print("{"+str(i)+"} ", end = '')
Explanation:
This line declares the class
class myClass:
This line defines the method
def printRange(min,max):
This line iterates from min to max
for i in range(min, max+1):
This line prints the output in its required format
print("{"+str(i)+"} ", end = '')