توصيف
صيغة الحلقة while:
while
end
برنامج يطبع !Hello World مئة مرة:
%write Matlab program to print the word 'Hello World!' 100 times
counter=1;
while counter<=100
disp('Hello World!')
counter=counter+1;
end
برنامج يطبع الأعداد من 1 إلى 50:
%write Matlab program to print the number from 1 to 50
counter=1;
while counter<=50
counter
counter=counter+1;
end
برنامج لحساب جدول الضرب لعدد :
%Write Matlab program that computes Multiplication Table for a number n and given by the user.
n=input('Enter the number\n');
counter=1;
while counter<=10
result=counter*n;
fprintf( ' %d', n )
fprintf( '* %d', counter )
fprintf(' The Result is : %d\n', result);
counter=counter+1;
end