Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

MIN-103: Programming and Data Structures


TUTORIAL 4

Problems for programming

Write flowchart/pseudo code for all the problems in notebook

1. Take coordinate points of a triangle and check the following:


a) Can we form a triangle out of these points? If yes prompt the length of the
sides and perform next tasks. If no, report and stop the code.
b) Check whether the triangle is scalene, isosceles or equilateral.
c) Calculate area, perimeter and circum radius
d) Check whether the triangle is right angled, acute angled or obtuse angled.

2. Write a code to find out largest number out of three entries given by user. Use if-
else statements for performing the operation.

3. By writing a c++ code, determine the output of the following code snippet

int main()
{
int a,b;
cin>>a>>b;
bool x,y;

x=(a > b)&&(a==2);


y=(a < b || a==3)&&(a!=0);
cout<<x<< “\t” << y << endl;
return 0;
}

4. By writing a c++ code, determine the output of the following code snippet and
justify your answer in the notebook.
int main()
{
int a = 21;
int c ,d;
c = a++;
d= --a;
cout << c<<”\t”<<d<<endl;
return 0;
}

5. By writing a c++ code, determine the output of the following code snippet and
justify your answer in the notebook

int main()
{
int x = 5, y = 5, z;
x = ++x; y = --y;
z = x + ++x;
cout << z;
return 0;
}

6. By writing a c++ code, determine the output of the following code snippet and
justify your answer in the notebook. Determine any problem in the program if it
exits.

int main()
{
int x,y;
cin>>x>>y;
if(x != y )
if(x>y)
cout<<”x is greater than y\n”;
else
cout<<”x is less than y \n” ;
return 0;
}

7. Write a code for simple calculator which can perform (+, -, *, /). Use if-else-else
if statements.

You might also like