write a program that will accept two integers and will implement division without using the division operator if the second value is an odd number and will implement multiplication without using multiplication operator if the second value is an even number.
Answer / yogi patel
//Yogi patel
#include<conio.h>
#include<stdio.h>
void main()
{
int a,b,ans,i;
clrscr();
printf("Enter first number :->> ");
scanf("%d",&a);
printf("Enter second number :->> ");
scanf("%d",&b);
if(b%2==0)
{
ans=a;
printf("Division perform");
for(i=0; i<(a/2); i++)
{
ans=ans-1;
}
printf("\n\nAns is :- %d",ans);
}
else
{
ans=0;
printf("Multiplication perform");
for(i=0; i<b; i++)
{
ans=ans+a;
}
printf("\n\nAns is :- %d",ans);
}
getch();
}
Is This Answer Correct ? | 1 Yes | 0 No |
What are terms in math?
WHAT IS HEADER?
Write a Program to find whether the given number or string is palindrome.
write a program to count the no of repaeted words in a line?
Function shall sum members of given one-dimensional array. However, it should sum only members whose number of ones in the binary representation is higher than defined threshold (e.g. if the threshold is 4, number 255 will be counted and 15 will not) - The array length is arbitrary - output the results to the stdout
N O S I E R + A S T R A L ---------------- 7 2 5 6 1 3
void main(int argc,char *argv[],char *env[]) { int i; for(i=1;i<argc;i++) printf("%s",env[i]); }
Juxtapose the use of override with new. What is shadowing?
Synonymous with pointer array a) character array b) ragged array c) multiple array d) none
how to set Nth bit of a variable?
How to write a code for reverse of string without using string functions?
How do we make a global variable accessible across files? Explain the extern keyword?