66. Program to find power of number.
#include<stdio.h>
#include<conio.h>
void main()
{
int base, expo;
int value = 1;
clrscr();
printf("Enter base number : ");
scanf("%d", &base);
printf("Enter exponent number : ");
scanf("%d", &expo);
while (expo != 0)
{
// value = value * base;
value *= base;
--expo;
}
printf("Answer : %d", value);
getch();
}
67. Program to calculate HCF & LCM.
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, x, y, t, hcf, lcm;
clrscr();
printf("Enter two numbers : ");
scanf("%d%d", &x, &y);
a = x;
b = y;
while (b != 0)
{
t = b;
b = a % b;
a = t;
}
hcf = a;
lcm = (x * y) / hcf;
printf("\nHighest Common Factor of %d and %d : %d", x, y, hcf);
printf("\nLeast Common Multiple of %d and %d : %d", x, y, lcm);
getch();
}
68. Program to find largest among 3 numbers using ternary operator.
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c, big;
clrscr();
printf("Enter 3 numbers : ");
scanf("%d %d %d", &a, &b, &c);
big = (a > b && a > c ? a : b > c ? b : c);
printf("\nThe biggest number is : %d", big);
getch();
}
69. Program to find largest number of 'n' numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, num, i;
int big;
clrscr();
printf("Enter total numbers : ");
scanf("%d", &n);
printf("Number %d : ", 1);
scanf("%d", &big);
for (i = 2; i <= n; i++)
{
printf("Number %d : ", i);
scanf("%d", &num);
if (big < num)
big = num;
}
printf("Largest number is : %d", big);
getch();
}
70. Program to check whether the number is neon number or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, sq, i, sum = 0;
clrscr();
printf("Enter the number : ");
scanf("%d", &n);
sq = n * n;
for (i = sq; i > 0; i = i / 10)
sum = sum + i % 10;
if (sum == n)
printf("%d is a neon number.", n);
else
printf("%d is not a neon number.", n);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int base, expo;
int value = 1;
clrscr();
printf("Enter base number : ");
scanf("%d", &base);
printf("Enter exponent number : ");
scanf("%d", &expo);
while (expo != 0)
{
// value = value * base;
value *= base;
--expo;
}
printf("Answer : %d", value);
getch();
}
67. Program to calculate HCF & LCM.
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, x, y, t, hcf, lcm;
clrscr();
printf("Enter two numbers : ");
scanf("%d%d", &x, &y);
a = x;
b = y;
while (b != 0)
{
t = b;
b = a % b;
a = t;
}
hcf = a;
lcm = (x * y) / hcf;
printf("\nHighest Common Factor of %d and %d : %d", x, y, hcf);
printf("\nLeast Common Multiple of %d and %d : %d", x, y, lcm);
getch();
}
68. Program to find largest among 3 numbers using ternary operator.
#include<stdio.h>
#include<conio.h>
void main()
{
int a, b, c, big;
clrscr();
printf("Enter 3 numbers : ");
scanf("%d %d %d", &a, &b, &c);
big = (a > b && a > c ? a : b > c ? b : c);
printf("\nThe biggest number is : %d", big);
getch();
}
69. Program to find largest number of 'n' numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, num, i;
int big;
clrscr();
printf("Enter total numbers : ");
scanf("%d", &n);
printf("Number %d : ", 1);
scanf("%d", &big);
for (i = 2; i <= n; i++)
{
printf("Number %d : ", i);
scanf("%d", &num);
if (big < num)
big = num;
}
printf("Largest number is : %d", big);
getch();
}
70. Program to check whether the number is neon number or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int n, sq, i, sum = 0;
clrscr();
printf("Enter the number : ");
scanf("%d", &n);
sq = n * n;
for (i = sq; i > 0; i = i / 10)
sum = sum + i % 10;
if (sum == n)
printf("%d is a neon number.", n);
else
printf("%d is not a neon number.", n);
getch();
}
0 comments:
Post a Comment