Purchase Solution

Introduction to C - Conditionals and Basic Functions

Not what you're looking for?

Ask Custom Question

1. Given the variables isFullTimeStudent and age , write an expression that evaluates to true if age is less than 19 or isFullTimeStudent is true.

2.Write an expression that evaluates to true if and only if value of the integer variable isAMember is false.

3. Write a conditional that assigns true ( 1 ) to the variable fever if the variable temperature is greater than 98.6 .

4. Write the definition of a function printGrade , which has a char parameter and returns nothing. The function prints on a line by itself the message string Grade: followed by the char parameter (printed as a character) to standard output. Don't forget to put a new line character at the end of your line.

Thus, if the value of the parameter is 'A', the function prints out Grade: A

5. Write a statement that declares a prototype for a function add , which has two int parameters and returns an int .

6. Write the definition of a function max that has three int parameters and returns the largest.

Purchase this Solution

Solution Summary

Six elementary C programming problems are solved related to conditional expressions and basic function declaration and definition.

Solution Preview

<Ol>
<Li><B>Given the variables isFullTimeStudent and age , write an expression that evaluates to true if age is less than 19 or isFullTimeStudent is true.</B>

Here, there are two conditions, and if either one is true, the expression should have value true. That is, the <I>||</I> (or) operator is to be used:

<I>
age < 19 || isFullTimeStudent == 1
</I>

<Li><B>Write an expression that evaluates to true if and only if value of the integer variable isAMember is false.</B>

Here, if <I>isAMember</I> is false, the expression should be true, and if <I>isAMember</I> is false, the expression should be true. In other words, the expression's value should be the complement/negation of the truth value of <I>isAMember</I>, which means the <I>!</I> (not) operator should be used:

<I>
!isAMember
</I>

Another way of doing the same is:
<I>
isAMember == 0
</I>
(this directly checks whether isAMember is false)

<Li><B>Write a conditional that assigns true ( 1 ) to the ...

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Javscript Basics

Quiz on basics of javascript programming language.