Skip to main content

Posts

C program to convert a decimal number into binary number using function.

 C program to convert a decimal number into binary number using function.     In this example, we  convert the decimal number entered by the user into binary form. Here, in the out put we have taken a decimal number 20 whose binary  is printed as 10100. You can take other numbers such as 15, 13 78, etc... PROGRAM TO CONVERT A DECIMAL NUMBER INTO BINARY NUMBER USING FUNCTION. #include   <stdio.h> #include <conio.h> int  binary( int   b ); void  main() {      int  b;     printf( "\nEnter the Number You want to convert : " );     scanf( "%d" , &b);     binary(b);     getch(); } int  binary( int   b ) {      int  a[10], i, j;      for  (i = 0;  b  > 0; i++)     ...

C Program to print the PASCAL Triangle up to the Nth row where n is a value inputted by the user

 C Program to print the PASCAL Triangle up to the Nth row where n is a value inputted by the user.  .    In this example, we will print a Pascal's triangle upto to the value of the Nth row entered by the user. In the output section we have taken the value of n as 6 and the pascal's triangle is shown in the output. No, it is not that you have to take the value of n as 6, you can enter any value according to your choice. And the required pascal's tringle will be available on the screen.   What is Pascal's Triangle? Pascal's Triangle is a triangular arrangement of the binaomaial coefficients of the expansion (x+y) n  for positive integral values of n. PROGRAM  TO PRINT THE PASCAL TRIANGLE UP TO THE N-TH ROW WHERE N IS A VALUE INPUTTED BY THE USER: #include <stdio.h> #include <conio.h> void  main() {      int  n,coef=1,space,i,j;     printf( "Enter the value of n:" ); ...

C Program to print the first N even numbers in reverse order.

 C Program to print the first N even numbers in reverse order.      In this example, we will print the first N even numbers in reverse order. Here N is the total number of even numbers you want to print. PROGRAM TO PRINT THE FIRST N EVEN NUMBERS IN REVERSE ORDER: #include <stdio.h> #include <conio.h> int   main () {      int   even , n , i ;      printf ( "Enter the value of N : " );      scanf ( " %d " ,& n );      printf ( "Printing first  %d  even numbers in reverse order : " , n );      for ( i = n * 2 ; i > 2 ; i --)     {          if ( i % 2 == 0 )         {              printf ( " %d \t " , i );  ...

C program to Print the Digits of a Number in Words

 C program to Print the Digits of a Number in Words.      In this example, we will print the digits of a number in words.  For example, if a number 841 is entered through the keyboard  then the program must print “Eight Four One". For solving this first we have to reverse the number than by using switch statement we willl print the digits of the number in words.    PROGRAM TO PRINT THE DIGITS OF A NUMBER IN WORDS #include <stdio.h> #include <conio.h> void   main () {      int   n , num = 0 ;      printf ( "Enter the Number : " );      scanf ( " %d " ,& n );      while ( n != 0 )     {          num =( num * 10 )+( n % 10 );          n /= 10 ;     }      printf ( "Printing the...

C Program to find out the roots of a Quadratic Equation and also test for Real and Complex roots

 C Program to find out the roots of a Quadratic Equation  and also test for Real and Complex roots.       In this example, we will calculate the roots of the quadratic equation by testing for real and complex roots. We can test real and complex roots by checking these conditions : If b 2  −4 ac  < 0, then there are no real roots. If b 2  −4 ac  = 0, then both the roots are equal. If b 2  −4 ac  > 0, then roots are real and distinct.   PROGRAM TO FIND OUT THE ROOTS OF A QUADRATIC EQUATION. #include <stdio.h> #include <conio.h> #include <math.h> int   main () {      int   a , b , c , d ;      float   x , y ;      printf ( "Enter coefficient of x^2,x and constant : " );      scanf ( " %d   %d   %d " ,& a ,& b ,& c );      d = b * b ...

C Program to find Mean and Standard deviation(SD) for a set of n numbers using array.

 C Program to find Mean and Standard deviation(SD) for a set of n numbers using array.     In this example, we will calculate the mean and standard deviation for a set of n numbers entered by the user using array.    PROGRAM TO FIND THE MEAN AND STANDARD DEVIATION(SD) FOR A SET OF N NUMBERS USING ARRAY. #include <stdio.h> #include <math.h> #include <conio.h> void   main () {      int   n , i ;      float   x [ 50 ], mean , sd , sum ;      printf ( "How many numbers you want to enter : " );      scanf ( " %d " ,& n );      printf ( "Enter the numbers " );      for ( i = 0 ; i < n ; i ++)      {          scanf ( " %f " ,& x [ i ]);     }      f...