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 is the difference between constant pointer and pointer to a constant. Give examples.
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
what is the advantage of function pointer
16 Answers CMC, CS, Freshdesk, L&T, LG Soft, Matrix, TCS,
What is keyword in c?
int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation.
What is Dynamic Initialization.
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
What is break statement?
please help me..... please codes and flowchart plz turbo c lang po yan.....please asap response... 3. Make an astrology program. The user types in his or her birthday (month, day, and year as integer), and the program responds with the user’s zodiac sign, horoscope, and other information related to it. If the user’s birth year falls into a leap year, your program should display an appropriate message for it. NOTES: Conditional Statements: it should be with graphics
Write program to remove duplicate in an array?
What is false about the following A compound statement is a.A set of simple statments b.Demarcated on either side by curly brackets c.Can be used in place of simple statement d.A C function is not a compound statement.
C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions