---
title: "Can you tell me the code to write a C# program"  
description: "Can you tell me the code to write a C# program"  
author: "Mukul Goenka"  
published: 2021-11-14  
updated: 2021-11-14  
canonical: https://www.mindstick.com/forum/156831/can-you-tell-me-the-code-to-write-a-c-sharp-program  
category: "c#"  
tags: ["c#", ".net"]  
reading_time: 2 minutes  

---

# Can you tell me the code to write a C# program

Can you tell me the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) to write a C++ [program](https://www.mindstick.com/blog/12337/scaling-up-your-mentorship-program) [printing](https://www.mindstick.com/blog/63804/5-ways-you-can-use-printing-in-your-marketing-strategy) the [sum](https://www.mindstick.com/forum/159332/how-can-i-use-sum-in-linq) of [series](https://answers.mindstick.com/qa/101432/what-s-the-highest-score-in-a-single-world-series-game) 1+1/2+1/3…+1/100 using do [while loop](https://www.mindstick.com/forum/34579/while-loop-in-python)?

## Replies

### Reply by Ravi Vishwakarma

```
#include <iostream>
```

```
using namespace std;float printSeriesAndSum(int);int main(){    double sum = printSeriesAndSum(100);    cout<<'Sum of Series : '<< sum;    return 0;}float printSeriesAndSum(int num){    int i=1;    float sum= 0.0;    std::cout<<'Series ';    do{        float val = (float)1/i;        sum += val;        std::cout << val << '+ ';     }while(i++<num);    std::cout<<'\b\b \n';    return sum;}
```

Output.

```
Series 1+ 0.5+ 0.333333+ 0.25+ 0.2+ 0.166667+ 0.142857+ 0.125+ 0.111111+ 0.1+ 0.0909091+ 0.0833333+ 0.0769231+ 0.0714286+ 0.0666667+ 0.0625+ 0.0588235+ 0.0555556+ 0.0526316+ 0.05+ 0.047619+ 0.0454545+ 0.0434783+ 0.0416667+ 0.04+ 0.0384615+ 0.037037+ 0.0357143+ 0.0344828+ 0.0333333+ 0.0322581+ 0.03125+ 0.030303+ 0.0294118+ 0.0285714+ 0.0277778+ 0.027027+ 0.0263158+ 0.025641+ 0.025+ 0.0243902+ 0.0238095+ 0.0232558+ 0.0227273+ 0.0222222+ 0.0217391+ 0.0212766+ 0.0208333+ 0.0204082+ 0.02+ 0.0196078+ 0.0192308+ 0.0188679+ 0.0185185+ 0.0181818+ 0.0178571+ 0.0175439+ 0.0172414+ 0.0169492+ 0.0166667+ 0.0163934+ 0.016129+ 0.015873+ 0.015625+ 0.0153846+ 0.0151515+ 0.0149254+ 0.0147059+ 0.0144928+ 0.0142857+ 0.0140845+ 0.0138889+ 0.0136986+ 0.0135135+ 0.0133333+ 0.0131579+ 0.012987+ 0.0128205+ 0.0126582+ 0.0125+ 0.0123457+ 0.0121951+ 0.0120482+ 0.0119048+ 0.0117647+ 0.0116279+ 0.0114943+ 0.0113636+ 0.011236+ 0.0111111+ 0.010989+ 0.0108696+ 0.0107527+ 0.0106383+ 0.0105263+ 0.0104167+ 0.0103093+ 0.0102041+ 0.010101+ 0.01
Sum of Series : 5.18738
```


---

Original Source: https://www.mindstick.com/forum/156831/can-you-tell-me-the-code-to-write-a-c-sharp-program

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
