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 does int main () mean?
can we initialize all the members of union?
WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..
What is c standard library?
Is reference used in C?
main is a predefined or user define function if user defined why? if predefined whay?
What is this infamous null pointer, anyway?
What is pre-emptive data structure and explain it with example?
Write the syntax and purpose of a switch statement in C.
how to use enum datatype?Please explain me?
What does sizeof function do?
Explain argument and its types.