Finding a number multiplication of 8 with out using
arithmetic operator

Answers were Sorted based on User's Feedback



Finding a number multiplication of 8 with out using arithmetic operator..

Answer / wl

i << 3

Is This Answer Correct ?    9 Yes 2 No

Finding a number multiplication of 8 with out using arithmetic operator..

Answer / splurgeop

/* PROGRAM TO FIND WHETHER A NUMBER IS A MULTIPLE OF 2
AND 8 WITHOUT
USING ARITHMETIC OPERATOR */

#include<stdio.h>
#include<conio.h>
void main()
{
int num;
clrscr();
printf("\n enter a number");
scanf("%d",&num);
if(num & 1)
printf("\n not a multiple of 2");
else
printf("\n a multiple of 2");
if(num & 7)
printf("\n not a multiple of 8");
else
printf("\n a multiple of 8");

getch();
}

Is This Answer Correct ?    6 Yes 1 No

Finding a number multiplication of 8 with out using arithmetic operator..

Answer / raghuram.a

i=n<<3;

Is This Answer Correct ?    2 Yes 0 No

Finding a number multiplication of 8 with out using arithmetic operator..

Answer / lloyd.tumulak

boolean div8(x){
return (x & 7)
}

if return is 0 = divisible by 8

Is This Answer Correct ?    3 Yes 1 No

Finding a number multiplication of 8 with out using arithmetic operator..

Answer / ram

int i,n=1;
i=n<<3

Is This Answer Correct ?    3 Yes 1 No

Finding a number multiplication of 8 with out using arithmetic operator..

Answer / saravanan e

#include <stdio.h>
main()
{
int x,n;
printf("Enter the X number:");
scanf("%d",&x);
n=(x<<3)-x;
printf("The Answer is : %d",n);
getch();
}

Is This Answer Correct ?    2 Yes 2 No

Finding a number multiplication of 8 with out using arithmetic operator..

Answer / saravanan e , ps technologies,

#include <stdio.h>
main()
{
int x,n;
printf("Enter the X number:");
scanf("%d",&x);
n=(x<<3)-x;
printf("The Answer is : %d",n);
getch();
}

Is This Answer Correct ?    1 Yes 3 No

Finding a number multiplication of 8 with out using arithmetic operator..

Answer / aditya raj

#include<stdio.h>
main()
{
int n;
scanf("%d",&n);
if((n&7)==0) printf("yes\n");
else printf("no\n");
}

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More C Code Interview Questions

Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like.

21 Answers   ABC, eBay, Goldman Sachs, Google, HUP, Microsoft, TATA,


write a c program to Reverse a given string using string function and also without string function

1 Answers  


main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  


What are the files which are automatically opened when a C file is executed?

1 Answers  


How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!

1 Answers  






void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }

1 Answers  


main() { int i; clrscr(); for(i=0;i<5;i++) { printf("%d\n", 1L << i); } } a. 5, 4, 3, 2, 1 b. 0, 1, 2, 3, 4 c. 0, 1, 2, 4, 8 d. 1, 2, 4, 8, 16

4 Answers   HCL,


what will be the output of this program? void main() { int a[]={5,10,15}; int i=0,num; num=a[++i] + ++i +(++i); printf("%d",num); }

3 Answers   Wipro,


enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }

2 Answers  


# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }

1 Answers  


print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!

11 Answers   Wipro,


main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”

5 Answers   HCL,


Categories