0% found this document useful (0 votes)
10 views

class3

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

class3

Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 9

Conditional

===============

if
if else
else if
nested if - if another if condition

switch

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{

int a, b, c;

Console.WriteLine("enter first number");


a=int.Parse(Console.ReadLine());

Console.WriteLine("enter second number");


b =int.Parse(Console.ReadLine());

Console.WriteLine("enter third number");


c =int.Parse(Console.ReadLine());

if (a > b && a > c)


{
Console.WriteLine("a is greater than b and c");
}
else if (b > a)
{
if (b > c)
{
Console.WriteLine("b is greater than a and c");
}
else
{
Console.WriteLine("c is greater than a and b");
}
}
else
{
Console.WriteLine("please enter valid numbers");

}
Console.ReadKey();

}
}

}
if condition

54

condition 1 age > 10 false

condition 2 age > 20 false

condition 3 age > 30 false

condition 4 age > 40 false

condition 5 age > 50 true

condition 6 age > 60

condition 7 age > 70

switch
========

switch(condition)

case 1 :
statement
break;

case 2 :
statement
break;

default :
statement
break;

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{

int recharge;
Console.WriteLine("enter recharge amount");
recharge=int.Parse(Console.ReadLine());

switch (recharge)
{
case 10:
Console.WriteLine("recharge {0} is done!",recharge);
break;

case 20:
Console.WriteLine("recharge {0} is done!",recharge);
break;

case 30:
Console.WriteLine("recharge {0} is done!", recharge);
break;

case 40:
Console.WriteLine("recharge {0} is done!",recharge);
break;

default:
Console.WriteLine("invalid recharge!");
break;
}
Console.ReadKey();

}
}

=========================

Looping Statements
==================

while
do-while
for

foreach

whenever we required iteration(increment/decrement) then we need looping


statements

1 to 5

initialization - where to start


condition - where to stop
iteration - inc/dec

i++ => i=i+1


i-- => i=i-1
while
int i=1;
while(i<=5)
{
Console.WriteLine(i);
i++;
}

int i = 10;
while (i >= 1)
{
Console.WriteLine(i);
i--;
}

======================

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{
int table,i = 1;
Console.WriteLine("Please enter table number");

table=int.Parse(Console.ReadLine());

while (i <= 10)


{
Console.WriteLine("{0} X {1} = {2}", table, i, table * i);
i++;
}

Console.ReadKey();

}
}

-====================

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{
int i = 1;

while (i <= 100)


{
if (i % 2 == 0)
{
Console.WriteLine("even number : {0}", i);
}
else
{
Console.WriteLine("odd number : {0}", i);
}
i++;
}

Console.ReadKey();

}
}

}
==========================

Looping statements
===========

initialization
condition
iteration

while -
do-while

for

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{
int i = 1; // initilization

while (i <= 100) // condition


{
if (i % 2 == 0)
{
Console.WriteLine("even number : {0}", i);
}
else
{
Console.WriteLine("odd number : {0}", i);
}
i++;// iteration(inc/dec) i=i+1;
}

Console.ReadKey();

}
}

=================

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{
int i = 1; // initilization

while (i <= 100) // condition


{
Console.WriteLine(i);
i = i + 5;
//i++;// iteration(inc/dec) i=i+1;
}

Console.ReadKey();

}
}

=================================

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{
int i = 120; // initilization

do
{
Console.WriteLine(i);
i = i + 5;

} while (i <= 100); // condition


Console.ReadKey();

}
}

==================================

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{
for (int i = 1; i <= 10; i++)
{
Console.WriteLine(i);
}
for (int i = 10; i >= 1; i--)
{
Console.WriteLine(i);
}
Console.ReadKey();

}
}

==================================

Arrays
=============

collection of similar data types

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{

int st1 =1 ,st2 =2 ,st3 =3 ,st4 =4 ,st5 =5;

int[] st = new int[5]; // 5 is a length(or)size


st[0] = 1; // 0 is a index position
st[1] = 2; // 2 is a value
st[2] = 3;
st[3] = 4;
st[4] = 5;

for (int i = 0; i <= st.Length - 1; i++)


{
Console.WriteLine(st[i]);
}

Console.ReadKey();

}
}

==============

using System;

namespace MyfirstConsole
{
internal class Program
{
static void Main()
{
int[,] st = new int[3, 3];

st[0, 0] = 2;
st[0, 1] = 2;
st[1, 0] = 3;
st[1, 1] = 4;

Console.WriteLine(st.Length);
Console.WriteLine(st[1,1]);

Console.ReadKey();

}
}

====================================

Project
===============

UI - html,css,javascript,jquery,bootstrap,angular,react
js.....
Web , mobile , windows

Backend - C# (Business Logic)

Database - SQL server

You might also like