Pages

Using C# Console write a program, which takes marks of subject from the user and calculate Sum, average and percentage .


CODE:

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            int physicsno, Mathematicsno, englishno, islamiatno, urduno, sum, avg, percentage;
            Console.WriteLine("enter your physics no");
            physicsno = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter your Mathematics no");
            Mathematicsno = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter your english no");
            englishno = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter your islamiat no");
            islamiatno = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter your urdu no");
            urduno = Convert.ToInt32(Console.ReadLine());
            sum = physicsno + Mathematicsno + englishno + islamiatno + urduno;
            Console.WriteLine("the obtain marks is {0}", sum);
            avg = sum / 5;
            Console.WriteLine("the avg is {0}", avg);
            percentage= sum*100/500;
            Console.WriteLine("the percentage is {0}", percentage);
        }
    }

}

OUTPUT:

ALGORITHM:

  • ·         Start,
  • ·         Initializing:intPhysicno, Mathematicsno, Englishno, islamiatno, urduno, Sum, avg, percentage.
  • ·         Output:enter your Physics no
  • ·         Set Physicno: Taking inputfrom user
  • ·         Output: enter your Mathematics no
  • ·         Set  Mathematicsno: Taking Input from user
  • ·         Output: enter your English no
  • ·         Set Englishno: Taking input from the user
  • ·         Output: enter your islamiatno
  • ·         Set islamiatno: Taking input from the user
  • ·         Output: enter your urduno
  • ·         Set urduno: Taking input from the user
  • ·         Set  Sum= Physicno + Mathematicsno + Englishno + islamiatno + urduno
  • ·         Output = sum(total marks gained in each subject)
  • ·         Set avg: Sum/6
  • ·         Output: Avg of gained marks
  • ·         Set Percentage: (Sum/600)*100
  • ·         Output: Percentage of gained marks
  • ·         End.

No comments:

Post a Comment