Sunday, 26 August 2012
Calculating Grand Total on Discount
22:51
No comments
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int a, b, c, d, e;
float total, discount, discountAmt, grandTotal;
printf("Enter the 1st amount : ");
scanf("%d",&a);
printf("Enter the 2nd amount : ");
scanf("%d",&b);
printf("Enter the 3rd amount : ");
scanf("%d",&c);
printf("Enter the 4th amount : ");
scanf("%d",&d);
printf("Enter the 5th amount : ");
scanf("%d",&e);
total = a+b+c+d+e;
printf("\n\nTotal = Rs. %.f",total);
if(total>5000)
{
discount = 5;
}
else
{
discount = 3;
}
printf("\n\nYou will get %.f discount.",discount);
discountAmt = ((float) discount/100) * total;
grandTotal = total - discountAmt;
printf("\n\nDiscount Amount = Rs. %.f",discountAmt);
printf("\n\Total Amount = Rs. %.f",grandTotal);
getch();
}
Convert Character to ASCII Code
21:42
22 comments
#include <stdio.h>
#include <conio.h>
void main()
{
char a;
clrscr();
printf("Enter a character : ");
scanf("%c",&a);
printf("ASCII code of %c is %u",a,a);
getch();
}
Wednesday, 22 August 2012
Greatest value between Three Numbers
06:32
No comments
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter the A number : ");
scanf("%d",&a);
printf("Enter the A number : ");
scanf("%d",&b);
printf("Enter the C number : ");
scanf("%d",&c);
if(a>b)
{
if(a>c)
{
printf("A is the greatest Number.");
}
}
else
{
if(b>c)
{
printf("B is the greatest Number.");
}
else
{
printf("C is the greatest Number.");
}
}
getch();
}
Greatest value between Two Numbers
01:58
No comments
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b;
clrscr();
printf("Enter the first number : ");
scanf("%d",&a);
printf("Enter the second number : ");
scanf("%d",&b);
if(a>b)
{
printf("A is greater than B\n");
}
else
{
printf("B is greater than A\n");
}
getch();
}
Sunday, 22 July 2012
Adding Numbers
00:23
No comments
#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,c;
printf("Enter two integer to add numbers :\n");
scanf("%d%d", &a,&b);
c = a + b;
printf("Sum of %d + %d = %d\n", a, b, c);
getch();
}
Sunday, 15 July 2012
Farenheight to Celcius Conversion
05:29
No comments
#include <stdio.h>
main()
{
int celcius;
printf("Farenheight Celcius\n------------------------\n");
for (celcius = 0; celcius <= 300; celcius = celcius + 20)
printf("%3d = %3d\n",celcius,((celcius-32)*5)/9);
}
Create 2x2 Table
04:33
No comments
#include <stdio.h>
#include <conio.h>
main()
{
int a,b;
a = 1;
b = 2;
for (a; a <= 10; a++)
{
printf("%d * %2d = %2d\n",b,a,(a*b));
}
getch();
}
Subscribe to:
Posts (Atom)










