Finding a number multiplication of 8 with out using
arithmetic operator
Answers were Sorted based on User's Feedback
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 |
Answer / lloyd.tumulak
boolean div8(x){
return (x & 7)
}
if return is 0 = divisible by 8
Is This Answer Correct ? | 3 Yes | 1 No |
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 |
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 |
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 |
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
main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }
What are the files which are automatically opened when a C file is executed?
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!
void main() { int *mptr, *cptr; mptr = (int*)malloc(sizeof(int)); printf(“%d”,*mptr); int *cptr = (int*)calloc(sizeof(int),1); printf(“%d”,*cptr); }
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
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); }
enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }
# include <stdio.h> int one_d[]={1,2,3}; main() { int *ptr; ptr=one_d; ptr+=3; printf("%d",*ptr); }
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!
main() { char *p = "hello world"; p[0] = 'H'; printf("%s", p); } a. Runtime error. b. “Hello world” c. Compile error d. “hello world”