Thursday, 26 June 2025

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 2

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 2

 

Q: (d) Write a program to receive Cartesian co-ordinates (x, y) of a point and convert them into polar co-ordinates (r, ). Hint: r = sqrt ( x2 + y2 ) and  𝝫 = tan-1 ( y / x )


#include <stdio.h>

#include<math.h>

int main()

{

    double x,y,r,p;

    printf("Enter Cartesian Co-ordinates x,y :\n");

    scanf("%lf%lf", &x,&y);

    r=sqrt(x*x+y*y);

    p=atan(y/x);

    printf("Polar Co-ordinates are ( %lf , %lf )",r,p);

    return 0;

}



Download Source Code


C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 2

 Q: (c) If lengths of three sides of a triangle are input through the keyboard, write a program to find the area of the triangle.


#include <stdio.h>

#include<math.h>

int main()

{

    double a, b, c, s, area;

    printf("Enter the length of side a:\n");

    scanf("%lf", &a);

    printf("Enter the length of side b:\n");

    scanf("%lf", &b);

    printf("Enter the length of side c:\n");

    scanf("%lf", &c);

    s = (a + b + c) / 2;

    area = sqrt(s * (s - a) * (s - b) * (s - c));

    printf("The area of the triangle is: %lf", area);

    return 0;

}






Download Source Code

Wednesday, 25 June 2025

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 2

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 2

Q:(b)If a five-digit number is input through the keyboard, write a 

program to reverse the number.

#include <stdio.h>


int main()

{

    long int n;

    int s=0,r;

    printf("Enter Number\n");

    scanf("%ld",&n);

    while(n>0)

    {

        r=n%10;

        s=s*10+r;

        n=n/10;

    }

    printf("Reverse of Number is %d",s);

    return 0;

}





 







Download Source Code

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 2

 

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 2


Q: (a) If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’)


#include <stdio.h>
int main()
{
    long int n;
    int s=0,r;
    printf("Enter Number\n");
    scanf("%ld",&n);
    while(n>0)
    {
        r=n%10;
        s=s+r;
        n=n/10;
    }
    printf("Sum of Digits is %d",s);
    return 0;
}


C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 1

 Q:(f) Paper of size A0 has dimensions 1189 mm x 841 mm. Each subsequent size A(n) is defined as A(n-1) cut in half parallel to its shorter sides. Thus paper of size A1 would have dimensions 841 mm x 594 mm. Write a program to calculate and print paper sizes A0, A1, A2, … A8.

#include <stdio.h>

int main()

{

    double a[9][2]={{1189,841}};

    int i,j;

    for(i=1;i<=8;i++)

    {

        for(j=0;j<=0;j++)

        {

            if(a[i-1][j]>a[i-1][j+1])

            {

                a[i][j+1]=a[i-1][j]/2;

                a[i][j]=a[i-1][j+1];

            }

            else

            {

                a[i][j+1]=a[i-1][j+1]/2;

                a[i][j]=a[i-1][j];


            }

        }

    }

    for(i=0;i<=8;i++)

    {

        for(j=0;j<=1;j++)

        {

            printf("%lf\t",a[i][j]);

        }

        printf("\n");

    }

    return 0;

}







Tuesday, 24 June 2025

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 1

Q: (e) 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 the rectangle, and the area and circumference of the circle.


#include <stdio.h>

int main()

{

    double l,b,arearec,perirec,r,areacir,circumcir;

    printf("Enter Length & Breadth of Rectangle\n");

    scanf("%lf%lf",&l,&b);

    printf("Enter Radius of Circle\n");

    scanf("%lf",&r);

    arearec=l*b;

    perirec=2*(l+b);

    areacir=3.14*r*r;

    circumcir=2*3.14*r;

    printf("Area of Rectangle is %lf\n",arearec);

    printf("Perimeter of Rectangle is %lf\n",perirec);

    printf("Area of Circle is %lf\n",areacir);

    printf("Circumference of Circle is %lf\n",circumcir);

    return 0;

}



Download Source Code

Page : 1 2 3 4 5

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 1

 Q: (d) Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into Centigrade degrees.

#include <stdio.h>

int main()

{

    double f, c;

    printf("Enter temperature in Fahrenheit: ");

    scanf("%lf", &f);

    c=(f - 32) * 5.0 / 9.0;

    printf("%lf Fahrenheit is equal to %lf Celsius\n", f, c);

    return 0;

}



Download Source Code

Page : 1 2 3 4 5

Tuesday, 17 June 2025

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 1

Q: (c) If the marks obtained by a student in five different subjects are input through the 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 in each subject is 100.

/*Q: (c) If the marks obtained by a student in five different subjects are input through the 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 in each subject is 100.*/



#include<stdio.h>

#include<conio.h>

void main()

{

double m1,m2,m3,m4,m5,tot,per;

clrscr();

printf("Enter Marks in 5 Subjects out of 100 each\n");

printf("Enter Marks in Subject 1\n");

scanf("%lf",&m1);

printf("Enter Marks in Subject 2\n");

scanf("%lf",&m2);

printf("Enter Marks in Subject 3\n");

scanf("%lf",&m3);

printf("Enter Marks in Subject 4\n");

scanf("%lf",&m4);

printf("Enter Marks in Subject 5\n");

scanf("%lf",&m5);

tot=m1+m2+m3+m4+m5;

per=tot/5;

printf("Total Marks = %lf\n",tot);

printf("Percentage = %lf",per);

getch();

}






Page : 1 2 3 4 5

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 1

 Q: (b) The distance between two cities (in km.) is input through the keyboard. Write a program to convert and print this distance in meters, feet, inches and centimeters.


/*Q: (b) The distance between two cities (in km.) is input through the keyboard.

Write a program to convert and print this distance in meters, feet, inches and centimeters.*/

#include<stdio.h>

#include<conio.h>

void main()

{

double dkm,dm,dcm,dft,din;

clrscr();

printf("Enter Distance in KM");

scanf("%lf",&dkm);

dm=dkm*1000;

dcm=dm*100;

din=dcm*0.3937;

dft=dcm*0.0328;

printf("Distance in CM = %lf\n",dcm);

printf("Distance in Inches = %lf\n",din);

printf("Distance in Feet = %lf\n",dft);

printf("Distance in Meter = %lf",dm);

getch();

}









Download Source Code


Page : 1 2 3 4 5


Sunday, 15 June 2025

C Programming Solved Problems Let us C Yashwant Kanitkar Chapter 1

 Q: (a) Ramesh’s basic salary is input through the keyboard. His dearness 

allowance is 40% of basic salary, and house rent allowance is 20% of 

basic salary. Write a program to calculate his gross salary.

Solution:

/*(a) Ramesh’s basic salary is input through the keyboard. His dearness 

allowance is 40% of basic salary, and house rent allowance is 20% of 

basic salary. Write a program to calculate his gross salary.*/

#include<stdio.h>

#include<conio.h>

void main()

{

double b_sal,da,hra,g_sal;

clrscr();

printf("Enter basic salary");

scanf("%lf",&b_sal);

hra=0.20*b_sal;//House Rent Allowance

da=0.40*b_sal;//Dearness Allowance

g_sal=b_sal+da+hra;//Gross Salary

printf("Gross Salary = %lf",g_sal);

getch();

}

Output:



Download Source Code

Page : 1 2 3 4 5