Decision making and branching - c# program, DOT NET Programming

Decision Making and Branching - C# Program

Need Programming help on Decision Making and Branching in C#.

Posted Date: 2/11/2013 7:45:43 AM | Location : United States





This program will help you, try it out

using System;  

class SumOfOdds

{

  public static void Main()

 {

   int x=0, sumodd=0, sumeven=0, sumdiv7 = 0 ,totalno7 = 0, i;    

   for (i=0 ; i<=20 ; i++)

  {

   x = i % 2;

    if (x != 0)

   {

    sumodd = sumodd + i;

   }

    if (x == 0)

   {

    sumeven = sumeven + i;

   }

  }  

   //checking for the sum & no. of numbers divisible by 7    

  x = 0; // resetting the value of ''x''

   for (i=100; i<=200;i++)

  {

   x = i % 7;

    if (x == 0)

   {

    sumdiv7 = sumdiv7 + i;

    totalno7 = totalno7 + 1;

   }   

}     

  Console.WriteLine("Sum of all odd numbers from 1 - 20 = " + sumodd + "\n");

  Console.WriteLine("Sum of all even numbers from 1 - 20 = " + sumeven + "\n");

  Console.WriteLine("Sum of all numbers from 100 - 200, divisible by 7 = " +

sumdiv7 + "\n");

  Console.WriteLine("Total numbers from 100 - 200, divisible by 7  = " + totalno7 + "\n");

   Console.ReadLine();

 }

}

Posted by james | Posted Date: 2/11/2013 7:47:08 AM

Hey John i have the ouput of above program:

Output:
Sum of all odd numbers from 1 - 20 = 100
Sum of all even numbers from 1 - 20 = 110
Sum of all numbers from 100 - 200, divisible by 7 = 2107
Total numbers from 100 - 200, divisible by 7  = 14.

Posted by | Posted Date: 2/11/2013 7:48:14 AM


Related Discussions:- Decision making and branching - c# program, Assignment Help, Ask Question on Decision making and branching - c# program, Get Answer, Expert's Help, Decision making and branching - c# program Discussions

Write discussion on Decision making and branching - c# program
Your posts are moderated
Related Questions
Experienced Microsoft .NET web developer I have a various projects for which I need a web developer for. The developer will be the sole product owner hence should be dependab

Describe IUKNOWN interface All COM object supports atleast one interface, that is  IUnknown interface. All interfaces are the classes, derived from the base class IUnknown. Eve

Webpage builder windows application + source code + installer + user friendly interface. Project Description: Website Builder As its name suggests, the site builder should

I want a C# school project Project Description: The project is made in C# and haves a database connection. We have some small problems asking up data from the database.

What is a class? A class describes all the attributes of objects, as well as the methods that execute the behaviour of member objects. It is a comprehensive data type, which sh

Project Description: We are looking for same usability/options of coachup.com thus, we will have different own UI design. Conditions: State your price and please describe/

A CRM based on .net and Oracle as backend with import data, Transaction Reporting and management Capabilities Project Description: 1. Introduction ADA recovery Branch gets

Calculate Standard Deviation - C# Program Hello i am unable to find the code for Calculate Standard Deviation in c#. Can anybody please provide me the assignment help?

What is the use of DISPOSE method? This Dispose method belongs to the IDisposable interface. It is bad  to override the finalize method for writing the cleaning of the unmanage

What are the methods provided by the command object? The command objects used to connect the connection object to the Datareader or the dataset. The command object provided som