0

Swapping two variables without and with using third variable.

C programming

#include<stdio.h> #include<conio.h> void swap1(int,int); void swap2(int,int); void main() { int a,b; clrscr(); printf(“Enter the values for a & b respectively:”); scanf(“%d%d”,&a,&b); swap1(a,b); swap2(a,b); getch(); } void swap1(int a,int b) {int c; printf(“\n Swap using third variable:”); c=a; a=b; b=c; printf(“\n… Continue Reading

0

C program to check palindrome.

C programming

#include<stdio.h>#include<conio.h>void main(){char str[10];int len,flag,i,j;clrscr();printf(“Enter a string:”);scanf(“%s”,str);len=strlen(str);for(i=0,j=len;i<=len,j>=0;i++,j–){if(str[i]==str[j])flag=1;else{flag=0; break; }}if(flag==1)printf(“PALINDROME!!”);elseprintf(“NOT A PALINDROME!!”);getch();} So lets have an explanation of the code. first of all what is palindrome palindrome is a string that remain same when reversed. so here in the program we are… Continue Reading

0

C program to find maximum number in an array.

C programming

#include<stdio.h>#include<conio.h>void main(){int i,max,a[5];clrscr();printf(“Enter elements of array:”);for(i=0;i<5;i++){scanf(“%d”,&a[i]);}max=a[0];for(i=0;i<5;i++){if(max<a[i]){max=a[i];} else max = max;}printf(“Maximum number in the given array is:%d”,max);getch();}   Here is the explaination of the code:- first of all we are declaring an array of size 5 you can take the size… Continue Reading

2

C program to transpose of a matrix.

C programming

#include<stdio.h> #include<conio.h> void main() { int i,j,a[5][5],b[5][5],m,n; clrscr(); printf(“Enter the number of rows and columns for matrice:(max 5)”); scanf(“%d%d”,&m,&n); printf(“Enter the elements of matrix”); for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf(“%d”,&a[i][j]); } } for(i=0;i<m;i++) { for(j=0;j<n;j++) { b[i][j]=a[j][i]; } } printf(“\nNew matrix… Continue Reading