Wednesday, February 28, 2018

17 Saal - Kemzyy Official Song New Hindi Songs 2015 - HD video


Program To Convert Binary To Octal Number System.




/* C program to convert binary to octal number system */

#include <stdio.h>

int main()

{

int octalConstant[] = {0, 1, 10, 11, 100, 101, 110, 111};

long long binary, octal, tempBinary;

int digit, place, i;

octal = 0;

place= 1;

/* Input binary number from user */

printf("Enter any binary number: ");

scanf("%lld", &binary);

/* Copy original binary value to temp variable */

tempBinary = binary;

while(tempBinary != 0)

{

/* Extract last three digit of binary */

digit = tempBinary % 1000;

/* Find octal equivalent of 3 digit binary */

for(i=0; i<8; i++)

{

if(octalConstant[i] == digit)

{

/* Increase the place value of octal and add the previous octal value */

octal = (i * place) + octal;

break;

}

}

/* Remove the last three digit of binary */

tempBinary /= 1000;

/* Increase the place value */

place *= 10;

}

printf("Original binary number = %lld\n", binary);

printf("Octal number = %lld", octal);

return 0;

}

Output

Program To Convert Binary To Octal Number System.

Program To Convert From Decimal To Binary Number System.




/* C program to convert from Decimal to Binary number system */

#include <stdio.h>

int main()

{

long long decimal, tempDecimal, binary;

int rem, place = 1;

binary = 0;

/* Input decimal number from user */

printf("Enter any decimal number: ");

scanf("%lld", &decimal);

tempDecimal = decimal;

/* Decimal to binary conversion */

while(tempDecimal > 0)

{

rem = tempDecimal % 2;

binary = (rem * place) + binary;

tempDecimal /= 2;

place *= 10;

}

printf("Decimal number = %lld\n", decimal);

printf("Binary number = %lld", binary);

return 0;

}
OUTPUT
Program To Convert From Decimal To Binary Number System.

Program To Convert Binary Number System To Decimal Number System.




/* C program to convert binary number system to decimal number system */

#include <stdio.h>

#include <math.h>

int convertBinaryToDecimal(long long n);

int main()

{

long long n;

printf("Enter a binary number: ");

scanf("%lld", &n);

printf("%lld in binary = %d in decimal", n, convertBinaryToDecimal(n));

return 0;

}

int convertBinaryToDecimal(long long n)

{

int decimalNumber = 0, i = 0, remainder;

while (n!=0)

{

remainder = n%10;

n /= 10;

decimalNumber += remainder*pow(2,i);

++i;

}

return decimalNumber;

}
Output

Program To Convert Binary Number System To Decimal Number System.

Tuesday, February 27, 2018

3) Program for sin(), cos(), tan(), sinh(), cosh(), tanh(), log(), log10(), and exp() in C.


/* Program for Sin(),cos(),tan(),exp(), and Log() value */

#include <stdio.h>

#include <math.h>

int main()

{

float i = 0.314;

float j = 0.25;

float k = 6.25;

printf("\n Enter three Values to Find the sin(), cos(),tan(),sinh(),cosh(),tanh(),log(),log10(),exp(), Tangent Values :");

scanf("%f %f %f",&i, &j, &k);

float sin_value = sin(i);

float cos_value = cos(i);

float tan_value = tan(i);

float sinh_value = sinh(j);

float cosh_value = cosh(j);

float tanh_value = tanh(j);

float log_value = log(k);

float log10_value = log10(k);

float exp_value = exp(k);

printf("The value of sin(%f) : %f \n", i, sin_value);

printf("The value of cos(%f) : %f \n", i, cos_value);

printf("The value of tan(%f) : %f \n", i, tan_value);

printf("The value of sinh(%f) : %f \n", j, sinh_value);

printf("The value of cosh(%f) : %f \n", j, cosh_value);

printf("The value of tanh(%f) : %f \n", j, tanh_value);

printf("The value of log(%f) : %f \n", k, log_value);

printf("The value of log10(%f) : %f \n",k,log10_value);

printf("The value of exp(%f) : %f \n",k, exp_value);

return 0;

}
Output

Program for sin(), cos(), tan(), sinh(), cosh(), tanh(), log(), log10(), and exp() in C.


Sunday, February 25, 2018

C Program For Selection Sort.

C Program For Selection Sort.

/* program for Selection sort */2
#include <stdio.h>
int main()
{
int array[100], n, c, d, position, swap;
printf("Enter number of elements\n");
scanf("%d", &n);
printf("Enter %d
integers\n", n);
for ( c = 0 ; c < n ; c++ )
scanf("%d", &array[c]);
for ( c = 0 ; c < ( n - 1 ) ; c++ )
{
position = c;
for ( d = c + 1 ; d < n ; d++ )
{
if ( array[position] > array[d] )
position = d;
}
if ( position != c )
{
swap = array[c];
array[c] = array[position];
array[position] = swap;
}
}
printf("Sorted list in ascending order:\n");
for ( c = 0 ; c < n ; c++ )
printf("%d\n", array[c]);
return 0;
}

Output:-

Selection Sort

Saturday, February 17, 2018

Inverted Full Pyramid Using *

/* inverted full pyramid using * */

#include<stdio.h>

int main()

{

int rows, i, j, space;

printf("Enter number of rows: ");

scanf("%d",&rows);

for(i=rows; i>=1; --i)

{

for(space=0; space < rows-i; ++space)

printf("  ");

for(j=i; j <= 2*i-1; ++j)

printf("* ");

for(j=0; j < i-1; ++j)

printf("* ");

printf("\n");

}

return 0;

}

Output:-




 Inverted Full Pyramid Using *

 


Life Articles And News:

Life Articles And News: