You are on page 1of 2

1.

Write a C Program to accept two integer numbers and find their SUM, DIFF, PRODUCT, QUOTIENT

// C Program to accept two integer numbers and find their SUM, DIFF, PRODUCT, QUOTIENT
#include<stdio.h>
void main()
{
int num1, num2, sum=0, diff=0, product=0;
float quotient=0.0; OUTPUT:
clrscr(); Enter First Number
printf("Enter First Number\n"); 10
scanf("%d",&num1); Enter Second Number
printf("Enter Second Number\n"); 3
scanf("%d",&num2); Sum of 10 and 3 = 13
sum=num1+num2; Difference of 10 and 3 = 7
diff=num1-num2; Product of 10 and 3 = 30
product=num1*num2; Quotient of 10 and 3 = 3.333333
quotient=num1/num2;
printf("Sum of %d and %d = %d\n", num1, num2, sum);
printf("Difference of %d and %d = %d\n", num1, num2, diff);
printf("Product of %d and %d = %d\n", num1, num2, product);
printf("Quotient of %d and %d = %f\n", num1, num2, quotient);
getch();
}

_____________________________________________________________________________________

2. Write an algorithm and flowchart to find the total cost of a product given the rate per unit and quantity

//C Program to find the total cost of a product given the rate per unit and quantity
#include<stdio.h>
void main()
{
float rate, qty, cost=0.0; OUTPUT:
clsrscr(); Enter Quantity
printf("Enter Quantity\n",); 50
scanf("%f", &qty); Enter Rate per Unit
printf("Enter Rate per Unit\n",); 10.50
scanf("%f", &rate); Total Number of Quantity = 50.000000
cost=qty*rate; Rate per Unit = 10.500000
printf("Total Number of Quantity = %f", qty); Total Cost = 525.000000
printf("Rate per Unit = %f", rate);
printf("Total Cost = %f", cost);
getch();
}
_____________________________________________________________________________________

3. Write a C program accept the total time in seconds, find the number of Hours, Minutes and Seconds

//C program accept the total time in seconds, find the number of Hours, Minutes and Seconds
#include<stdio.h>
void main()
{
int sec, hr, min, rem; OUTPUT:
clrscr(); Enter the time in Seconds
printf("Enter the time in Seconds\n"); 3675
scanf("%d", &sec); Number of Hours= 1
min=sec/60; Number of Minutes= 1
sec=sec%60; Number of Seconds= 15
hr=min/60;
min=min%60;
printf("Number of Hours= %d\n",hr);
printf("Number of Minutes= %d\n",min);
printf("Number of Seconds= %d\n",sec);
getch();
}
4. Write a C Program to find the temperature in Celsius, given the Temperature in Fahrenheit

You might also like