Posts

Q: Consider a currency system in which there are note of seven denominations, namely, Rs. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100. if a sum of Rs. N is entered through the keyboard, write a program to compute the smallest number of notes that will combine to give Rs N.

#include <stdio.h> #include <math.h> int main() {     int x,a,b,c,d,e,f;         printf("enter total amount of money\n");     scanf("%d",&x);         /*floor fun is used to get significant value*/         a=floor(x/100);     b=floor((x%100)/50);     c=floor(((x%100)%50)/10);     d=floor((((x%100)%50)%10)/5);     e=floor(((((x%100)%50)%10)%5)/2);     f=floor(((((x%100)%50)%10)%5)%2);         printf("note of 100 = %d\nnote of 50 = %d\nnote of 10 = %d\nnote of 5 = %d\nnote of 2 =                                       %d\nnote of 1 = %d\n",a,b,c,d,e,f); return 0; } ----------------------------------------- output : enter total amount of mon...

Q: Two number are input through the keyboard into two two locations C and D. write a program to interchange the contents of C and D.

#include <stdio.h> int main() {     float C,D;    /*C and D are two variables*/         printf("enter value of C and D respectivly:");     scanf("%f%f",&C,&D);         /*steps to interchange value of two variables*/     C=C+D;     D=C-D;     C=C-D;         printf("value of C is %f\nvalue of D is %f\n",C,D);         return 0; } ----------------------------------------- output : enter value of C and D respectivly:5 4 value of C is 4.000000 value of D is 5.000000  

Q: If value of an angle is input through the keyboard, write a program to print all its Trigonometric ratios.

#include <stdio.h> #include <math.h> int main() {     float degree, radian;     float PI = 3.14159;     printf("Enter angle in degree\n");     scanf("%f",&degree);     radian = degree * (PI / 180.0);     printf("Sin(%f) = %f\n", degree, sin(radian));     printf("Cos(%f) = %f\n", degree, cos(radian));     printf("Tan(%f) = %f\n", degree, tan(radian));     printf("Cosec(%f) = %f\n", degree, 1/sin(radian));     printf("Sec(%f) = %f\n", degree, 1/cos(radian));     printf("Cot(%f) = %f\n", degree, 1/tan(radian));     return 0; } ----------------------------------------- output : Enter angle in degree 30 Sin(30.000000) = 0.500000 Cos(30.000000) = 0.866026 Tan(30.000000) = 0.577350 Cosec(30.000000) = 2.000001 Sec(30.000000) = 1.154700 Cot(30.000000) = 1.732052

Q: write a program to recive values of T and V and calculate wind chill factor (wcf).

formula to find wind chill factor :   wcf=35.74+0.6215*T+(0.4275*T-35.75)*pow(V,0.16) #include <stdio.h> #include <math.h> int main() {     float T, V, wcf; /* T is temp and V is velocity of air */         printf("enter value of temp T and velocity of air V\n");         scanf("%f%f",&T,&V);         wcf=35.74+0.6215*T+(0.4275*T-35.75)*pow(V,0.16);  /*formula to find wind chill factor*/         printf("wcf is %f",wcf); return 0; } ----------------------------------------- output : enter value of temp T and velocity of air V 50 23 wcf is 43.074802

Q: The Body Mass Index (BMI) is defined as ratio of the weight of a person (in kilograms) to the square of the height (in meters). Write a c program that receives weight and height, calculates the BMI, and reports the BMI category as per the following table:

Image
#include<stdio.h> #include<math.h>  /*this header file is used to include all predefined maths function*/ int main() {     /*Weight should be in Kilograms*/     /*Height should be in Meters*/     float weight, height, BMI;         printf("Enter the weight of person: ");     scanf("%f", &weight);     printf("Enter the height of person: ");     scanf("%f", &height);     /*BMI stands for Body Mass Index*/     BMI = weight/(pow(height, 2));    /*pow is a function that gives second value peresent in bracket is as power of first value of bracket*/     printf("\n\nThe BMI of person is: %f\n", BMI);     if (BMI>0 && BMI<=15)         printf("BMI Category is Starvation");     else if (BM...

Q: Write a c program, which will require the user to give value of hardness, carbon content and tensile strength of the steel under consideration and output the grade of the steel.

A certain grade of steel is graded according to the following conditions: Hardness must be greater than 50 Carbon content must be less than 0.7 Tensile strength must be greater than 5600 The grades are as follows: Grade is 10 if all three conditions are met Grade is 9 if conditions (i) and (ii) are met Grade is 8 if conditions (ii) and (iii) are met Grade is 7 if conditions (i) and (iii) are met Grade is 6 if and only one conditions is met Grade is 5 is none of the conditions are met #include<stdio.h> int main() {     /*h = Hardness of steel,cc = Carbon content,ts = Tensile strength*/     float h, cc, ts;     int h_f=0,  cc_f=0, ts_f=0;  /*here 0 represent False and one represent for True*/     int grade;     printf("Enter the value of Hardness: ");         scanf("%f", &h);         printf("Enter the value of Carbon Con...

Q: In digital world colors are specified in Red-Green-Blue (RGB) format, with values of R, G, B varying on an integer scale from 0 to 255. In print publishing the colors are mentioned in Cyan-Magenta-Yellow-Black (CMYK) format, with values of C, M, Y, and K varying on a real scale from 0.0 to 1.0. Write a c program that converts RGB color to CMYK color as per the following formulae.

Formulae : White = Max(Red/255, Green/255, Blue/255) Cyan = (White-Red/255)/(White) Magenta = (White-Green/255)/(White) Yellow = (White-Blue/255)/(White) Black = 1-White Note that of the RGB values are all 0, then the CMY values are all 0 and the K value is 1. #include<stdio.h> int main() {     float r, g, b, rf, gf, bf, max, w, c, y, m , k;         /*k stands for black*/     printf("Enter the value of Red(0 to 255): ");     scanf("%f", &r);     printf("Enter the value of Green(0 to 255): ");     scanf("%f", &g);     printf("Enter the value of Blue(0 to 255): ");     scanf("%f", &b);     rf = r/255;     gf = g/255;     bf = b/255;     printf("\nRed: %f\nGreen: %f\nBlue: %f\n", rf, gf, bf);     /*find maximum amoung all of them...