0% found this document useful (0 votes)
2 views5 pages

exp3

The document contains a series of C# programming experiments conducted by Alveera Abdulnawaz Shaikh, focusing on various algorithms including Fibonacci series, Armstrong numbers, Anagrams, Sum of Digits, and Palindrome checks. Each experiment includes the code implementation and prompts for user input. The document showcases the student's understanding of basic programming concepts and problem-solving skills.

Uploaded by

dacega9204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

exp3

The document contains a series of C# programming experiments conducted by Alveera Abdulnawaz Shaikh, focusing on various algorithms including Fibonacci series, Armstrong numbers, Anagrams, Sum of Digits, and Palindrome checks. Each experiment includes the code implementation and prompts for user input. The document showcases the student's understanding of basic programming concepts and problem-solving skills.

Uploaded by

dacega9204
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Name: Alveera Abdulnawaz Shaikh

Std: T.Y. Div: B Roll no.: 250

Experiment No. : 03

1) Fibonacci series

using System;
class Fibonacci

static void Main()

Console.WriteLine("Name: Alveera Abdulnawaz Shaikh, Roll no: 250, Div: B");

int n1 = 0, n2 = 1, n3, i, number;

Console.Write("Enter the number of elements: ");

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

Console.Write(n1 + " " + n2 + " ");

for (i = 2; i < number; ++i)

n3 = n1 + n2;

Console.Write(n3 + " ");

n1 = n2;

n2 = n3;

Output:
2) Armstrong Number

using System;
class Armstrong
{
static void Main()
{

Console.WriteLine("Name: Alveera Abdulnawaz Shaikh, Roll no: 250, Div: B");


int n, r, sum = 0, temp;
Console.Write("Enter the Number= ");
n = int.Parse(Console.ReadLine());
temp = n;
while (n > 0)
{
r = n % 10;
sum = sum + (r * r * r);
n = n / 10;
}
if (temp == sum)
Console.Write("Armstrong Number.");
else
Console.Write("Not Armstrong Number.");
}
}

Output:
3) Anagram

using System;
class Anagram
{
static void Main()
{
Console.WriteLine("Name: Alveera Abdulnawaz Shaikh, Roll no: 250, Div: B");
string str1 = "heater";
string str2 = "reheat";
char[] ch1 = str1.ToLower().ToCharArray();
char[] ch2 = str2.ToLower().ToCharArray();
Array.Sort(ch1);
Array.Sort(ch2);
string val1 = new string(ch1);
string val2 = new string(ch2);

if (val1 == val2)
{
Console.WriteLine("Both the strings are Anagrams");
}
else
{
Console.WriteLine("Both the strings are not Anagrams");
}
}
}

Output:
4) Sum of Digits
using System;

class SumOfDigits

static void Main()

Console.WriteLine("Name: Alveera Abdulnawaz Shaikh, Roll no: 250, Div: B");

Console.WriteLine();

Console.Write("Enter a number: ");

int num = Math.Abs(Convert.ToInt32(Console.ReadLine()));

int sum = 0;

while (num > 0)

int digit = num % 10;

sum += digit;

num /= 10;

Console.WriteLine("The sum of digits is: " + sum);

Output:
5) Palindrome

using System;

class PalindromeNumber
{
static void Main()
{
Console.WriteLine("Name: Alveera Abdulnawaz Shaikh, Roll no: 250, Div: B");
Console.Write("Enter a number: ");
int num = Convert.ToInt32(Console.ReadLine());
int originalNum = num, reversedNum = 0;
while (num > 0)
{
reversedNum = reversedNum * 10 + num % 10;
num /= 10;
}
Console.WriteLine(originalNum == reversedNum ? "Palindrome" : "Not a
Palindrome");
}
}

Output:

You might also like