Starting Programming on C

  1. Calculation of Simple interest 
    #include<stdio.h>
    int main(){
    int p,n;
    float r,si;

    printf("Enter principal:");
    scanf("%d",&p);
    printf("Enter Rate:");
    scanf("%f",&r);
    printf("Enter time:");
    scanf("%d",&n);

    si=(p*n*r)/100;

    printf("Interest is:%f",si);


    return 0;
    }







  2.  Ramesh's basic salary is input through the keyboard. His dearness allowance is 40% of basic salary and rent allowance is 20% of his basic salary. Write a basic program to calculate his Gross Salary.
    #include<stdio.h>
    int main(){
    int basic_salary, house_rent_allowance,dearness_allowance, gross_salary;

    printf("Enter Basic Salary:");
    scanf("%d",&basic_salary);

    dearness_allowance=basic_salary*40/100;
    house_rent_allowance=basic_salary*20/100;
    gross_salary=basic_salary+dearness_allowance+house_rent_allowance;

    printf("His Dearness allowance is :%d\n",dearness_allowance);
    printf("His House Rent allowance is :%d\n",house_rent_allowance);
    printf("His Gross Salary is :%d\n",gross_salary);

    return 0;
    }




  3. The Distance between two cities (in Km) is input through the keyboard. Write a program to convert and print this distance in meters, feet, inch and centimeter.
    #include<stdio.h>
    int main(){
        int distance,m,f, i,cm;
    printf("Enter Distance between two Cities (in KM):");
    scanf("%d",&distance);
    m=distance*1000;
    f=distance*3280.84;
    i=distance*39370.1;
    cm=distance*100000;

    printf("Distance in Meter:%d meter\n",m);
    printf("Distance in Feet:%d feet\n",f);
    printf("Distance in Inch:%d inch\n",i);
    printf("Distance in CM:%d Centimeter\n",cm);


    return 0;
    }





  4.  If the marks obtained by a student in five different subjects are input through keyboard, write a program to find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student.
    #include<stdio.h>
    int main(){
        int sub1,sub2,sub3,sub4,sub5,total,percentage;
    printf("Enter Marks for Subject1:");
    scanf("%d",&sub1);
    printf("Enter Marks for Subject2:");
    scanf("%d",&sub2);
    printf("Enter Marks for Subject3:");
    scanf("%d",&sub3);
    printf("Enter Marks for Subject4:");
    scanf("%d",&sub4);
    printf("Enter Marks for Subject5:");
    scanf("%d",&sub5);
    total=sub1+sub2+sub3+sub4+sub5;
    percentage=1.00*total/500*100; /*Converting it into integer to float*/

    printf("Total Marks:%d\n",total);
    printf("Percentage:%d\n",percentage);




    return 0;
    }





  5. Temperature of a city in Centigrade  degree is input through the keyboard. Write a a program to convert this temperature into Fahrenheit.

    #include<stdio.h>
    int main(){
    int deg,fah;
    printf("Enter temperature in degree:");
    scanf("%d",&deg);

    fah=1.0*(deg*9/5)+32;
    printf("Fahrenheit degree:%d",fah);
    return 0;
    }











  6. The length and breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area and perimeter of a rectangle.
    #include<stdio.h>
    #include<math.h>
    int const pi=22/7;
    int main(){
    int length,breadth,radius,area1, area2;
    printf("Enter length and breadth of rectangle:");
    scanf("%d%d",&length,&breadth);

    printf("Enter radius of Circle:");
    scanf("%d",&radius);

    area1=length*breadth;
    area2= pi*pow(pi,2);

    printf("Area of Rectangle:%d\n",area1);
    printf("Area of Circle:%d",area2);


    return 0;
    }






0 Comments had been done yet:

Post a Comment