C Program to reverse a given number
#include
#include
int main()
{
int num, rem, rev = 0;
printf("\nEnter any no to be
reversed : ");
scanf("%d", &num);
while (num >= 1)
{
rem = num
% 10;
rev = rev
* 10 + rem;
num = num
/ 10;
}
printf("\nReversed Number :
%d", rev);
return (0);
}
Output
Enter any no to be reversed : 123
Reversed Number : 321
C Program to calculate sum of 5 subjects and find percentage
#include
#include
int main()
{
int s1, s2, s3, s4, s5, sum,
total = 500;
float per;
printf("\nEnter marks of 5
subjects : ");
scanf("%d %d %d %d %d",
&s1, &s2, &s3, &s4, &s5);
sum = s1 + s2 + s3 + s4 + s5;
printf("\nSum : %d",
sum);
per = (sum * 100) / total;
printf("\nPercentage :
%f", per);
return (0);
}
Output
Enter marks of 5 subjects : 80 70 90 80 80
Sum : 400
Percentage : 80.00
C Program to find area and circumference of circle
#include
#include
int main()
{
int rad;
printf("\n Enter radius of circle:
");
scanf("%d",&rd);
area=PI*rad*rad;
printf("\n Area of circle:%f
,area");
ci=2*PI*rad;
printf("\n Circumference:%f",ci);
return(0);
}
Output
Enter radius
of a circle :1
Area of circle : 3.14
Circumference:6.28
C Program to Hide Mouse Pointer
#include
#include
#include
#include
void showmouseptr();
void hidemouseptr();
union regs i, o;
int main()
{
int count = 1, gdriver = detect, gmode;
initgraph(&gdriver, &gmode,
"c\\:tc\\bgi");
i.x.ax = 0;
int86(0x33, &i, &o);
if (o.x.ax == 0)
{
printf("ntmouse
support is unavailable !!");
}
else
{
showmouseptr();
while (count <= 10)
{
getch();
count++;
if (count
% 2 == 0)
hidemouseptr();
else
showmouseptr();
}
}
getch();
return 0;
}
void showmouseptr()
{
i.x.ax = 1;
int86(0x33, &i, &o);
}
void hidemouseptr()
{
i.x.ax = 2;
int86(0x33, &i, &o);
}
No comments:
Post a Comment