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 |
main() { char string[]="Hello World"; display(string); } void display(char *string) { printf("%s",string); }
main() { extern int i; { int i=20; { const volatile unsigned i=30; printf("%d",i); } printf("%d",i); } printf("%d",i); } int i;
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
main() { char p[ ]="%d\n"; p[1] = 'c'; printf(p,65); }
void main() { printf(“sizeof (void *) = %d \n“, sizeof( void *)); printf(“sizeof (int *) = %d \n”, sizeof(int *)); printf(“sizeof (double *) = %d \n”, sizeof(double *)); printf(“sizeof(struct unknown *) = %d \n”, sizeof(struct unknown *)); }
#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }
how can i search an element in an array
2 Answers CTS, Microsoft, ViPrak,
main() { int i=10; i=!i>14; Printf ("i=%d",i); }
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!
main() { extern out; printf("%d", out); } int out=100;
Declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
int i; main(){ int t; for ( t=4;scanf("%d",&i)-t;printf("%d\n",i)) printf("%d--",t--); } // If the inputs are 0,1,2,3 find the o/p