my task is to use a loop,, i need the loop to go till 77777

the problem is that the numbers need to be octagon type.. 1-8 instead of 1-10. i have no idea how to make that conversion. i created 2 loops...

i tried to come up with a code for 2 hours. but no luck

here is my code so far..

``````class Ex6
{
public static void main(String[] args)
{
int count;
count=0;

while(count<77778)
{
int n1;
n1=0;

while(n1<8)

{

n1=n1+1;    }

System.out.println(count+n1);

count=count+1;
}

}

}``````

If you are coding it with TurboC++, a 16-bit compiler, int is by default "short int" (size: 2bytes) So make it at least unsigned long to stay within the limits of INT_MAX.
Edit:

``System.out.println(count+n1);``

I guess it's VC++.

the numbers need to be octagon type

First, it's Octal. I don't get it when you say "I need to make numbers octal". Does your app convert numbers from One base to another? I can't make any sense out of either of your loops.

In C octal numbers start with a zero like

01234;

``while(count<77778)``

Here your 77778 corresponds to decimal 77778 or octal 227722. & there is no valid 077778 so 077777 corresponds to decimal 32767.

NO, you can use basic stuff, like the basic operators.. (including trilienar operator)

, no advanced for or classes allowed.. basic stuff

i need to make it so that it would add a series of 1-8 with another 1-8 until you reach 77777.

those were the instructions, to display octal numbers from 0-77777

no idea how it is done, but it must have a loop and a few basic operators

If you need to display octal numbers then look at the code below:

``````#include <stdio.h>

int main(int argc, char**argv)
{
fprintf(stdout, "ans->%o\n", 9999);
return 0;
}``````

i know how to make an octal presentation.

u can do while (n1<0777777) and it would give an octal presentation

but how do i make those octal numbers , which are decimal 32767. reach 777777

i am a bit confused,

i need a simple code, nothing difficult. i need to reach 77777 octal figure

from 0 to 77777 octal figure.

the question is whether my code is okay?!?
or do i need something to make it clear

i know how to make an octal presentation.

u can do while (n1<0777777) and it would give an octal presentation

but how do i make those octal numbers , which are decimal 32767. reach 777777

i am a bit confused,

i need a simple code, nothing difficult. i need to reach 77777 octal figure

from 0 to 77777 octal figure.

the question is whether my code is okay?!?
or do i need something to make it clear

Number one - the numbers are integers not decimal
Number two - 077777 is 32767...How you want to display it is your business.

Number one - the numbers are integers not decimal

As of this scenario, they are decimals. Integers is a general term for decimals,octals,hexadecimals combined (a la Union).
I think what the OP is trying to achieve is "emulate" octal using decimal. Right?

If you merely want to display the octals from 0-77777. Just run a loop from 0-32767 & printf() using the %o modifier (as already illustrated by gerard4143).

``printf("%o,",num);``

okay thanks.

i will keep it simple

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.