100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
COP 3514 Question and answers verified to pass 2024 $13.49   Add to cart

Exam (elaborations)

COP 3514 Question and answers verified to pass 2024

 12 views  0 purchase
  • Course
  • COP
  • Institution
  • COP

COP 3514 Question and answers verified to pass 2024 COP 3514 Which of the function definitions for a function isletter will correctly determine whether a character is an alphabetic letter and returns 1 for true and 0 for false? 1. int isletter(char ch) { if((ch >= 'a' && ch <= 'z')||(...

[Show more]

Preview 3 out of 21  pages

  • September 7, 2024
  • 21
  • 2024/2025
  • Exam (elaborations)
  • Questions & answers
  • cop 3514
  • COP
  • COP
avatar-seller
flyhigher329
COP 3514
Which of the function definitions for a function isletter will correctly determine
whether a character is an alphabetic letter and returns 1 for true and 0 for
false?
1.
int isletter(char ch)
{
if((ch >= 'a' && ch <= 'z')||(ch >= 'A' && ch <= 'Z'))
return 1;
else
return 0;
}


2.
int isletter(char ch)
{
if((ch >= 'a' || ch <= 'z')&&(ch >= 'A' || ch <= 'Z))
return 1;
else
return 0;
} - correct answer ✔1


The following program supposes to sum all entered int values that are greater
than 5. It takes integer input and -1 indicates the end of input. It compiles
without any error message, and it executes without error message, but
nevertheless is wrong. What is wrong with the program?
#include <stdio.h>

,int main()
{
int x, sum = 0;
while (x != -1)
{
scanf("%d", &x);
if (x > 5);
sum = sum +x;
}
printf("The sum of values > 5 is %d\n", sum);
} - correct answer ✔The semicolon at the end of the if statement causes all
entered values to be summed.


Which one of the following would exchange the values of the variables x and y
successfully?
a)
int tmp;
tmp = x;
x=y;
y=x;
b)
int tmp;
tmp = x;
x=y;
y=tmp;
c)
int tmp;

, tmp = y;
x=y;
y=tmp; - correct answer ✔b


Consider the following recursive function.
int compute(int low, int high){
if (low == high) return 0;
else return 1 + compute(low+1, high);
}




What does a call compute(3, 5) return? - correct answer ✔2


Which of the following defines a recursive function for calculating the factorial
of a number?
a)
int fact(int n)
{
if (n==1) return 1;
else return fact(n*(n-1));
}


b)
int fact(int n)
{
if (n==1) return 1;

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller flyhigher329. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $13.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

79271 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$13.49
  • (0)
  Add to cart