A function that determines if a given year is a leap year:
#include<stdio.h>
int main()
{
//fill the code
int year, month;
scanf(“%d %d”,&month,&year);
if(!Leapyear(month, year))
{
if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12)
printf(“Number of days is 31”);
else if(month == 2)
{
printf(“Number of days is 28”);
}
else
printf(“Number of days is 30 “);
return 0;
}
}
int Leapyear(int month, int year)
{
if((month == 2) && (year%4 == 0) || ((year%100 == 0) &&(year%400 == 0)))
{
printf(“Number of days is 29”);
return 1;
}
else
return 0;
}
B.cannot be accessed from the GUI
Answer:
The program written in Python is as follows:
file_handler = open("numbers.dat","r")
nums = 0
for line in file_handler:
try:
nums+=int(line)
except ValueError:
continue
file_handler.close()
print("Sum: "+str(nums))
Explanation:
The file handler is used to enable the program reads content of the file numbers.dat
file_handler = open("numbers.dat","r")
This initializes the sum of numbers to 0
nums = 0
This iterates through the line of the file
for line in file_handler:
The try exception is used to prevent program crash if data other than integer is read
try:
This adds numbers on each line
nums+=int(line)
This exception is returned for data other than integers
except ValueError:
continue
This closes the file handler
file_handler.close()
This prints the calculated sum
print("Sum: "+str(nums))
Answer:
1. Verify transactions independently
.
2. Restricting access to programmers to change programs and data files when there is an error.
Explanation:
- Verifying transactions independently by involving another employee re-entering transactions, then programming the software in order to compare the inputs and search out errors, is an essential control method.By doing this, errors are identified, reducing risk of incorrect transactions.
- When programmers have access to changing data and programs, this indicates a lack of internal control. Unrestricted access enables a programmer include or subtract certain elements of programs which could lead to errors in operations and transactions. There should be proper identification of duties and a programmer should be bound by specific functions, reducing the risk of this type of error.
Answer: Printing of documents was initially accomplished using IBM Selectric typewriters modified for ASCII-character input. These were later replaced by application-specific daisy wheel printers, first developed by Diablo, which became a Xerox company, and later by Qume.
Explanation: