Posts

write a program to add two number using pointer

  #include <stdio.h> int main () { int first , second , * p , * q , sum ; printf ( "Enter two integers to add\n" ); scanf ( "%d%d" , & first , & second ); p = & first ; q = & second ; sum = * p + * q ; printf ( "Sum of entered numbers = %d\n" , sum ); return 0 ; }

write a program to convert temperature Celsius to Fahrenheit and vice versa

  #include<stdio.h>   main  ( ) { float  temp_c ,  temp_f ;   printf   ( "Enter the value of Temperature in Celcius: " ) ;   scanf   ( "%f" ,   & temp_c ) ;   temp_f  =   ( 1.8   *  temp_c )   +   32 ;   printf   ( "The value of Temperature in Fahreinheit is: %f" ,  temp_f ) ;   }

write a program to convert character upper to lower and vice versa in C

  #include <stdio.h> #include <string.h> int main () {     char s [ 100 ];     int i ;    printf ( "\nEnter a string : " );    gets ( s );     for ( i = 0 ; s [ i ]!= '\0' ; i ++) {       if ( s [ i ] >= 'a' && s [ i ] <= 'z' ) {          s [ i ] = s [ i ] - 32 ;       }     }    printf ( "\nString in Upper Case = %s" , s );     return 0 ; }

write a program to print palindrome string

  #include <stdio.h> #include <string.h> int main(){ char string1[20]; int i, length; int flag = 0; printf("Enter a string:"); scanf("%s", string1); length = strlen(string1); for(i=0;i < length ;i++){ if(string1[i] != string1[length-i-1]){ flag = 1; break; } } if (flag) { printf("%s is not a palindrome", string1); } else { printf("%s is a palindrome", string1); } return 0; }

write a program to swap two matrix

  #include <stdio.h> int main () { int a [ 10 ], b [ 10 ], c [ 10 ], i ; printf ( "Enter First array->" ); for ( i = 0 ; i < 10 ; i ++) scanf ( "%d" ,& a [ i ]); printf ( "\nEnter Second array->" ); for ( i = 0 ; i < 10 ; i ++) scanf ( "%d" ,& b [ i ]); printf ( "Arrays before swapping" ); printf ( "\nFirst array->" ); for ( i = 0 ; i < 10 ; i ++) { printf ( "%d" , a [ i ]); } printf ( "\nSecond array->" ); for ( i = 0 ; i < 10 ; i ++) { printf ( "%d" , b [ i ]); } for ( i = 0 ; i < 10 ; i ++) { //write any swapping technique c [ i ]= a [ i ]; a [ i ]= b [ i ]; b [ i ]= c [ i ]; } printf ( "\nArrays after swapping" ); printf ( "\nFirst array->" ); for ( i = 0 ; i < 10 ; i ++) { printf ( "%d" , a [ i ]); } printf ( "\nSecond array->" ); ...

write a program to Mirror matrix

 #include<stdio.h> int main() {     int r,i,j;     printf("Enter number of rows:");     scanf("%d",&r);     int a[r][r];     printf("Enter %d matrix elements:\n",r*r);     for(i=0;i<r;i++)     {         for(j=0;j<r;j++)         scanf("%d",&a[i][j]);     }     printf("Matrix Elements:\n");     for(i=0;i<r;i++)     {         printf("\n");         for(j=0;j<r;j++)         {             printf("%d\t",a[i][j]);         }          }     printf("\nMirror Image of Matrix:\n");     for(i=0;i<r;i++)     {         printf("\n");         for(j=r-1;j>=0;j--)         {         ...

write a program to print transpose matrix in c

  #include <stdio.h> int main() {     int m,n;                 //Matrix Size Declaration     printf("Enter the number of rows and column: \n");     int arr[10][10];        //Matrix Size Declaration     printf("\nEnter the elements of the matrix: \n");     for(int i=0;i<m;i++)    //Matrix Initialization     {         for(int j=0;j<n;j++)         {             scanf("%d",&arr[i][j]);         }     }     printf("\nThe elements in the matrix are: \n");     for(int i=0;i<m;i++)     //Print the matrix     {         for(int j=0;j<n;j++)         {             printf("%d ",arr[i][j]);         }   ...