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
What is a fish bone diagram? Dr. Kaoru Ishikawa discovered the fishbone diagram. Therefore, it can be also known as Ishikawa diagram. The Fishbone diagram is an analysis dia

How can we connect to Microsoft Access, Foxpro , Oracle etc ? The Microsoft provides System.Data.OleDb namespace to communicate with the databases such as Oracle, scess  etc. I

What are advantages of using UML? As the name suggests the UNIFIED MODELING LANGUAGE, The Modeling has been around for years, not only in the software field but also in other t

Project Description: I am seeking some automated trading software for the given strategy, I am using Omnesys Nest trader Step 1: Buy one share at current market price (ex:

Virtual Webcam effects + Sourcecode + Setup + Nice User Interface Project Description: i want a similar webcam effects application which can apply effects to webcam feed. So

I am looking individuals who have company experience working on Jquery and Microsoft Technology ( MVC 4.5 ), who will take live online session and provide training through Team Vie

Describe the XmlWriter class. The XmlWriter class is used to write XML to a stream, a file, or a Textwriter object. This class works in a forward-only, non-cached manner. You c

What are the advantages of DLR? The various advantages provided by DLR are: Permits you to easily execute the dynamic languages to the .NET Framework. Gives dynamic featu

I have 10 domains which are presently parked, now I need a software/Bot which generate clicks on the ads placed on the website. These clicks which are generated should use proxy to

Calculating the Sum of Digits - C# Program Hi, Can any of you, tell me how can i calculate the sum of digits of a given number?