Welcome to Word
Welcome to Word
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
namespace
class Program
INput
//Console.WriteLine("Enter your name:");
string name = Console.ReadLine();
// Getting int input Console.WriteLine("Enter your number:");
int number = int.Parse(Console.ReadLine());
// Getting char input Console.WriteLine("Enter a character:");
char character = char.Parse(Console.ReadLine());
// Getting double input Console.WriteLine("Enter a decimal number:");
double decimalNumber = double.Parse(Console.ReadLine());
//Console.WriteLine("Enter a date (yyyy-mm-dd):");
String to Integer:
Integer to String:
String to Double:
Double to String:
String to DateTime:
DateTime to String:
String to TimeSpan:
TimeSpan to String:
TimeSpan time = new TimeSpan(12, 30, 0);
string strTime = time.ToString();
}
foreach (int x in k )
{
if (x > 5)
{
Console.WriteLine(x);
}
}
//
K.Contains();
Sort();
Insert()/InsertRange();
Remove()/RemoveRange();
////
--------------------------------------------------------
fibonaci
int i, count, a = 0, b = 1, c = 0;
count =int.Parse(Console.ReadLine());
Console.Write(a);
Console.Write(b);
for (i = 0; i <= count; i++) {
c = a + b;
Console.Write(c + " ");
a=b;
b=c;
swap;
a=10,b = 30;
a = a + b //a=40
b = a - b; //b=10
a = a - b; //a=30
(or)
a=a*b;
b=a/b;
a=a/b;
-------------------------------------------------------------
palindrome;
while (n > 0)
{
i=n%10;
m = (m * 10) + i;
n =n/10;
}/
-------------------------------------------------------------
Factorial;
for(i=1;i<=number;i++){
fact=fact*i;
}
-------------------------------------------------------------
Armstrong Number ;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
-------------------------------------------------------------
Sum of digit;
while(n>0)
{
m=n%10;
sum=sum+m;
n=n/10;
}
Console.Write("Sum is= "+sum);
-------------------------------------------------------------
reverse number;
while(n!=0)
{
rem=n%10;
reverse=reverse*10+rem;
n/=10;
}
-------------------------------------------------------------
int n, i;
int[] a = new int[10];
Console.Write("Enter the number to convert: ");
n = int.Parse(Console.ReadLine());
for (i = 0; n > 0; i++)
{
a[i] = n % 2;
n = n / 2;
}
Console.Write("Binary of the given number= ");
for (i = i - 1; i >= 0; i--)
{
Console.Write(a[i]);
}
---------------------------------------------------
------------------------------------------------------
Array Short