Pages - Menu

Pages

Friday, 31 August 2012

Calculating Percentage & Grade


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

void main()
{
        int sub1, sub2, sub3, sub4, sub5;
        float total, percentage;

        clrscr();

        printf("\n\n\n***Program to Calculate Grade***\n\n\n");

        printf("Enter the obtained marks of Subject 1 : ");
        scanf("%d",&sub1);

        printf("Enter the obtained marks of Subject 2 : ");
        scanf("%d",&sub2);

        printf("Enter the obtained marks of Subject 3 : ");
        scanf("%d",&sub3);

        printf("Enter the obtained marks of Subject 4 : ");
        scanf("%d",&sub4);

        printf("Enter the obtained marks of Subject 5 : ");
        scanf("%d",&sub5);

        total = sub1+sub2+sub3+sub4+sub5;
        percentage = ((float)total/500)*100;

        printf("\n\nYour Total marks is %.f",total);
        printf("\nYour Percentage is %.2f",percentage);

        if(percentage>40)
        {
                if(percentage>60)
                {
                        if(percentage>80)
                        {
                                printf("\nYour Grade is A.");
                        }
                        else
                        {
                                printf("\nYour Grade is B.");
                        }
                }
                else
                {
                        printf("\nYour Grade is C.");
                }
        }
        else
        {
                printf("\n\nHome Guidance is necessary.");
        }

        getch();
}

Sunday, 26 August 2012

Calculating Grand Total on Discount


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

void main()
{
                clrscr();

                int a, b, c, d, e;
                float total, discount, discountAmt, grandTotal;

                printf("Enter the 1st amount : ");
                scanf("%d",&a);

                printf("Enter the 2nd amount : ");
                scanf("%d",&b);

                printf("Enter the 3rd amount : ");
                scanf("%d",&c);

                printf("Enter the 4th amount : ");
                scanf("%d",&d);

                printf("Enter the 5th amount : ");
                scanf("%d",&e);

                total = a+b+c+d+e;

                printf("\n\nTotal = Rs. %.f",total);

                if(total>5000)
                {
                                discount = 5;
                }
                else
                {
                                discount = 3;
                }

                printf("\n\nYou will get %.f discount.",discount);

                discountAmt = ((float) discount/100) * total;

                grandTotal = total - discountAmt;

                printf("\n\nDiscount Amount = Rs. %.f",discountAmt);

                printf("\n\Total Amount =  Rs. %.f",grandTotal);

                getch();
}

Convert Character to ASCII Code


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

void main()
{
                char a;
                clrscr();

                printf("Enter a character : ");
                scanf("%c",&a);

                printf("ASCII code of %c is %u",a,a);

                getch();
}

Wednesday, 22 August 2012

Greatest value between Three Numbers


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

void main()
{
                int a,b,c;
                clrscr();

                printf("Enter the A number : ");
                scanf("%d",&a);

                printf("Enter the A number : ");
                scanf("%d",&b);

                printf("Enter the C number : ");
                scanf("%d",&c);

                if(a>b)
                {
                                if(a>c)
                                {
                                                printf("A is the greatest Number.");
                                }
                }
                else
                {
                                if(b>c)
                                {
                                                printf("B is the greatest Number.");
                                }
                                else
                                {
                                                printf("C is the greatest Number.");
                                }
                }
                getch();
}