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 |
write a function to find whether a string is palindrome or not and how many palindrome this string contain?
What is const keyword in c?
Explain how do you list files in a directory?
If we give two names then this displays the connection between the two people. It is nothing but flames game
What are the benefits of c language?
What are the different types of constants?
What is unary operator?
What is the difference between text and binary modes?
Is there a way to switch on strings?
What is a structural principle?
Is main() is used in the program,,see below example? void main() { int i; for(i=0;i<10;i++) main(); } Then what is the output of the program?
Tell us bitwise shift operators?