Friday, August 29, 2014

A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input through the keyboard in hundreds, find the total number of currency notes of each denomination the cashier will have to give to the with-drawer

1 comments

Code

#include<stdio.h>
int main()
{
float t,t1,t2,t3;
int m1,m2,m3;

printf("\nInput notes in hundreds");
scanf("%f",&t);
t3=t/100;
m3=t3;

t2=(t-m3*100.0)/50;
m2=t2;

t1=(t-(m3*100.0+m2*50.0))/10;
m1=t1;

printf("\n\nThe no of 100 notes is %d\nThe no of 50 notes is %d\nThe no of 10 notes is %d",m3,m2,m1);

printf ("\n\nPress any key to close.");
getch ();
return 0;
}

Output

cash handling c language

Read More..

The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle.

0 comments
Hint: 
        Area of rectangle = length * breadth
        Perimeter of a rectangle is the sum of the lengths of all the sides of the rectangle
        Area of a circle = 3.1415 * (radius)2 hint: (radius)2 = radius * radius
        Circumference of a circle = 3.1415 * diameter of a circle

Code

#include<stdio.h>
int main()
{
int a,b,area_r,area_c,peri_r,peri_c,r;
printf ("Enter length and width of rectangle: ");
scanf ("%d%d",&a,&b);

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

area_r = (a * b);
peri_r = ((2*a) + (2*b));

area_c = (3.14 * r * r);
peri_c = (3.14 * 2 * r);

printf ("\n\nArea of rectangle = %d",area_r);
printf ("\nPerimeter of rectabgle = %d",peri_r);

printf ("\n\nArea of the circle = %d",area_c);
printf ("\nCircumference of the circle = %d",peri_c);

printf ("\n\nPress any key to close.");

getch ();
return 0;
}

Output

finding area c language

Read More..

Create a program that prompts a user to input five integers. The program then displays the sum and average values of its integers

0 comments

Code

#include<stdio.h>
int main()
{
int a,b,c,d,e,avg,sum;

printf ("Enter five integers: ");
scanf ("%d%d%d%d%d",&a,&b,&c,&d,&e);

sum = (a+b+c+d+e);

avg = (sum / 5);

printf ("SUM = %d \n\n AVG = %d\n",sum,avg);

printf ("\nPress any key to close.");

getch ();
return 0;
}

Output

C program average

Read More..

If the marks obtained by a student in five different subjects are input through the keyboard, 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

1 comments

Code

#include<stdio.h>
int main ()
{
float a,b,c,d,e,f;
float g;

printf ("Enter marks of 1st subject: ");
scanf ("%f",&a);

printf ("Enter marks of 2nd subject: ");
scanf ("%f",&b);

printf ("Enter marks of 3rd subject: ");
scanf ("%f",&c);

printf ("Enter marks of 4th subject: ");
scanf ("%f",&d);

printf ("Enter marks of 5th subject: ");
scanf ("%f",&e);

f = ((a+b+c+d+e)/5);

g = ((a+b+c+d+e)/500)*100;

printf ("\nAggregate marks= %f",f);

printf ("\nPercentage= %f \%",g);

printf ("press any key to close.");

getch ();
return 0;
}

Output

aggregate marks c Language

Read More..

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

3 comments

Code

Hint: 1 km = 1000 meters, 1 meter = 3.28 feet, 1 foot = 12 inches, foot = 30 centimeters

#include<stdio.h>
int main()
{
int a,b,c,d,f;

printf ("Enter the distance (in km): ");
scanf ("%d",&a);

b = a * 1000;
c = b * 3.28;
d = c * 12;
f = d * 30;

printf ("\nDistance in meters = %d m",b);
printf ("\nDistance in feets = %d feet",c);
printf ("\nDistance in inches = %d inches",d);
printf ("\nDistance in centimeters= %d cm",f);

printf ("\n\npress any key to close.");

getch ();
return 0;
}

Output

distance conversion C Language

Read More..

Hassan’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

0 comments

Code

#include<stdio.h>
int main()
{
int a,c;

printf ("Enter Hassan's basic salary: ");
scanf ("%d",&a);

c = (a/100) * 60;

printf ("\nGross Salary= %d",c);

printf ("\n\npress any key to close.");

getch ();
return 0;
}

Output

gross salary C Language

Read More..

Write a program that asks the user to input a number. The program displays the square of that number

0 comments

Code

#include<stdio.h>
int main()
{
int a,c;

printf ("Enter value of a:");
scanf ("%d",&a);

c = a*a;

printf ("\n\nAnswer= %d",c);

printf ("\n\npress any key to close.");

getch ();
return 0;
}

Output

C Language digit's square

Read More..

Create a program that uses the formula (f = (a b)(x y)) to output the result. This time prompt the user for the values a, b, x, and y. Use appropriate variable names and naming conventions

0 comments

Code

#include<stdio.h>
int main ()
{
int a,b,x,y,f;

printf ("Enter value of a:");
scanf ("%d",&a);

printf ("Enter value of b:");
scanf ("%d",&b);

printf ("Enter value of x:");
scanf ("%d",&x);

printf ("Enter value of y:");
scanf ("%d",&y);

f = (a*b)*(x*y);

printf ("\n\nAnswer= %d",f);

printf ("\npress any key to close.");

getch ();
return 0;
}

Output


C Language using Variables
Read More..

Given a = 5, b = 1, x = 10, and y = 5, create a program that outputs the result of the formula f = (a b)(x y) using a single printf() function

0 comments

Code

#include<stdio.h>
int main()
{
int a = 5,b = 1,x = 10,y = 5,f;

f = (a*b)*(x*y);

printf ("\n\nAnswer= %d",f);

printf ("press any key to close.");

getch ();
return 0;
}

Output


C Language mathematical formula
Read More..

If a five-digit number is input through the keyboard, write a program to print the digits of that number in reverse order. For example if the number that is input is 54321 then the output should be displayed as 12345

0 comments

Code

#include<stdio.h>
int main()
{
int a,sum,r1,r2,r3,r4,a1,a2,a3,a4;

printf ("Enter five digit number: ");
scanf ("%d",&a);

r1 = a/10000;
a1 = a%10000;

r2 = a1/1000;
a2 = a1%1000;

r3 = a2/100;
a3 = a2%100;

r4 = a3/10;
a4 = a3%10;

printf ("\nReverse Order = %d%d%d%d%d",a4,r4,r3,r2,r1);

printf ("\n\nPress any key to close.");

getch ();
return 0;
}

Output

reverse number c language

Read More..

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact