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.
Write the C++ code using nested for loops that prints the product of the outer loop...
Write the C++ code using nested for loops that prints the product of the outer loop counter and the inner loop counter; one per line. The outer loop counter should go from 1 to 8 and the inner loop counter should go from the value of the outer loop counter to 10. Both counters should increment by 1. Use outer for the outer loop counter and inner for the inner loop counter.
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...
1) Write a java programming nested while loop where you will declare two numbers one for...
1) Write a java programming nested while loop where you will declare two numbers one for outer loop and the other one for inner while loop, and display the result. (Try using scanner) Steps: 1) Declare the variable of outer loop int and assign value of your choice 2) Declare while condition which outer variable is less the number of your choice 3) Declare variable of inner loop int and assign the value of your choice 4) Declare while condition...
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...
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...
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....
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...
PLEASE DO IT IN C++ ONLY. THE MIN-MAX DIGIT PROBLEM Write a function named minMaxDigit() that...
PLEASE DO IT IN C++ ONLY. THE MIN-MAX DIGIT PROBLEM Write a function named minMaxDigit() that accepts an integer as an input parameter and returns the largest and smallest digits using the two output parameters min and max. For example, the call minMaxDigit(68437, min, max) would set min to 3 and max to 8. If there is only one digit, then both min and max are set to the same value. The function has no return statement.
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT