Posts

Program to find the smallest number in an array of 10.

  // program to find smallest no. in array #include <stdio.h> #include <conio.h> int main () {     int arr [ 5 ] = { 22 , 54 , 3 , 6 , 9 };     int lenght = sizeof ( arr ) / sizeof ( arr [ 0 ]);     int min = arr [ 0 ];     int a = sizeof ( arr );     for ( int i = 0 ; i < lenght ; i ++ )     {         if ( arr [ i ] < min )         {             min = arr [ i ];         }     }     printf ( "Smallest element present in array is %d\n" , min );     return 0 ; } // Output Smallest element present in array is 3

If age of Ram, Shyam,Ajay are input through the key board , Write a program to determine the youngest of the three.

// program youngest of three . # include <stdio.h> int main (){     int ram , shyam , ajay ;     printf ( "Enter the age of Ram ,Shyam and Ajay:\n" );     scanf ( "%d%d%d" , & ram , & shyam , & ajay );     if ( ram < shyam )     {         if ( ram < ajay )         {             printf ( "Ram is youngest" );         }     }     if ( shyam < ram )     {         if ( shyam < ajay )         {             printf ( "Shyam is youngest" );         }     }     if ( ajay < ram )     {         if ( ajay < shyam )         {             printf ( "Ajay is youngest" );         }   ...

A five digit number is entered through the keyboard . write a program to obtain the reversed number and to determine whether the original and reversed numbers are equal or not.

  /*Program for  three  Digit number check wheater the original and reverse are equal or not.*/ #include <stdio.h> int main () {     int num , n1 , n2 , n3 , rev ;     printf ( "Enter the three digit number :" );     scanf ( "%d" , & num );     n3 = num % 10 ;     num = num / 10 ;     n2 = num % 10 ;     num = num / 10 ;     n1 = num % 10 ;     num = num / 10 ;     rev = n3 * 100 + n2 * 10 + n1 * 1 ;     printf ( "Please once again enter the same number:" );     scanf ( "%d" , & num );     printf ( "\n%d" , rev );     if ( rev == num )     {         printf ( "\nThe Original number and reversed number are equal.\n" );     }     else     {         printf ( "\nThe Original number and reversed number are not equal!\n" ); ...

program for to Interchange the number.

  // program for interchange contents.   #include <stdio.h> int main () {     int a = 5 , b = 6 , c = 7 ;     int temp ;     temp = a ;     a = b ;     b = c ;     c = temp ;     printf ( "a=%d,\tb=%d,\tc=%d" , a , b , c ); } /*Output*/ a=6, b=7, c=5

Write the program to receive Cartesian coordinate (x,y) of a point and convert them into polar coordinates (r,c)

/* program to convert Cartesian co-ordinate (x,y) into polar coordinates (r,c) */ #include <stdio.h> #include <math.h> int main () {     int x , y ;     float r , angle ;     printf ( "Enter the value of x and y:" );     scanf ( "%d%d" , & x , & y );     r = sqrt ( pow ( x , 2 ) + pow ( y , 2 ));     angle = atan ( y / x );     angle = angle * 180 / 3.14159265359 ;     printf ( "The coordinate of r,c is (%f,%f)" , r , angle );     return 0 ; } Enter the value of x and y:1 1 The coordinate of r,c is (1.414214,45.000000)  

If a five digit number is input through the keyboard the keyboard ,write a program to calculate the sum of its digits.

  /* program for sum of 5 digit Enter by the user */ #include <stdio.h> int main () {     int sum = 0 , num , i ;     printf ( "Enter the 5 digit number:" );     scanf ( "%d" , & num );     for ( i = 0 ; i < 5 ; i ++ ) //by using for loop     {         sum = sum + num % 10 ;         num = num / 10 ;             }       printf ( "The sum of the number Enter by the user is %d" , sum );     return 0 ; } //output Enter the 5 digit number:12345 The sum of the number Enter by the user is 15

Paper of size A0 has dimensions 1189 mm x 841 mm. each subsequent size A(n) is defined as A(n-1) cut in half parallel to its shorter sides. Thus paper of size A1 would have dimensions 841 mm x 594 mm. write a program to calculate and print paper sizes A0,A1,.....A8.

  // program to calculate the size of paper. #include <stdio.h> int main () {     int w = 841 , h = 1189 , i , temp ;     for ( i = 0 ; i <= 8 ; i ++ )     {         printf ( "A%d:%dmm x %dmm\n" , i , w , h );         temp = h ;         h = w ;         w = temp / 2 ;     }     return 0 ; } // output A0:841mm x 1189mm A1:594mm x 841mm A2:420mm x 594mm A3:297mm x 420mm A4:210mm x 297mm A5:148mm x 210mm A6:105mm x 148mm A7:74mm x 105mm A8:52mm x 74mm