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
Explain Windows authentication Schemes There are four parts of windows authentication I. Integrated Windows authentication II. Basic and basic with SSL authentication

Program of addition of byte type variables - C# Program Program of addition of byte type variables, i need program code for performing addition of byte type variables. Can any

Finding the EOQ and TBO - C# Program: Need summer assignment help on c#.

What is Extensible Markup Language (XML). XML is an easy and flexible mark-up language in the text format. Nowadays, it is widely used to exchange a large variety of data over

What is a Hash Table? You can access an array using the INDEX value of that array, but how many times you know the real value of the index. The Hashtable provides a way of acce

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

.NET aplication with vBulletin paid subscribtion Project Description: I have an application in .net it's a simple client i have sheltered with net seal license system for aut

Perform Arithmetic operations on Floating Values - C# Program Hello, I've been trying so many codes for this but those codes didn't work well. Please write the code for Perfor

What is the Append Format for FileUpload Control in ASP.Net? What it specify?

Project Description: The website should be CMS based; coding done only on ASP, MySql databases, .net script, aspx and java use with least of the flash work. We will be sharing j