Question

C programming 3. Write a do-while loop that displays: 0,10,20,30,40 4.Write nested for loops that displays...

C programming

3. Write a do-while loop that displays: 0,10,20,30,40

4.Write nested for loops that displays three rows of asterisks:

*****

*****

*****

5. Write a complete program that reads a set of integers using scant() until a sentinel value of -99 is read. Once that value is read, display the sum of the value read, exclusive of the -99.

6.Write a procedure(function, method named times10() that accepts an integer argument and displays the result of multiplying the argument by 10.

7.Write a function prototype for a min3() function that accepts three integer parameters and returns an integer value.

8.Write the function implementation for the min3() function. Return the minimum value of the three.

Homework Answers

Answer #1

3.

#include <stdio.h>

int main(void) {
  
   int x = 0;
   do
   {
   printf("%d",x);
   if(x < 40)
   printf(",");
   x = x+ 10;
   }while(x<= 40);
  
   return 0;
}

Output:

0,10,20,30,40

4.

#include <stdio.h>

int main(void) {
  
   int i,j;
   for(i=1;i<=3;i++)
   {
       for(j=1;j<=5;j++)
       {
           printf("*");
       }
       printf("\n");
   }
  
   return 0;
}

Output:

*****
*****
*****

5.

#include <stdio.h>

int main(void) {
  
   int x, sum;
   sum = 0;
  
   do
   {
      
   scanf("%d",&x);
   if(x == -99)
   break;
   sum = sum + x;
   }while(x != -99);
  
   printf("\nSum = %d",sum);
   return 0;
}

Output:

8 -5 7 6 -99

Sum = 16

6.

#include <stdio.h>

int times10(int x)
{
   return 10*x;
}
int main(void) {
  
   printf("%d",times10(4));
  
   return 0;
}

Output

40

7.

int min3(int x,int y,int z);

8.

#include <stdio.h>

int min3(int x,int y,int z)
{
   if(x < y)
   {
       if(x < z)
       return x;
       else
       return z;
      
   }
   else
   {
       if(y < z)
       return y;
       else
       return z;
   }
}
int main(void) {
  
   printf("%d",min3(54,66,12));
  
   return 0;
}

Output:

12

Do ask if any doubt. Please upvote.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a complete program in C that reads a set of integers using scanf() until a...
Write a complete program in C that reads a set of integers using scanf() until a sentinel value of -99 is read. Once that value is read, display the sum of the values, exclusive of the -99.
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c....
Create a new file named quiz_loops.py. b. Write your name and date in a comment. c. Write a for loop which will display this set of values 2,4,6,8,10,12,14,16. d. Write a while which will display this set of values 16,13,10,7,4,1,-2. e. Write a for loop which will print ‘Loops are fun’ three times. f. Write a while loop that will prompt you for four numbers. Convert the number to an integer. Compute the power as power = power ** number....
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an...
Arrays, loops, functions: Lotto Element Repeated Function Write a function that that takes as parameters an array of ints, an int value named element, and an int value named end. Return a bool based on whether the element appears in the array starting from index 0 and up to but not including the end index. Generate Random Array Write a function that takes as parameters an array of integers and another integer for the size of the array. Create a...
In C++ write a program for a multiplication table It must Prompt the user for two...
In C++ write a program for a multiplication table It must Prompt the user for two integers between 1 and 20 (inclusive) • also must Calculates and displays the multiplication table in a well-formatted output The table must include a label for each row and column The program must follow the requirements: • Validates user input, displaying an error message and prompting to user to enter another integer if the input is invalid, and repeating it as many times as...
Write a function that accepts an int array and the array’s size as arguments. The function...
Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads an integer N...
Please write it in c# program please and if possible no arrays only loops Loop Introduction...
Please write it in c# program please and if possible no arrays only loops Loop Introduction Assignment Using the conditions below, write one program that calculates a person’s BMI. Your main() function will call functions 1, 2, and 3. Your program will contain three functions: Function #1: Will ask the user for their weight in pounds and their height in inches.   Your function will convert the weight and height into Body Mass Index (BMI). The formula for converting weight into...
USING PYTHON do all the he problems using while loop , continue and break 1-This problem...
USING PYTHON do all the he problems using while loop , continue and break 1-This problem provides practice using a while True loop.write a function named twoWords that gets and returns two words from a user. The first word is of a specified length, and the second word begins with a specified letter.The function twoWords takes two parameters: an integer, length, that is the length of the first word and a character, firstLetter, that is the first letter of the...
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
Write a function that accepts an int array and the array’s size as arguments. The function...
Write a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should return a pointer to the new array. Demonstrate the function by using it in a main program that reads an integer N (that is not more than 50) from standard input and then reads N integers from a file named data into an...
Nested Loops Problem 3 Write a function called makesentence() that has three parameters: nouns, verbs, and...
Nested Loops Problem 3 Write a function called makesentence() that has three parameters: nouns, verbs, and gerunds. Each parameter is a list of strings, where nouns list has noun strings (such as 'homework'), verbs list has veb strings (such as 'enjoy'), and gerunds list has gerund strings (those -ing words, such as 'studying'). The function will go through all these lists in a systematic fashion to create a list of all possible sentences that use all the noun, verb, and...