#include
#define N 100 /* change the upper limit by changing value of N */
int main()
{
int i;
clrscr();
printf("\nPROGRAM TO PRINT NUMBERS DIVISIBLE BY 8 between 1 and 100\n");
for(i=1;i<=N;i++)
{
if(i%8==0)
{
printf("%d\n",i);
}
}
getch();
return 0;
}
If you visualize 1123581321 as a set of numbers (without spaces in between) instead of one number, you'll see that it's a set of the first 8 Fibnocci nos. - 1 1 2 3 5 8 13 21. The following program would print the required no. using a For looping structure. int main (void) { int i=1; int j=1; int k, num=1; for(k=0; k<7; k++){ if(k==0){ printf("%d", num); } printf("%d", num); //next no. is the sum of previous two nos. in the series i=j; j=num; num=i+j; // 1 + 1 = 2 ... 1 + 2 = 3 ... 2 + 3 = 5 ... 3 + 5 = 8 // sum=i + j ... i takes value of j ... j takes value of sum ... repeat. } }
QBASIC operators are listed as follows.../along with some example QBASIC code... ->LOGICAL OPERATORS AND OR NOT EXAMPLE QBASIC CODE:- A=1 B=1 IF (A AND B) THEN PRINT "Result: True" ELSE PRINT "Result: False" ...output... Result: True A=1 B=2 IF (A AND B) THEN PRINT "Result: True" ELSE PRINT "Result: False" ...output... Result: False -> MATHEMATICAL OPERATORS + plus - minus * multiply / divide MOD division remainder ^ raise to the power EXAMPLE QBASIC CODE:- num1=4 num2=2 PRINT num1 + num2 PRINT num1 - num2 PRINT num1 * num2 PRINT num1 / num2 PRINT num1 MOD num2 PRINT num1 ^ num2 ...output... 6 2 8 2 0 16 -> COMPARISON OPERATORS = equals > greater than < lesser than >= greater than/or, equals <= lesser than/or, equals <> not EXAMPLE QBASIC CODE:- num1 = 6 num2 = 8 IF num1 = num2 THEN PRINT "Equal to" IF num1 > num2 THEN PRINT "Greater than" IF num1 < num2 THEN PRINT "Lesser than" IF num1 >= num2 THEN PRINT "Greater than/or, equal to" IF num1 <= num2 THEN PRINT "Lesser than/or, equal to" IF num1 <> num2 THEN PRINT "NOT equal" ...output... Lesser than Lesser than/or, equal to NOT equal
AnswerYou're better off using a program like Visual Basic or C++ to do that. QBasic doesn't have very many capabilities.AnswerQBasic is quite capable. It is certainly capable of solving a magic squares problem.
PROGRAMMING LANGUAGE: QBASIC/VERSION: QB64 ...Program code... intNum% = 2 CLS PRINT "PROGRAM: POWERS OF N/(N ="; intNum%; ")" PRINT FOR intEachLoopNum% = 0 TO 10 PRINT intNum%; " ^ "; intEachLoopNum%; " = "; intNum% ^ intEachLoopNum% NEXT ...Output... 2 ^ 0 = 1 2 ^ 1 = 2 2 ^ 2 = 4 2 ^ 3 = 8 2 ^ 4 = 16 2 ^ 5 = 32 2 ^ 6 = 64 2 ^ 7 = 128 2 ^ 8 = 256 2 ^ 9 = 512 2 ^ 10 = 1024 *NOTE*: In QBASIC the mathematical symbol: ^...means 'raise to the power of'; thus, 2 ^ 3; actually means raise the number 2 to the power of 3/or, 2 x 2 x 2.
1. Input number, n 2. a = 0 3. d = n % 10 4. Print d 5. a = a + d 6. n = n / 10 7. If n > 0 then goto 3 8. Print a
The nos. Are 8 and -8 Sum of the nos. 8+(-8)=0 Product of the nos. 8 × (-8) = -64
If the last 3 digits are divisible by 8, the number is divisible by 8.
no.. for example 6,12,18 are divisible by 2..but not divisible by 8.
152 is divisible by 8, and the answer is 19.
Neither is divisible by 8.
Not always for example, 36 is not divisible by 8 but it is divisible by 2 and 4.
4 is divisible by 1, 2 and 4. So is 8. If a number is divisible by 8, it will also be divisible by 4.
Yes - 24 is divisible by both 6 and 8 - but is NOT divisible by 48
Yes. 8 / 4 = 2 8 is also divisible by 2 and 8.
All numbers that are divisible by 8 and 12 would also be divisible by 4.
If you have a few different numbers that you are using, divide them each by 8 and if you get a whole number, that number is divisible. If you are trying to figure out what is divisible by 8, you can use a divisibility test.A number is divisible by 8 if:the number formed by the last three digits is divisible by 8.So, an example of this would be:7, 120.This number is divisible by 8 because 120 (the last 3 digits) is divisible by 8!
Numbers are divisible by 8 if the number formed by the last three individual digits is evenly divisible by 8. For example, the last three digits of the number 3624 is 624, which is evenly divisible by 8 so 3624 is evenly divisible by 8.