You are on page 1of 3

HOMEWORK 1 OF LAB OF

MODERN
PROGRAMMING TOOLS &
TECHNIQUES-2

Submitted to: Submitted By:


Mr. P.S.Vijayendra Anish sethi
RA17B1A17
B-TECH(HONS.)MBA(CSE)

Write a C program to calculate the following Sum:

Sum=1+x/1! +x3/3!+x5/5!+x7/7!+xn/n!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int w,x,q,s=1;
Console.WriteLine("Enter value for variable w");
w = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter value for variable x");
x = Convert.ToInt32(Console.ReadLine());
for (q = 1; q <= n; q=q+2)
{
int k = 1;
int r = 1;
for (int m = 1; m <= q; m++)
{
f = k * q;
g = r*x;
}
Console.WriteLine(g);
Console.WriteLine(f);
s = s + r/k;
}
Console.WriteLine(s);
Console.Read();
}

}
}

Write a C# program to find the sqrt of a given number

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
class Program
{

static void Main(string[] args)


{
Int n;
Console.WriteLine("Enter the value for n");
n=Convert.ToDouble(Console.ReadLine());
double y = n / 2.0;
double l = 0.0;
while(y != l)
{
l = y;
y = (y + n/y) / 2.0;

}
Console.WriteLine(y);
Console.ReadLine();

}
}
}

You might also like