# Thread: 2 programs for programming !

1. ## 2 programs for programming !

Hi friends , I have 2 programs ... and i want u to help me on solving them !

1. Write a c++ (or c) program that input 3 numbers and print the type of a Triangle ! (of course if the triangle can be made ! Otherwise print it can not be a Triangle )

and 2. write a program that input a number , if it's a Multiple of 4 print (1/4) that number ... otherwise print (2^n) (n is inputed number) (Without using of if,:?,*,%,/)!!

am waiting for ur answers ... TNX !!

2. And we're waiting for you to show some effort.

You can't just dump your assignment and leave it at that.

For the first, study some geometry -> Triangle - Wikipedia, the free encyclopedia
For the second, lookup the bitwise operators << >> & |

3. You might also want to have a look at this site's homework policy, at this link. That will make the reasons for Salem's response abundantly clear.

4. Salem .... excuse me !!
In fact i want u to help me ... !!! Not just solving them !! and i know what a triangle is !!!!!

I solved one of them but not completely ... and i want u Guide me !!!

at all , I apologoize u if i annoy anyone !!

Regards;
Seniorija

5. Originally Posted by Seniorija
I solved one of them but not completely ...
So.. show us the incomplete solution.

6. Think of us as a pinball machine. We're those little bumper things that give the ball a shove when the ball touches them, to try and get the more points, make things more interesting, and keep the ball away from the hole at the bottom. The problem here is that you haven't pulled the plunger to fire the ball into play (i.e. haven't posted your attempt), so we have nothing to do yet.

We're still waiting for you... not the other way around.

7. iMalc, you may be dating yourself with a pinball machine reference

8. Thank u for ur all warnings ! So ... for question 1 : i have used "if" ... actually i know that its better to use if , but i dont exactly know what i shoud do ... !!!! the following is my solution (incomplete solution!!):
Code:
```#include <iostream>
#include <conio.h>
using namespace std;
int main(){
float a,b,c;
cout << "Enter 3 Numbers:" << endl;
cin >> a >> b >> c;

if (a+b<=c)
cout << "WoW! It can not be a Triangle" << endl;
if (a+c<=b)
cout << "WoW! It can not be a Triangle" << endl;
if (b+c<=a)
cout << "0WoW! It can not be a Triangle" << endl;

if (a==b==c)
cout << "Type of Triangle is equalateral triangle" << endl;

if (a*a==b*b+c*c)
cout << "Type of Triangle is right triangle" << endl;
if (b*b==a*a+c*c)
cout << "Type of Triangle is right triangle" << endl;
if (c*c==a*a+b*b)
cout << "Type of Triangle is right triangle" << endl;

if (a==b)
cout << "Type of Triangle is Isosceles Triangle" << endl;
if (a==c)
cout << "Type of Triangle is Isosceles Triangle" << endl;
if (b==c)
cout << "Type of Triangle is Isosceles Triangle" << endl;
getch();
return 0;
}```
in this code i want check 3 conditions (if) and after print 1 message (to specify the type of triangle ) ... !! i think its better that i write my code compact !! , dont it ?... do u know what i mean ?!!!
and next ,when i enter 3 equal numbers , it prints "The type of triangle is Isosceles Triangle" 3 times and also it doesnt print equlateral triangle !!!! why ?!!

and for question 2 :
would u plz give me an idea to start ?!!!!!!!

9. > and next ,when i enter 3 equal numbers , it prints "The type of triangle is Isosceles Triangle"
Because equilateral is just a special case of isosceles.

Code:
```if ( ... ) {
} else if ( ... ) {
} else if ( .... ) {
} else {
}```
If you just have separate if statements, you hit all the ones which are true.
If you have if / else if chain, then you only get the first one to match true.

> if (a==b==c)
Try
if ( a == b && b == c )

> and for question 2 :
> would u plz give me an idea to start