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 |
how can i get output like this? 1 2 3 4 5 6
Explain continue keyword in c
What is preprocessor with example?
How do I convert a string to all upper or lower case?
Are there constructors in c?
what is the difference between structure and union?
Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??
Can a function argument have default value?
12345 1234 123 12 1
What is the value of h?
write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1
What is a buffer in c?