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 program to remove duplicate from an ordered char array? in c
what is the output of the program and explain why?? #include<stdio.h> void main ( ) { int k=4,j=0: switch (k) { case 3; j=300; case 4: j=400: case 5: j=500; } printf (ā%d\nā,j); }
Why is it usually a bad idea to use gets()? Suggest a workaround.
create an SINGLE LINKED LISTS and reverse the data in the lists completely
can we access one file to one directory?
write a program for size of a data type without using sizeof() operator?
22 Answers HCL, IBM,
How to write a code for implementing my own printf() and scanf().... Please hep me in this... I need a guidance... Can you give an coding for c... Please also explain about the header files used other than #include<stdio.h>...
How many loops are there in c?
write aprogram for There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.
1 Answers iGate, Shashi, Source Bits, Subex,
Why is not a pointer null after calling free?
When is a void pointer used?
What is pointers in c?