You are on page 1of 2

Haramaya University

College of Computing and Informatics

Department of IS

Basic Computer Programming I worksheet2 on C++ Operators

int m=6,n=2,p=4,r=3,s=8,k = 4,a,b,c,d ;

a =++n+ ++m;

b = s++ * s++;

c = p––*p––;

d = (––k* ––k)*++r ;

cout<<“a = “<<a<<“,\tn = “<<n<<“,\tm = “<<m<<endl;

cout<<“b = “<<b <<“,\ts = “ <<s<<“\n”;

cout<<“c = “<<c<<“,\tp = “<<p<<endl;

cout<<“d = “<<d <<“,\tk = “<<k<<“,\tr = “<<r<<endl;

return 0;

19. Evaluate the following for int n = 4;.

(a) ++n*n++; (b) ++n*n– – ;

(c) 2*++n + 3 * – –n; (d) ++n += 3;

20. What would be the value of following expression for int m = 10; in the following code?

(i) m – = ++m;

(ii) m *= ++m;

21. Run the C+ code and check how it could be ?

#include <iostream>

using namespace std;

int main ()

int m=3, n=4, p=5, s=6, q=31;


m += 2;

n *= 4;

p –= 3;

s /= 2;

cout <<“m = ”<<m <<“, n = ”<<n<<“, p = ”<<p<<“, s = ”<<s<<endl;

q %= 4 + (n /= 4);

cout << “ q = “ << q << endl;

return 0;

Note: you should have addressed the whole questions as much as possible. If you have any

question on the worksheet or any doubt most welcomed new building Room no-7.

You might also like