Question

In: Computer Science

C PROGRAMMING 1. Write a C Language inline function that computes the cube of float X,...

C PROGRAMMING

1. Write a C Language inline function that computes the cube of float X, if X is greater than 1 and X is less than 100. Put the inline function in a main program that reads X from the keyboard, calls the function, and then outputs the result.

2. Show an empty statement and detail what it does?

3. A collection of predefined functions is called a

  1. Database                    C) Subroutine                       E) None of these
  2. Library                       D) Directive

4. T___ F___ A function should be created if the code will be used often in the program or in future programming.

Solutions

Expert Solution

#include <stdio.h>
inline float cube(float x){
    return x*x*x;
}

int main() {
    float a;
    float result;
    printf("Enter the value..\n");
    scanf("%f",&a);
    printf("Entered value is: %f\n",a);
    if(a>1 && a<100){
        result = cube(a);
        printf("Cube result: %f\n",result);
    }
    else{
        printf("The entered value should be greater than 1 and less than 100! Try again!");
    }
    
    return 0;
}

#include <stdio.h>


int main() {
char text[25] = "Miracle can happen";
int i;

for(i = 0; text[i] != 'q'; i++)
    ;//empty statement
    //If we have 'q' in our string it will not go inside the loop
    
    return 0;
}

//When we want to find the index of first occurrence of a given character in a string in our case its q.

#include <stdio.h>


int main() {

for(;;;) //empty loop it will run  forever.
    
}

3. A collection of predefined functions is called a Library.

As the C in-built functions are collected and placed together in a library every library does a specific task.

for example stdio.h takes case of input output tasks.

database is not the answer as no predifined database s their in C.

Subroutine is kind-of a function which user creates with specific instructions associated with a name.

Directives are the initial lines of program begain with # it is to include some library etc.

4. A function should be created if the code will be used often in the program or in future programming - TRUE

because when we need some lines of code to run often then without writing the same code again and again we write it separately as a function and we call that function whenever we want to run those specific codes.


Related Solutions

Programming language: C++   suggested software: Code::Blocks Develop an algorithm and write a C++ program that computes...
Programming language: C++   suggested software: Code::Blocks Develop an algorithm and write a C++ program that computes the final score of a baseball game. Use a loop to read the number of runs scored by both teams during each of nine innings. Display the final score afterward. Submit your design, code, and execution result via file, if possible
Programming in C language (not C++) Write a runction derinition for a function called SmallNumbers that...
Programming in C language (not C++) Write a runction derinition for a function called SmallNumbers that will use a while loop. The function will prompt the user to enter integers ine by one, until the user enters a negative value to stop. The function will display any integer that is less than 25. Declare and initialize any variables needed. The function takes no arguments and has a void return type.
C Language - Programming Write a function that takes an array of ints, and the size...
C Language - Programming Write a function that takes an array of ints, and the size of the array – another int. It also returns a double. Call this one ‘average.’ Return a double that is the average of the values in the array. Demonstrate that it works by finding the average of an array with these values {78, 90, 56, 99, 88, 68, 92} Write a function that takes one double parameter, and returns a char. The parameter represents...
In C language: Write a function which can receive a float array, an integer number(number of...
In C language: Write a function which can receive a float array, an integer number(number of elements) as input arguments and print all the elements in the array with 2 decimal precision.
Using C Language Write a program segment that computes 1 + 2 + 3 + ......
Using C Language Write a program segment that computes 1 + 2 + 3 + ... + ( n - 1) + n , where n is a data value. Follow the loop body with an if statement that compares this value to (n * (n + 1)) / 2 and displays a message that indicates whether the values are the same or different. Please give me code to just copy and paste
Programming in C language (not C++) Write a function definition called PhoneType that takes one character...
Programming in C language (not C++) Write a function definition called PhoneType that takes one character argument/ parameter called "phone" and returns a double. When the variable argument phone contains the caracter a or A, print the word Apple and return 1099.99. When phone contains the caracter s or S print the word Samsung and return 999.99. When phone contains anything else, return 0.0.
In C language: Write the fnFindMin function which can receive a float array, an integer number(number...
In C language: Write the fnFindMin function which can receive a float array, an integer number(number of elements) as input arguments and finds the minimum value in the array. This function should return the array index (subscript) of the minimum value.
in C programming language Write a function removeDups that removes all duplicates in a given array...
in C programming language Write a function removeDups that removes all duplicates in a given array of type int. Sample Test Case: input -> {1,2,2,2,3,3,4,2,4,5,6,6} output -> {1,2,3,4,5,6,0,0,0,0,0,0} More specifically, the algorithm should only keep the first occurance of each element in the array, in the order they appear. In order to keep the array at the same length, we will replace the removed elements with zeros, and move them to the end of the array.
C++ Write a recursive function that computes and returns the product of the first n >=1...
C++ Write a recursive function that computes and returns the product of the first n >=1 real numbers in an array.
GPA calculator in C language To understand the value of records in a programming language, write...
GPA calculator in C language To understand the value of records in a programming language, write a small program in a C-based language that uses an array of structs that store student information, including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,” etc.). Note:Code and Output Screenshots
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT