Results 1 to 4 of 4

Thread: What is the Program to calculate the percentage?

  1. #1
    Join Date
    Nov 2009
    Posts
    1,269

    What is the Program to calculate the percentage?

    Hi,

    I have to code the program, which will calculate the percentage of the given marks. I have tried this program but getting wrong answer because my poor programing logic.

    Anyone has the program in any language to find out the percentage?

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: What is the Program to calculate the percentage?

    Hi friends,

    Please copy the below program code and try to run on your system, the output of the below code shows the percentage of the three numbers:


    #include<conio.h>
    #include<stdio.h>

    void main()
    {

    float avgdemo(int a1,int a2,int a3);
    clrscr();

    printf ("percentage of 3 mark of subject : %.2f",avgdemo(88,87,75));

    getch();
    }
    float avgdemo(int a1,int a2,int a3)
    {
    return (a1+a2+a3)/3;
    }

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    Re: What is the Program to calculate the percentage?

    Hi,

    I suggest to use "avg function" of the c programming to calculate the percentage of the given program. But this "avg function" is applicable only if the given marks are out of hundred. see below:

    float functionName (int num1,int num2,int num3,int num4)
    {
    float z = (num1+num2+num3+num4)/4;

    return z;
    }

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: What is the Program to calculate the percentage?

    Hi

    I found this below code book in one of the "C" book. I tried to execute this program, and the program is running successfully without any error.

    Program code:
    main()
    {

    int x,y,z;

    float abc(x, y, z);

    printf("\nPercentag= %.2f", abc(50,56,89));

    getch();

    }

    abc(int x,int y,int z)
    {

    int d= (m1+m2+m3)/3;
    return d

    }

Similar Threads

  1. C Program - Percentage using pointer
    By syabab33 in forum Software Development
    Replies: 1
    Last Post: 08-05-2012, 11:42 PM
  2. Replies: 2
    Last Post: 23-02-2012, 04:57 PM
  3. Program : How to calculate the median in C++?
    By UseME in forum Software Development
    Replies: 3
    Last Post: 19-01-2010, 12:08 PM
  4. Calculate Average in C program
    By BoanHed in forum Software Development
    Replies: 3
    Last Post: 30-10-2009, 11:40 AM
  5. Calculate grade based on percentage
    By Adel123 in forum Software Development
    Replies: 2
    Last Post: 01-09-2009, 04:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,584,057.06555 seconds with 17 queries