Question: Write an application named Sum200 that sums the integers from 1 through 200. Display the running total when the program is halfway complete (after the

Write an application named Sum200 that sums the integers from 1 through 200. Display the running total when the program is halfway complete (after the first 100 numbers), and at the end.

This is my code:

using System;

class Program

{

static void Main()

{

int i,j;

Console.WriteLine("Halfway through......");

int sum1=0,sum2=0;

for(i=1;i<100;i++){

sum1=sum1+i;

}

Console.WriteLine(" after 100 nymbers sum is {0}",sum1);

for(j=1;j<=200;j++){

sum2=sum2+j;

}

Console.WriteLine("The sum of integers 1 through 100 is {0}",sum2);

}

}

13)

//code for ques 13

using System;

class Program

{

static void Main()

{

int vowelsCount = 0,consCount = 0;

Console.WriteLine("Enter the word: ");

string strValue = Console.ReadLine();

for (int j = 0; j < strValue.Length; j++)

using System;

class Program

{

static void Main()

{

int i,j;

Console.WriteLine("Halfway through......");

int sum1=0,sum2=0;

for(i=1;i<100;i++){

sum1=sum1+i;

}

Console.WriteLine(" after 100 nymbers sum is {0}",sum1);

for(j=1;j<=200;j++){

sum2=sum2+j;

}

Console.WriteLine("The sum of integers 1 through 100 is {0}",sum2);

}

}

13)

//code for ques 13

using System;

class Program

{

static void Main()

{

int vowelsCount = 0,consCount = 0;

using static System.Console;

class Sum200

{

static void Main() {

int sum = 0;

for(int i = 1;i<=200;i++){

sum += i;

if(i==100){

WriteLine(sum);

}

}

WriteLine(sum);

}

}

Can someone help me there is something wrong with my output?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!