how to draw pattern like 123 | if condition | without using loop
1
12
123.
simple program codes showing to draw 123 pattern. Logic is very simple just divide value using 100 , 10, and 1I have shown here code and also out put of given program in c#
int val = 123;
int temp = 0;
int last = 3;
if(last>2)
{
temp = val / 100; //will gives 1 because 123/100 remainder will be 23
Response.Write(temp);
Response.Write("</br>");
temp = val / 10; //will gives 12 because 123/10 remainder will be 3
Response.Write(temp);
Response.Write("</br>");
temp = val / 1; ////will gives 123 because 123/1 remainder will be 0
Response.Write(temp);
// just simple funda not a very difficult source code.
1
12
123.
simple program codes showing to draw 123 pattern. Logic is very simple just divide value using 100 , 10, and 1I have shown here code and also out put of given program in c#
int val = 123;
int temp = 0;
int last = 3;
if(last>2)
{
temp = val / 100; //will gives 1 because 123/100 remainder will be 23
Response.Write(temp);
Response.Write("</br>");
temp = val / 10; //will gives 12 because 123/10 remainder will be 3
Response.Write(temp);
Response.Write("</br>");
temp = val / 1; ////will gives 123 because 123/1 remainder will be 0
Response.Write(temp);
// just simple funda not a very difficult source code.
0 comments: