Question

In: Computer Science

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.

Solutions

Expert Solution

#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

void SmallNumbers()
{
    int f=0;
    while(f==0)
    {
        // take input of number from user
        int n;
        printf("Enter a value: ");
        scanf("%d",&n);


        // if number is greater than 0 and smaller than 25 then print it
        if(n>=0 && n<25)
            printf("The entered number is %d \n\n",n);


        // if number is smaller than 0 then end the program
        else if(n<0)
        {
            printf("Program ends\n");
            f=1;
        }

    }

    return;

}

int main()
{

    SmallNumbers();

    return 0;
}

PLEASE LIKE THE SOLUTION :))

IF YOU HAVE ANY DOUBTS PLEASE MENTION IN THE COMMENT


Related Solutions

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.
Programming in C (not C++) Write the function definition for a function called CompareNum that takes...
Programming in C (not C++) Write the function definition for a function called CompareNum that takes one doyble argument called "num". The function will declare, ask, and get another double from the user. Compare the double entered by the user to "num" and return a 0 if they are the same, a -1 num is less than the double entered by the user and 1 if it is greater.
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 programming language, write and test a function that writes and returns through an output...
in C programming language, write and test a function that writes and returns through an output parameter the longest common suffix of two words. (e.g. The longest common suffix of "destination" and "procrastination" is "stination", of "globally" and "internally" is "ally, and of "glove" and "dove" is the empty string)
LISP Programming Language Write a Bubble Sort program in the LISP Programming Language called “sort” that...
LISP Programming Language Write a Bubble Sort program in the LISP Programming Language called “sort” that sorts the array below in ascending order.  LISP is a recursive language so the program will use recursion to sort. Since there will be no loops, you will not need the variables i, j, and temp, but still use the variable name array for the array to be sorted.             Array to be sorted is 34, 56, 4, 10, 77, 51, 93, 30, 5, 52 The...
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 Database                    C) Subroutine                       E) None of these Library                       D) Directive 4....
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.
Use R programming Language Q1. (a)Write a function called lowerTrim that takes 2 arguments: x and...
Use R programming Language Q1. (a)Write a function called lowerTrim that takes 2 arguments: x and trimBelow. This function takes the average of those values in x that are greater than the trimBelow. Make x a required argument and supply a default value for trimBelow of negative infinity. First create some variable to be used for testing later. x = 1:5 y = letters z = list(a = 1:5, b = 1:10) Now test your function with the following lowerTrim(x)...
C programming Write a function called string in() that takes two string pointers as arguments. If...
C programming Write a function called string in() that takes two string pointers as arguments. If the second string is contained in the first string, have the function return the address at which the contained string begins. For instance, string in(“hats”, “at”) would return the address of the a in hats. Otherwise, have the function return the null pointer. Test the function in a complete program that uses a loop to provide input values for feeding to the function.
(C LANGUAGE) Write a function called upperLower that inputs a line of text into char array...
(C LANGUAGE) Write a function called upperLower that inputs a line of text into char array s[100]. Output the line in uppercase letters and in lowercase letters This is what I have so far: void * upperLower (const char * s) { char *word[sizeof(s)]; for(int i = 0; i < sizeof(s); i++){ *word[i] = s[i]; } word = strtok(word, " "); int counter = 0; while(word != NULL){ if(counter % 2 == 0){ word[counter] = toupper(word); printf("%s ", word); }...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT