Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What are the basic Datatypes supported in C Programming Language?(8 mks) 2. What do you mean by the Scope of the variable? What is the

What are the basic Datatypes supported in C Programming Language?(8 mks)

2. What do you mean by the Scope of the variable? What is the scope of the variables in C? (3mrks)

3. Can a C program be compiled or executed in the absence of a main()? (4 mrks)

4. What is Preprocessor?(2mrks)

Write function named "sum_from_to" that takes two integer arguments, call them "first" and "last", and returns as its value the sum of all the integers between first and last inclusive. Thus, for example, cout << sum_from_to(4,7) << endl; // will print 22 because 4+5+6+7 = 22 cout << sum_from_to(-3,1) << endl; // will print 5 'cause (-3)+(-2)+(-1)+0+1 = 5 cout << sum_from_to(7,4) << endl; // will print 22 because 7+6+5+4 = 22 cout << sum_from_to(9,9) << endl; // will print 9

Write function named "enough" that takes one integer argument, call it "goal" and returns as its value the smallest positive integer n for which 1+2+3+. . . +n is at least equal to goal . Thus, for example, cout << enough(9) << endl; // will print 4 because 1+2+3+4 9 but 1+2+3<9 cout << enough(21) << endl;// will print 6 'cause 1+2+ . . .+6 21 but 1+2+ . . . 5<21 cout << enough(-7) << endl;// will print 1 because 1 7 and 1 is the smallest // positive integer cout << enough(1) << endl; // will print 1 because 1 1 and 1 is the smallest // positive integer

Write function named "g_c_d" that takes two positive integer arguments and returns as its value the greatest common divisor of those two integers. If the function is passed an argument that is not positive (i.e., greater than zero), then the function should return the value 0 as a sentinel value to indicate that an error occurred. Thus, for example, cout << g_c_d(40,50) << endl; // will print 10 cout << g_c_d(256,625) << endl; // will print 1 cout << g_c_d(42,6) << endl; // will print 6

cout << g_c_d(0,32) << endl; // will print 0 (even though 32 is the g.c.d.) cout << g_c_d(10,-6) << endl; // will print 0 (even though 2 is the g.c.d.)

Write function named "digit_name" that takes an integer argument in the range from 1 to 9 , inclusive, and prints the English name for that integer on the computer screen. No newline character should be sent to the screen following the digit name. The function should not return a value. The cursor should remain on the same line as the name that has been printed. If the argument is not in the required range, then the function should print "digit error" without the quotation marks but followed by the newline character. Thus, for example, the statement digit_name(7); should print seven on the screen; the statement digit_name(0); should print digit error on the screen and place the cursor at the beginning of the next line.

Write function named "reduce" that takes two positive integer arguments, call them "num" and "denom", treats them as the numerator and denominator of a fraction, and reduces the fraction. That is to say, each of the two arguments will be modified by dividing it by the greatest common divisor of the two integers. The function should return the value 0 (to indicate failure to reduce) if either of the two arguments is zero or negative, and should return the value 1 otherwise. Thus, for example, if m and n have been declared to be integer variables in a program, then m = 25; n = 15; if (reduce(m,n)) cout << m << '/' << n << endl; else cout << "fraction error" << endl; will produce the following output: 5/3 Note that the values of m and n were modified by the function call. Similarly, m = 63; n = 210; if (reduce(m,n)) cout << m << '/' << n << endl; else cout << "fraction error" << endl;

Consider a relational table R that is in 3NF, but not in BCNF. Which one of the following statements is TRUE ?

An organization requires a range of IP address to assign one to each of its 1500 computers. The organization has approached an Internet Service Provider (ISP) for this task. The ISP uses CIDR and serves the requests from the available IP address space 202.61.0.0/17. The ISP wants to assign an address space to the organization which will minimize the number of routing entries in the ISP's router using route aggregation. Which of the following address spaces are potential candidates from which the ISP can allot any one of the organization ?

I. 202.61.84.0 / 21

II. 202.61.104.0 / 21

III. 202.61.64.0 / 21

IV. 202.61.144.0 / 21q

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Marketing

Authors: Philip Cateora

16th Edition

0073529974, 9780073529974

More Books

Students also viewed these Economics questions