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 Outlook addin (Microsoft Office) developer Project Description: About us in a nutshell: We are a young start-up that buys a refreshing product in the field of ent

Finding Maximum & Minimum Numbers - C# Program I am facing some problems in the code for Finding Maximum & Minimum Numbers. Can anybody suggest me the proper code for it.

Automate installation setup Project Description: The steps are: Clicking four times accept and the setup goes to tray, I do not want to block the mouse or the keyboard. Sk

Project Description: I am seeking software that can do the subsequent: 1. Check position for a URL in Google, Bing, Yahoo. 2. Check position for a Youtube video in Youtube

Explain the WSDL. WSDL is a short form for Web Services Description Language, which is used to explain a Web service in terms of the messages that it forms and accepts. The WS

Need Report Generation in SQL / .NET Project Description: Prepare a report generation web page by pulling information from an SQL Database. Filter parameters per report :

finding greatest of n no''s in c#

We are seeking for online invoice OCR solution. That will help us to automate accounts payable function. User could be able to use the existing pdf file or scan a document, then

Explain the architecture of ADO.NET in brief. AD0.NET having of two fundamental components: The DataSet, which is disconnected from the data source and does not require to k

13579 3579 579 79 9 How to the logic in code. pls give me Ans.