when user give a number it multiply with 9 without
useing '+' and '*' oprator

Answers were Sorted based on User's Feedback



when user give a number it multiply with 9 without useing '+' and '*' oprator..

Answer / guest

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{clrscr();
int a,i,r=0;
scanf("%d",&a);

for(i=a;i>0;i--)
r=r-9;
r=abs(r);
printf("%d",r);
getch();
}

Is This Answer Correct ?    4 Yes 2 No

when user give a number it multiply with 9 without useing '+' and '*' oprator..

Answer / tknowledge05

The above guest is me .. okk....
by the time i solved and executing i was logged out and when i posted the answer it considered guest.......

Is This Answer Correct ?    0 Yes 0 No

when user give a number it multiply with 9 without useing '+' and '*' oprator..

Answer / tknowledge05

The above guest is me .. okkkk....
by the time i solved and executing i was logged out and when i posted the answer it considered guestt.........

Is This Answer Correct ?    0 Yes 0 No

when user give a number it multiply with 9 without useing '+' and '*' oprator..

Answer / vaibhav nigam

/*
your answer is quite correct but its better to use
r=-r; instead of r=abs(r);

well i would have done it like :

*/

#include <iostream>
using namespace std;
int main()
{
int k;
cin >> k;
k=(k<<4)-(k<<2)-(k<<1)-k;
cout << k << endl;
return 0;
}

//here no loop is used..

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

hi any body pls give me company name interview conduct "c" language only

0 Answers  


What is const keyword in c?

0 Answers  


what is c programming?

3 Answers   TCS,


differentiate built-in functions and user – defined functions.

0 Answers  


what would be the output of the following program main() { int a[] = {1,2,3,4,5}; int *ptr = {a,a+1,a+2,a+3,a+4}; printf("%d %d %d %d",a,*ptr,**ptr,ptr); } }

1 Answers  






proc() { static i=10; printf("%d",i); } If this proc() is called second time, what is the output?

7 Answers   Hughes,


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

5 Answers   TCS, Vimukti Technologies,


Hai why 'c' is the middle language

4 Answers  


What is the value of y in the following code? x=7;y=0; if(x=6) y=7; else y=1;

12 Answers   TCS,


Explain what is the benefit of using #define to declare a constant?

0 Answers  


How to Clear last bit if it 1 using Macro TURN_OFF_BIT_LAST

6 Answers   Adobe, Huawei,


Do you know the purpose of 'register' keyword?

0 Answers  


Categories