7- (10 points) Consider the following code- What is the final value of.docx
Nächste SlideShare
Project2Project2
Wird geladen in ... 3
1 von 1

Más contenido relacionado

Más de rjessie(20)

7- (10 points) Consider the following code- What is the final value of.docx

  1. 7. (10 points) Consider the following code. What is the final value of count? count -0; for a0:2 for b 2:-1:a for c a:b count count1; end end end Solution the final value of count is 10 count = 0; % count variable is assigned with value zero for a=0:2 % the value of a is begin with zero increment by 1 until reach 2 for b=2:-1:a % the value of b is begin with 2 and decrement by 1 till reach the value of a loop ends for c= a:b % the value of c is begin with the value in a and increment by one till reach the value in b .loop ends count= count+1; %the count variable is incremented by one till loop terimination fprintf(" a =%d , b= %d ,c= %d ,count = %d ",a,b,c,count); end end end fprintf("/n final value of count = %d ",count); on executing the above program we it displays the following result Output: