Operators from lowest to highest precedence


Question1)a) Find the errors in the following program:

# Include
main( )
{
print (‘Learning C is not\n a difficult task’);
return ( );
}

b) If a, b, c are int variables and a - 2, b - 4, c-3, d-5, what is the value of the expression a/b/c*d-a+c*d/b-c. Justify your answer.

c) Which of the following are valid C identifiers?

i) variable name 

ii) 2ndchance

iii) alpha++

iv) Motor-Car

v) register

vi) Saving Account

d) Write the following operators from lowest to highest precedence:

i) ( ), <, ||, ?, +, *, ++

ii) /, !=, &, -, ~, [], +=

Question2)a) Consider the program

1 #include
2 int main ()
3 {
4 int a;
5 char b;
6 float c;
7 printf ("Enter the values of a, b, c");
8 scanf ("%d%c%f",&a, &b, &c);
9 printf ("%d%c%f",&a,&b,&c);
10 return 0;
11 }

If the input is a-2.5, b-234, c-89, what is the output. Explain your answer.

b) What will be the output of the following program? Justify your answer.

#include
Int main()
{
Int x, y, z;
x=10;y=20;z=5;
x=z+y++;
printf("x=%d,y=%d,z=%d\n",x,y,z);
x=10;y=20;z=5;
y=z+ --y/x++;
printf("x=%d,y=%d,z=%d\n",x,y,z);
x=10;y=20;z=5;
z+=x*y-- %10;
printf("x=%d,y=%d,z=%d\n",x,y,z);
x=10;y=20;z=5;
x-=x%z-(x+--z%z);
return 0;
}

c) Explain the output of the following C program:

1 # include
2 # include
3 int main ( )
4 {
5 int count;
6 for (count = 1; count <= 100; count ++)
7 i f (pow (floor (sqrt (count + 0.0)), 2) == count)
8 printf ("% d", count);
9 printf ("\n");
10 return 0;
11 }

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Operators from lowest to highest precedence
Reference No:- TGS02595

Now Priced at $40 (50% Discount)

Recommended (93%)

Rated (4.5/5)