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 C program that computes the value ex by using the formula ex =1+x/1!+x2/2!+x3+3!+………….
the output will be #include<stdio.h> int main () { int i; i = 9/2; printf("%i",i); return 0; }
wat is the difference between a definition and declaration? float y;---it looks like a declaration..but it s a definition.how?someone explain
How is pointer initialized in c?
What are the modifiers available in c programming language?
what is the difference b/w NULL and null?
What is cohesion and coupling in c?
Explain what will the preprocessor do for a program?
the maximum width of a c variable name can be a) 6 characters b) 8 characters c) 10 characters d) 20 characters
What is the difference between char array and char pointer?
Write a program to print fibonacci series without using recursion?
Implement bit Array in C.