Answer:
// here is code in c++.
// include headers
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
long long int minutes,years,days;
long long int s;
cout<<"please enter the minutes:";
// read the minutes
cin>>minutes;
// make a copy
s=minutes;
// calculate days
days=minutes/1440;
// calculate years
years=days/365;
// calculate remaining days after years
days=days%365;
// print the result
cout<<s<<" minutes is equal to "<<years<<" years "<<days<<" days."<<endl;
return 0;
}
Explanation:
Read the number of minutes from user and assign it to variable "minutes" of long long int type.Make a copy of input minutes.Then calculate total days by dividing the input minutes with 1440, because there is 1440 minutes in a day.Then find the year by dividing days with 365.Then find the remaining days and print the output.
Output:
please enter the minutes:1000000000
1000000000 minutes is equal to 1902 years 214 days.
In the C programming language, you can't determine the array size from the parameter, so you have to pass it in as an extra parameter. The solution could be:
#include <stdio.h>
void swaparrayends(int arr[], int nrElements)
{
int temp = arr[0];
arr[0] = arr[nrElements - 1];
arr[nrElements - 1] = temp;
}
void main()
{
int i;
int myArray[] = { 1,2,3,4,5 };
int nrElements = sizeof(myArray) / sizeof(myArray[0]);
swaparrayends(myArray, nrElements);
for (i = 0; i < nrElements; i++)
{
printf("%d ", myArray[i]);
}
getchar();
}
In higher languages like C# it becomes much simpler:
static void Main(string[] args)
{
int[] myArray = {1, 2, 3, 4, 5};
swaparrayends(myArray);
foreach (var el in myArray)
{
Console.Write(el + " ");
}
Console.ReadLine();
}
static void swaparrayends(int[] arr)
{
int temp = arr[0];
arr[0] = arr.Last();
arr[arr.Length - 1] = temp;
}
I usually include my teachers name in the upper right hand corner along with the date my name and the subject.
A. by combining similar instructions into groups, which will then execute in parallel