Question

Write a while loop that prints to the screen: ONLY the multiples of 3 which are...

Write a while loop that prints to the screen: ONLY the multiples of 3 which are between 4 and 40.

In C code please.

Homework Answers

Answer #1

C code:

#include <stdio.h>
int main()
{
//initializing i as 4
int i=4;
//looping till i is 40
while(i<=40){
//checking if i is a multiple of 3
if(i%3==0)
//printing i
printf("%d\n",i);
//incrementing i
i++;
}   
return 0;
}


Screenshot:


Input and Output:

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 program with while loop that prints all numbers between 5 and 100 (inclusive) that...
Write a program with while loop that prints all numbers between 5 and 100 (inclusive) that are divisible by 5.
Write a Python program using while loop that finds and prints the sum of this geometric...
Write a Python program using while loop that finds and prints the sum of this geometric series. 1 + 2 +4 +8 + … + 1024
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow...
Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum = 40: 20 10 5 2 1 ..... my code: #include <iostream> using namespace std; int main() { int userNum; userNum = 40; /* Your solution goes here */ while (userNum != 1){ userNum = userNum/2; cout << userNum << " ";   } cout << endl; return 0; } ........ but as a result i...
Write a for loop that prints: 1 2 ... userNum Ex: userNum = 4 prints: 1...
Write a for loop that prints: 1 2 ... userNum Ex: userNum = 4 prints: 1 2 3 4 import java.util.Scanner; public class ForLoops { public static void main (String [] args) { int userNum; int i; Scanner input = new Scanner(System.in); userNum = input.nextInt(); for (/* Your code goes here */) { System.out.print(i + " "); } } } Need to fill out the "for" solved in JAVA
Using a while loop, write a program that reads 10 integer numbers. The program shall count...
Using a while loop, write a program that reads 10 integer numbers. The program shall count how many of them are multiples of 2, how many are multiples of 3, and how many are NOT multiples of either 2 or 3. The output should be similar to the one shown below. c++ language
Write a code segment to print your name ten times on the screen using a while...
Write a code segment to print your name ten times on the screen using a while loop. Use one variable called count to act as a counter for the loop. Discuss how would you print your name 1000 times on the screen. NOTE: You can either type your code into the text box or upload a document to the discussion board by clicking the "attach" clip at the bottom left of the discussion box.
I'm trying to write a nested loop in Mips Assembly that prints out, for example, if...
I'm trying to write a nested loop in Mips Assembly that prints out, for example, if user input x was 5: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 (spaces in between) So far my code is : li $v0, 5   #Ask for integer syscall move $t5, $v0 addi $t0, $zero, 0 For1:    slt $t1, $t0, $t5    beq $t1, $zero, Exit    add $s0, $s0, $t0    addi $t0, $t0, 1...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. See "How to Use zyBooks". Also note: If the submitted code has an...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop...
Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider that your user might give you two of the same...
This code is in C++ Write a function named printMultTable that takes 2 integers, numValues and...
This code is in C++ Write a function named printMultTable that takes 2 integers, numValues and factor, and prints the first numValues greater than 0 that are multiples of  factor, separated by SPACE. It has no return value. printMultTable(5, 4) should print the first 5 multiples of 4, separated by a space, which is "4 8 12 16 20" printMultTable(3, 6) should print the first 3 multiples of 6, separated by a space, which is "6 12 18"   
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT