I can handle most basic C but i am lost when it comes to these. 1. Write a C pro
ID: 3636712 • Letter: I
Question
I can handle most basic C but i am lost when it comes to these.1. Write a C program that prompts the user for the radius of a circle, then calls inline function circleArea to calculate the area of that circle.
Make sure to:
Format and add comments appropriately
Submit an error free .cpp source file
Create and submit a flowchart that matches your program file
2. Write a complete C program with the two alternate functions specified below, each of which simply triples the variable count defined in main. Then compare and contrast the two approaches. These two functions are
A) Function tripleByValue that passes a copy of count by value, triples the copy and returns the new value and
A) Function tripleByReference that passes count by reference via a reference parameter and triples the original value of count through its alias ( i.e., the reference parameter).
Explanation / Answer
please rate - thanks
if you use Visual C++ remove
#include <conio.h>
and getch();
before running
in the future, 1 question per post
#include <stdio.h>
#include <conio.h>
int tripleByValue(int);
void tripleByReference(int*);
int main()
{int count;
printf("Enter an integer: ");
scanf("%d",&count);
count=tripleByValue(count);
printf("Using tripleByValue value is %d ",count);
tripleByReference(&count);
printf("the new value tripled using tripleByReference is %d ",count);
getch();
return 0;
}
int tripleByValue(int n)
{return n*3;
}
void tripleByReference(int* n)
{*n=*n*3;
}
------------------------
#include <stdio.h>
#include <conio.h>
inline double circleArea(double r){return 3.14*(r*r);}
int main()
{double radius;
printf("Enter a radius: ");
scanf("%lf",&radius);
printf("The circle area is: %lf ",circleArea(radius));
getch();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.