Wednesday , 24 July 2024
Home » Tutorials

Category Archives: Tutorials

C Program to Find if a year is Leap Year or not

Program: #include <stdio.h> main() { int year; clrscr(); printf("Enter a year to check if it is a leap year\n"); scanf("%d", &year); if ( year%400 == 0) printf("%d is a leap year.\n", year); else if ( year%100 == 0) printf("%d is not a leap year.\n", year); else if ( year%4 == 0 ) printf("%d is a leap year.\n", year); else printf("%d ... Read More »

C program to Find the Transpose of a given matrix

Program : #include int main() { int a[4][4],i,j,b; for(i=0;i<4;i++) { printf("\nEnter elements of %d row of Matrix: ",i+1); for(j=0;j<4;j++) scanf("%d",&a[i][j]); } for(i=0;i<4;i++) { for(j=i+1;j<4;j++) { b=a[i][j]; a[i][j]=a[j][i]; a[j][i]=b; } } printf("\n Transposed Matrix:\n\n"); for(i=0;i<4;i++) { for(j=0;j<4;j++) printf("%4d",a[i][j]); printf("\n"); } return 0; } Read More »

C Program to print Pascal’s Triangle

Program : #include <stdio.h> void main() { int num,x,y,a[50][50]; clrscr(); fflush(stdin); printf("Enter the number of rows: "); scanf("%d",&num); printf("\n Pascal's Triangle of Order %d\n\n",num); for(x=0;x{ for(y=0;y<=x;y++) { if(x==y || y==0) a[x][y]=1; else a[x][y]=a[x-1][y-1]+a[x-1][y]; printf("%4d",a[x][y]); } printf("\n\n"); } getch(); } Read More »

C program to implement Bubble sort

Bubble sort is a sorting technique where each two adjacent numbers are compared and the process is repeated until the whole list is sorted. This is less efficient but stable Program: #include int main() { int arr[100],i,j,n,temp; printf("Enter no. of terms\n"); scanf("%d",&n); printf("Enter the elements\n"); for(i=0;iarr[j+1]) { temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } printf("Sorted elements are\n"); for(i=0;i Read More »

C program to find Mean, Median and mode with algorithm

Well before starting, let’s look at the basic defention and how we find mean, median and mode. Both these are 3 variables to find the average value or an approximate value of a list, but yet they have different values as they are based on 3 different concepts Concepts of mean, median and mode What is mean ?  Mean is ... Read More »

Scroll To Top