This is Not AD.
Join Our Telegram Channel To Get OUR all Material Up to Date.
Don't Worry Your All Info Will Be Secured
Home About Us Services Materials Contact Us
Home About Services Materials Contact
‹
›
Home
Home > C# | SU [ 1 - 10 ] [ FOR JOURNAL ]
CODE

using System;
class Swap
{
    static void Main()
    {
        int a = 10, b = 20;

        Console.WriteLine("Before Swap");
        Console.WriteLine("A = "+a+" B = "+b);

        a = a + b; 
    // 30 = 10 + 20;
        b = a - b; 
    // 10 = 30 - 20;
        a = a - b; 
    // 20 = 30 - 10;

        Console.WriteLine("After Swap");
        Console.WriteLine("A = "+a+" B = "+b);
    }
}

                
OUTPUT

Before Swap
A = 10 B = 20
After Swap
A = 20 B = 10
                    
CODE

using System;
class Calculation
{
    static void Main()
    {
        int sum , difference , product;
        float quotient;

        Console.WriteLine("Calculation");
        Console.Write("Enter A = ");
        int a = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter B = ");
        int b = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("\n Your Value A = "+a+" & B = "+b);
        Console.WriteLine("----------------------------------");
        sum = a + b;
        Console.WriteLine("Sum = " + sum);

        difference = a - b;
        Console.WriteLine("Difference = " + difference);

        product = a * b;
        Console.WriteLine("Product = " + product);

        quotient = a / b;
        Console.WriteLine("Quotient = " + quotient);
        
    }
}

                
OUTPUT

Calculation
Enter A = 20
Enter B = 30

 Your Value A = 20 & B = 30
----------------------------------
Sum = 50
Difference = -10
Product = 600
Quotient = 0
                    
CODE

using System;
class Relational_Operator
{
    static void Main()
    {
        Console.WriteLine("Relational Operator ");
        Console.Write("Enter A = ");
        int a = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter B = ");
        int b = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("\n Your Value A = " + a + " & B = " + b);
        Console.WriteLine("----------------------------------");

        Console.WriteLine("A > B   " + (a > b));
        Console.WriteLine("A < B   " + (a < b));
        Console.WriteLine("A >= B  " + (a >= b));
        Console.WriteLine("A <= B  " + (a <= b));
        Console.WriteLine("A == B  " + (a == b));
        Console.WriteLine("A != B  " + (a != b));


    }
}
                
OUTPUT

Relational Operator 
Enter A = 20
Enter B = 20

 Your Value A = 20 & B = 20
----------------------------------
A > B   False
A < B   False
A >= B  True
A <= B  True
A == B  True
A != B  False

                    
CODE

using System;
class CheckNo
{
    static void Main()
    {
        Console.WriteLine("Check No. is Positive | Negative | Zero ");
        Console.Write("Enter A = ");
        int a = Convert.ToInt32(Console.ReadLine());
        
        Console.WriteLine("\n Your Value A = " + a);
        Console.WriteLine("----------------------------------");

        if(a > 0)
        {
            Console.WriteLine("Positive");
        }
        else if (a < 0)
        {
            Console.WriteLine("Negative");
        }
        else
        {
            Console.WriteLine("Zero");
        }


    }
}
                
OUTPUT

Check No. is Positive | Negative | Zero 
Enter A = 0 

 Your Value A = 0
----------------------------------
Zero
                    
CODE

using System;
class NestedIf
{
    static void Main()
    {
        int a = 100 , b = 20 , c = 20 ;

        if(a < b)
        {
            if (b < c)
            {
                Console.WriteLine(" Largest No. is "+c);
            }
            else
            {
                Console.WriteLine(" Largest No. is " + b);
            }
        }
        else if(a > b)
        {
            if(a > c)
            {
                Console.WriteLine(" Largest No. is " + a);
            }
            else
            {
                Console.WriteLine(" Largest No. is " + b);
            }
        }
        else
        {
            Console.WriteLine(" Largest No. is " + c);
        }
    }
}

                
OUTPUT

Largest No. is 100
CODE

using System;
class Switch
{
    static void Main()
    {
        Console.WriteLine("Find Day of Week Using Switch");
        Console.Write("Enter A = ");
        int no = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("\n Your Value = " + no);
        Console.WriteLine("----------------------------------");

        switch (no)
        {
            case 1 : Console.WriteLine("Monday");
                     break;

            case 2 : Console.WriteLine("Tuesday");
                     break;

            case 3 : Console.WriteLine("Wednesday");
                     break;

            case 4 : Console.WriteLine("Thursday");
                     break;

            case 5 : Console.WriteLine("Friday");
                     break;

            case 6 : Console.WriteLine("Saturday");
                     break;

            case 7 : Console.WriteLine("Sunday");
                     break;

            default : Console.WriteLine("!Opps Incorrect Number");
                     break;
        }
    }
}
                
OUTPUT

Find Day of Week Using Switch
Enter A = 

 Your Value = 8
----------------------------------
!Opps Incorrect Number

                    
CODE

using System;
class ForLoop
{
    static void Main()
    {
        Console.WriteLine("For Loop");

        for (int i = 1; i <= 10; i++)
        {
            Console.WriteLine(i);
        }
    }
}
                
OUTPUT

For Loop
1
2
3
4
5
6
7
8
9
10
                    
CODE

using System;
class While
{
    static void Main()
    {
        int i = 2;

        Console.WriteLine("While Loop");
        while(i<=50)
        {
            Console.WriteLine(i);
            i += 2;
        }
    }
}
                
OUTPUT

While Loop
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
                    
CODE

using System;
class DoWhile
{
    static void Main()
    {
        Console.WriteLine("Do.. While Loop");
        int n;
        


        do
        {
            Console.Write("Enter No. (0 to terminate) : ");
            n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine();

            if (n != 0)
            {
                Console.WriteLine(" Entered Number : "+n);
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("------------------------------");
                Console.WriteLine("Loop Stopped");
                break;
            }

        } while (n != 0);
    }
}
                
OUTPUT

Do.. While Loop
Enter No. (0 to terminate) : 1

 Entered Number : 1

Enter No. (0 to terminate) : 22

 Entered Number : 22

Enter No. (0 to terminate) : 90

 Entered Number : 90

Enter No. (0 to terminate) : 0

------------------------------
Loop Stopped

                    
CODE

// 10 (a) - 1 2 3 ... n series

using System;
class series123n
{
    static void Main()
    {
        for (int i = 1; i <= 10; i++)
        {
            Console.Write(" "+i);
        }
    }
}

                    
OUTPUT

1 2 3 4 5 6 7 8 9 10
CODE

// 10 (b) - 1 3 5 ... n series

using System;
class series135n
{
    static void Main()
    {
        for(int i = 1; i<=10; i+=2)
        {
            Console.Write(" "+i);
        }
    }
}
                    
OUTPUT

1 3 5 7 9 
CODE

// 10 (c) - 2+4+6 ... n series

using System;
class series246n
{ 
    static void Main()
    {
        for(int i = 2;i<=9;i+=2)
        {
            Console.Write(i+" + ");
        }
        Console.WriteLine("10");
    }
}

                    
OUTPUT

2 + 4 + 6 + 8 + 10
CODE

// 10 (d) - 1+4+7 ... n series 

using System;
class series147n
{
    static void Main()
    {
        for (int i = 1; i <= 9; i += 3)
        {
            Console.Write(i + " + ");
        }
        Console.Write("10");

    }
}

                    
OUTPUT

1 + 4 + 7 + 10
CODE

// 10 (e) - 0 1 1 2 3 5 ... n series

using System;
class series011235n
{
    static void Main()
    {
       long a = 0, b = 1, c;

        for (int i = 0; i <= 10; i++)
        {
            if (i <= 1)
            {
                c = i; 
            }
            else
            {
                c = a + b;
                a = b;
                b = c;
            }
            Console.Write(c + " ");
        }
        Console.WriteLine();
    }
}

                    
OUTPUT

0 1 1 2 3 5 8 13 21 34 55 
CODE

// 10 (f) - 1 2 2 4 8 ... n series

using System;
class series12248n
{
    static void Main()
    {
        long a = 1, b = 2, c;


        for (int i = 1; i <= 10; i++)
        {
            if (i == 1)
            {
                Console.Write(a + " ");
                continue;
            }
            if (i == 2)
            {
                Console.Write(b + " ");
                continue;
            }

            c = a * b; 
            Console.Write(c + " ");

            a = b;
            b = c;
        }
        Console.WriteLine();
    }
}

                    
OUTPUT

1 2 2 4 8 32 256 8192 2097152 17179869184 

No comments:

Post a Comment

Tuesday, 20 January 2026

C# | SU [ 1 - 10 ] [ FOR JOURNAL ]

CODE

using System;
class Swap
{
    static void Main()
    {
        int a = 10, b = 20;

        Console.WriteLine("Before Swap");
        Console.WriteLine("A = "+a+" B = "+b);

        a = a + b; 
    // 30 = 10 + 20;
        b = a - b; 
    // 10 = 30 - 20;
        a = a - b; 
    // 20 = 30 - 10;

        Console.WriteLine("After Swap");
        Console.WriteLine("A = "+a+" B = "+b);
    }
}

                
OUTPUT

Before Swap
A = 10 B = 20
After Swap
A = 20 B = 10
                    
CODE

using System;
class Calculation
{
    static void Main()
    {
        int sum , difference , product;
        float quotient;

        Console.WriteLine("Calculation");
        Console.Write("Enter A = ");
        int a = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter B = ");
        int b = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("\n Your Value A = "+a+" & B = "+b);
        Console.WriteLine("----------------------------------");
        sum = a + b;
        Console.WriteLine("Sum = " + sum);

        difference = a - b;
        Console.WriteLine("Difference = " + difference);

        product = a * b;
        Console.WriteLine("Product = " + product);

        quotient = a / b;
        Console.WriteLine("Quotient = " + quotient);
        
    }
}

                
OUTPUT

Calculation
Enter A = 20
Enter B = 30

 Your Value A = 20 & B = 30
----------------------------------
Sum = 50
Difference = -10
Product = 600
Quotient = 0
                    
CODE

using System;
class Relational_Operator
{
    static void Main()
    {
        Console.WriteLine("Relational Operator ");
        Console.Write("Enter A = ");
        int a = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter B = ");
        int b = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("\n Your Value A = " + a + " & B = " + b);
        Console.WriteLine("----------------------------------");

        Console.WriteLine("A > B   " + (a > b));
        Console.WriteLine("A < B   " + (a < b));
        Console.WriteLine("A >= B  " + (a >= b));
        Console.WriteLine("A <= B  " + (a <= b));
        Console.WriteLine("A == B  " + (a == b));
        Console.WriteLine("A != B  " + (a != b));


    }
}
                
OUTPUT

Relational Operator 
Enter A = 20
Enter B = 20

 Your Value A = 20 & B = 20
----------------------------------
A > B   False
A < B   False
A >= B  True
A <= B  True
A == B  True
A != B  False

                    
CODE

using System;
class CheckNo
{
    static void Main()
    {
        Console.WriteLine("Check No. is Positive | Negative | Zero ");
        Console.Write("Enter A = ");
        int a = Convert.ToInt32(Console.ReadLine());
        
        Console.WriteLine("\n Your Value A = " + a);
        Console.WriteLine("----------------------------------");

        if(a > 0)
        {
            Console.WriteLine("Positive");
        }
        else if (a < 0)
        {
            Console.WriteLine("Negative");
        }
        else
        {
            Console.WriteLine("Zero");
        }


    }
}
                
OUTPUT

Check No. is Positive | Negative | Zero 
Enter A = 0 

 Your Value A = 0
----------------------------------
Zero
                    
CODE

using System;
class NestedIf
{
    static void Main()
    {
        int a = 100 , b = 20 , c = 20 ;

        if(a < b)
        {
            if (b < c)
            {
                Console.WriteLine(" Largest No. is "+c);
            }
            else
            {
                Console.WriteLine(" Largest No. is " + b);
            }
        }
        else if(a > b)
        {
            if(a > c)
            {
                Console.WriteLine(" Largest No. is " + a);
            }
            else
            {
                Console.WriteLine(" Largest No. is " + b);
            }
        }
        else
        {
            Console.WriteLine(" Largest No. is " + c);
        }
    }
}

                
OUTPUT

Largest No. is 100
CODE

using System;
class Switch
{
    static void Main()
    {
        Console.WriteLine("Find Day of Week Using Switch");
        Console.Write("Enter A = ");
        int no = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("\n Your Value = " + no);
        Console.WriteLine("----------------------------------");

        switch (no)
        {
            case 1 : Console.WriteLine("Monday");
                     break;

            case 2 : Console.WriteLine("Tuesday");
                     break;

            case 3 : Console.WriteLine("Wednesday");
                     break;

            case 4 : Console.WriteLine("Thursday");
                     break;

            case 5 : Console.WriteLine("Friday");
                     break;

            case 6 : Console.WriteLine("Saturday");
                     break;

            case 7 : Console.WriteLine("Sunday");
                     break;

            default : Console.WriteLine("!Opps Incorrect Number");
                     break;
        }
    }
}
                
OUTPUT

Find Day of Week Using Switch
Enter A = 

 Your Value = 8
----------------------------------
!Opps Incorrect Number

                    
CODE

using System;
class ForLoop
{
    static void Main()
    {
        Console.WriteLine("For Loop");

        for (int i = 1; i <= 10; i++)
        {
            Console.WriteLine(i);
        }
    }
}
                
OUTPUT

For Loop
1
2
3
4
5
6
7
8
9
10
                    
CODE

using System;
class While
{
    static void Main()
    {
        int i = 2;

        Console.WriteLine("While Loop");
        while(i<=50)
        {
            Console.WriteLine(i);
            i += 2;
        }
    }
}
                
OUTPUT

While Loop
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
                    
CODE

using System;
class DoWhile
{
    static void Main()
    {
        Console.WriteLine("Do.. While Loop");
        int n;
        


        do
        {
            Console.Write("Enter No. (0 to terminate) : ");
            n = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine();

            if (n != 0)
            {
                Console.WriteLine(" Entered Number : "+n);
                Console.WriteLine();
            }
            else
            {
                Console.WriteLine("------------------------------");
                Console.WriteLine("Loop Stopped");
                break;
            }

        } while (n != 0);
    }
}
                
OUTPUT

Do.. While Loop
Enter No. (0 to terminate) : 1

 Entered Number : 1

Enter No. (0 to terminate) : 22

 Entered Number : 22

Enter No. (0 to terminate) : 90

 Entered Number : 90

Enter No. (0 to terminate) : 0

------------------------------
Loop Stopped

                    
CODE

// 10 (a) - 1 2 3 ... n series

using System;
class series123n
{
    static void Main()
    {
        for (int i = 1; i <= 10; i++)
        {
            Console.Write(" "+i);
        }
    }
}

                    
OUTPUT

1 2 3 4 5 6 7 8 9 10
CODE

// 10 (b) - 1 3 5 ... n series

using System;
class series135n
{
    static void Main()
    {
        for(int i = 1; i<=10; i+=2)
        {
            Console.Write(" "+i);
        }
    }
}
                    
OUTPUT

1 3 5 7 9 
CODE

// 10 (c) - 2+4+6 ... n series

using System;
class series246n
{ 
    static void Main()
    {
        for(int i = 2;i<=9;i+=2)
        {
            Console.Write(i+" + ");
        }
        Console.WriteLine("10");
    }
}

                    
OUTPUT

2 + 4 + 6 + 8 + 10
CODE

// 10 (d) - 1+4+7 ... n series 

using System;
class series147n
{
    static void Main()
    {
        for (int i = 1; i <= 9; i += 3)
        {
            Console.Write(i + " + ");
        }
        Console.Write("10");

    }
}

                    
OUTPUT

1 + 4 + 7 + 10
CODE

// 10 (e) - 0 1 1 2 3 5 ... n series

using System;
class series011235n
{
    static void Main()
    {
       long a = 0, b = 1, c;

        for (int i = 0; i <= 10; i++)
        {
            if (i <= 1)
            {
                c = i; 
            }
            else
            {
                c = a + b;
                a = b;
                b = c;
            }
            Console.Write(c + " ");
        }
        Console.WriteLine();
    }
}

                    
OUTPUT

0 1 1 2 3 5 8 13 21 34 55 
CODE

// 10 (f) - 1 2 2 4 8 ... n series

using System;
class series12248n
{
    static void Main()
    {
        long a = 1, b = 2, c;


        for (int i = 1; i <= 10; i++)
        {
            if (i == 1)
            {
                Console.Write(a + " ");
                continue;
            }
            if (i == 2)
            {
                Console.Write(b + " ");
                continue;
            }

            c = a * b; 
            Console.Write(c + " ");

            a = b;
            b = c;
        }
        Console.WriteLine();
    }
}

                    
OUTPUT

1 2 2 4 8 32 256 8192 2097152 17179869184 
GOHEL MANTHAN - January 20, 2026
‹
›
Home

Creating innovative solutions for a connected world.

Email On

manthangohel04@gmail.com

This website was designed , developed and maintenance by GOHEL MANTHAN © 2026