Thursday , 22 February 2024
Home » Tag Archives: coding

## c program to print all 255 ASCII Values using loop

#include <stdio.h> int main() { int i; printf("ASCII table & its equivalent values with numbering: \n"); for(i=1; i<=255; i++) printf("\nValue: %d -> ASCII character: %c",i,i); getch(); return 0; } Read More »

## 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 Find the Reverse of a given number by using Recursion

Program : #include <stdio.h> int rev(int,int); int main() { int a; printf("Type a value : "); scanf("%d",&a); printf("Reverse: %d",rev(a,0)); return 0; } int rev(int i,int r) { if(i > 0) return rev(i/10,(r*10)+(i%10)); return r; } Read More »

## Simple C program to find whether a number is an armstrong number or not

An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371. Algorithm: Step 1: Start Step 2: Read n Step 3: Rem=n Step 4: sum=0 Step 5: If n != 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