473,473 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Program that outputs numbers divisible by two values

3 New Member
A program that outputs all numbers divisible by both 5 and 6.This is what i have written :
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. int  main ()
  3. int i=200;
  4. int b=10;
  5. while(i<1000)
  6. i b/6%==0
  7. }
where could i have gone wrong.A new to programming
May 2 '12 #1
1 3772
Banfa
9,065 Recognized Expert Moderator Expert
Line 7 is utter garbage. I assume that should be if not i and an if statement requires parentheses. It does seem as if you may have intended to use the % operator but the syntax os the same as any other maths operator "a + b", "a - b", "a / b", "a * b", "a % b".

If you corrected line 7 to if (b % 6 == 0) then it would be testing to see if b is divisible by 6. Of course b is a constant in your program (it's value doesn't change) and so is i for that matter. Following the if statement you need another statement, presumable a printf statement to print the values divisible by 6.
May 2 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: hoover_richard | last post by:
I am a newbie to C++ and I need help with a simple program I am trying to write. My program is designed to print all of the odd integers contained in an array and output the sum of the odd...
13
by: placid | last post by:
Hi all, I was just if anyone knows a way to resolve a list of integers say {1,2,3,4,5} into a range that is 1-5? #include <stdlib.h> #include <stdio.h> #include <ctype.h> int main(int...
4
by: wkatz | last post by:
Hi, Gurus. What hashing algorithm outputs hash value as numbers only? For example, if you pass a “John Q. Public” it will output 23324. If there is no such hashing, how hard is it to hire somebody to...
3
by: shubhamgupta | last post by:
somebody plz help me with a program for inputing two numbers and then checking if they are amicable or not. i've just started learnign c++ and we are being made to use turbo c++ 3.0 we have been...
4
by: damatrix1 | last post by:
28, 32,37,24,33 im not sure how to make the program calculate it
7
by: jeremyhilg08 | last post by:
I have a question with a program. The assignment is "Write a program to verify the statement Numbers whose sum of digits is divisible by 3 represent numbers divisible by 3. Input a 5 digit integer...
4
by: Busgosu | last post by:
i dont know how to upload in a way that you can see it clearly.. so im just going to copy and paste what i have so far... sorry. :S #include <iostream> using namespace std; #include <cmath>...
1
by: Alex T | last post by:
Let's say I have a website about statistics, which had 4 numbers. How would I make my c++ program open the website and read the numbers, then write them to a text file? For a start, I have only...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.