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
Locate BUG website Project Description: Can you find a bug in easports fifa 14 ultimate team web app (easports/fifa/football-club/ultimate-team) so that i will earn a lot of

Explain Forms authentication You, as a Web application developer, are supposed to increase the Web page and authenticate the user by checking the given user ID and password aga

Ask queyuyuystion #Minimum 100 words accepted#

Set up a FTP File Server and active FTP File Transfer using VB.NET The Job Description is as given: 1. Manually set up a FTP file server on a remote server. 2. Manually ad

I need Remote chat Application for desktop Project Description: I want a team of .net experts who will design me a website and a remote desktop chat application as like  live

what is the code for calculator in windowsapplication

VB. Net & XML 1. Design a form based applications using labels, text boxes, and buttons to perform basic arithmetic operations on integers. 2. Explain the concept of Excepti

What are Attributes?  Attributes are declarative tags in code that insert additional metadata into an assembly. There exist two types of attributes in the .NET Framework: Prede

What is XSLT? The XSLT is a rule based language used to transform XML documents into other file formats. The XSLT are nothing but generic transformation rules which can be appl

How can we use Culture Auto in project? We will make a very simple login screen which we will try to use for English as well as the Greek. The login screen will display Engl