Write C statements for the following Assume that x is declared as int Declare a
ID: 3682543 • Letter: W
Question
Write C statements for the following Assume that x is declared as int Declare a pointer to an int, call It p Set p to point to x Set the value of x to 7 using p Print the value of x using p print the memory address of x using x Print the memory address of x using p Consider the following program with only the variable declarations shown for each statement, specify if it is true or false. Function alpha can access the external variable x In the inner block of the main function, the block variable y hides the local main variable y The declaration of variable k at the given location generates a compilation error Function beta is the only function that can access global variable x Write a recursive function count Down that prints numbers 1 to n in descending order Consider the following function Complete the function so it sets the sum of a, b, c in the variable pointed to by sum and their minimum in the variable pointed to by min :Explanation / Answer
1.
a. int *p;
b.p=&x;
c.*p=7;
d.printf("the value of x=%d",*p);
e.printf("the address of x=%d",&x);
f.printf("the address of x=%d",p);
2.
a.false
b.true
c.false
d.true
3.Recursive function
void countdown(int n)
{
if(n==0)
return;
else
{
printf(" %d",n);
countdown(n-1);
}
4. Sum and min function
int findSpecial(int a,int b,int c,int *sum,int *min)
{
int sumAll=a+b+c;
int minAll;
if(a<=b&&a<=c)
minAll=a;
else if(b<=c&&b<=a)
minAll=b;
else
minAll=c;
*sum=sumAll;
*min=minAll;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.