C Program to mask password text with asterisk(*)

C Program to mask password text with asterisk(*). This program is to illustrate how user authentication is made before allowing the user to access the secured resources. It asks for the user name and then the password. The password that you enter will not be displayed, instead that character is replaced by ‘*’. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* 
*                        Happy Coding
***********************************************************/

#include <stdio.h>
#include <conio.h>

void main()
{
 char pasword[10],usrname[10], ch;
 int i;
 clrscr();

 printf("Enter User name: ");
 gets(usrname);
 printf("Enter the password <any 8 characters>: ");

 for(i=0;i<8;i++)
 {
  ch = getch();
  pasword[i] = ch;
  ch = '*' ;
  printf("%c",ch);
 }

 pasword[i] = '';

 /*If you want to know what you have entered as password, you can print it*/
 printf("nYour password is :");

 for(i=0;i<8;i++)
 {
  printf("%c",pasword[i]);
 }
}
Read more Similar C Programs
Searching in C
C Strings

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program: Insert into an array

Arrays in C
Write a C program to insert a particular element in a specified position in a given array.Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

*/

#include <stdio.h>
#include <conio.h>

void main()
{
int x[10];
int i, j, n, m, temp, key, pos;

clrscr();

printf("Enter how many elementsn");
scanf("%d", &n);

printf("Enter the elementsn");
for(i=0; i<n; i++)
{
scanf("%d", &x[i]);
}

printf("Input array elements aren");
for(i=0; i<n; i++)
{
printf("%dn", x[i]);
}

for(i=0; i< n; i++)
{
for(j=i+1; j<n; j++)
{
if (x[i] > x[j])
{
temp = x[i];
x[i] = x[j];
x[j] = temp;
}
}
}

printf("Sorted list isn");
for(i=0; i<n; i++)
{
printf("%dn", x[i]);
}

printf("Enter the element to be insertedn");
scanf("%d",&key);

for(i=0; i<n; i++)
{
if ( key < x[i] )
{
pos = i;
break;
}
}

m = n - pos + 1 ;

for(i=0; i<= m ; i++)
{
x[n-i+2] = x[n-i+1] ;
}

x[pos] = key;

printf("Final list isn");
for(i=0; i<n+1; i++)
{
printf("%dn", x[i]);
}
} /* End of main() */
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program: Array Summation Using Pointers

Arrays in C.
Write a C program to read N integers and store them in an array A, and so find the sum of all these elements using pointer. Output the given array and and the computed sum with suitable heading. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/



#include <stdio.h>
#include <conio.h>
#include <malloc.h>

void main()
{
int i,n,sum=0;
int *a;

clrscr();

printf("Enter the size of array An");
scanf("%d", &n);

a=(int *) malloc(n*sizeof(int)); /*Dynamix Memory Allocation */

printf("Enter Elements of First Listn");
for(i=0;i<n;i++)
{
scanf("%d",a+i);
}

/*Compute the sum of all elements in the given array*/
for(i=0;i<n;i++)
{
sum = sum + *(a+i);
}

printf("Sum of all elements in array = %dn", sum);

} /* End of main() */
Read more Similar C Programs
Array In C

Simple C Programs

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed! and the computed sum with suitable heading. Read more about C Programming Language .

(c) www.c-program-example.com

C program: Sum Of Elements In A Matrix

Write a C program to read a matrix A (MxN) and to find the following using functions
a) Sum of the elements of each row
b) Sum of the elements of each column
c) Find the sum of all the elements of the matrix
Output the computed results with suitable headings.
Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include <stdio.h>
#include <conio.h>

void main()
{
int arr[10][10];
int i, j, row, col, rowsum, colsum,sumall=0;

/* Function declaration */
int Addrow(int A[10][10], int k, int c);
int Addcol(int A[10][10], int k, int c);

clrscr();

printf("Enter the order of the matrixn");
scanf("%d %d", &row, &col);

printf("Enter the elements of the matrixn");
for(i=0; i<row; i++)
{
for(j=0; j< col; j++)
{
scanf("%d", &arr[i][j]);
}
}

printf("Input matrix isn");
for(i=0; i<row; i++)
{
for(j=0;j<col;j++)
{
printf("%3d", arr[i][j]);
}
printf("n");
}

/* computing row sum */
for(i=0; i<row; i++)
{
rowsum = Addrow(arr,i,col);
printf("Sum of row %d = %dn", i+1, rowsum);
}

for(j=0; j<col; j++)
{
colsum = Addcol(arr,j,row);
printf("Sum of column %d = %dn", j+1, colsum);
}

/* computation of all elements */
for(j=0; j< row; j++)
{
sumall = sumall + Addrow(arr,j,col);
}

printf("Sum of all elements of matrix = %dn", sumall);

}

/* Function to add each row */
int Addrow(int A[10][10], int k, int c)
{
int rsum=0, i;
for(i=0; i< c; i++)
{
rsum = rsum + A[k][i];
}
return(rsum);
}

/* Function to add each column */
int Addcol(int A[10][10], int k, int r)
{
int csum=0, j;
for(j=0; j< r; j++)
{
csum = csum + A[j][k];
}
return(csum);
}
Read more Similar C Programs
Matrix Programs
Learn C Programming

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to find the Multiplication of two matrices

C Program to find the Multiplication of two matrices. C Program Develop functions
a) To read a given matrix
b) To output a matrix
c) To compute the product of two matrices
Use the above functions to read in two matrices A (MxN) B (NxM), to compute the product of the two matrices, to output the given matrices and the computed matrix in a main function
Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

#include <stdio.h>
#include <conio.h>
#define MAXROWS 10
#define MAXCOLS 10

void main()
{
int A[MAXROWS][MAXCOLS], B[MAXROWS][MAXCOLS], C[MAXROWS][MAXCOLS];
int M, N;

/*Function declarations*/

void readMatrix(int arr[][MAXCOLS], int M, int N);
void printMatrix(int arr[][MAXCOLS], int M, int N);
void productMatrix(int A[][MAXCOLS], int B[][MAXCOLS], int C[][MAXCOLS],
int M, int N);

clrscr();

printf("Enter the value of M and Nn");
scanf("%d %d",&M, &N);
printf ("Enter matrix An");
readMatrix(A,M,N);
printf("Matrix An");
printMatrix(A,M,N);

printf ("Enter matrix Bn");
readMatrix(B,M,N);
printf("Matrix Bn");
printMatrix(B,M,N);

productMatrix(A,B,C, M,N);

printf ("The product matrix isn");
printMatrix(C,M,N);
}

/*Input matrix A*/
void readMatrix(int arr[][MAXCOLS], int M, int N)
{
int i, j;
for(i=0; i< M ; i++)
{
for ( j=0; j < N; j++)
{
scanf("%d",&arr[i][j]);
}
}
}
void printMatrix(int arr[][MAXCOLS], int M, int N)
{
int i, j;
for(i=0; i< M ; i++)
{
for ( j=0; j < N; j++)
{
printf("%3d",arr[i][j]);
}
printf("n");
}
}

/* Multiplication of matrices */
void productMatrix(int A[][MAXCOLS], int B[][MAXCOLS], int C[][MAXCOLS],
int M, int N)
{
int i, j, k;
for(i=0; i< M ; i++)
{
for ( j=0; j < N; j++)
{
C[i][j] = 0 ;
for (k=0; k < N; k++)
{
C[i][j] = C[i][j] + A[i][k] * B[k][j];
}
}
}
}
Read more Similar C Programs
Matrix Programs
Learn C Programming

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to sort given N elements using SELECTION sort method

Write a C program to sort given N elements using SELECTION sort method using functions :
a) To find maximum of elements
b) To swap two elements
Selection sort is comparison based sorting technique, It finds the minimum value in list and swaps that value to the first position and so on. Selection sort is inefficient on larger data. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include <stdio.h>
#include <conio.h>

void main()
{
int array[10];
int i, j, N, temp;

int findmax(int b[10], int k); /* function declaration */
void exchang(int b[10], int k);

clrscr();

printf("Enter the value of Nn");
scanf("%d",&N);

printf("Enter the elements one by onen");
for(i=0; i<N ; i++)
{
scanf("%d",&array[i]);

}

printf("Input array elementsn");
for(i=0; i<N ; i++)
{
printf("%dn",array[i]);
}

/* Selection sorting begins */
exchang(array,N);

printf("Sorted array is...n");
for(i=0; i< N ; i++)
{
printf("%dn",array[i]);
}

} /* End of main*/

/* function to find the maximum value */
int findmax(int b[10], int k)
{
int max=0,j;
for(j = 1; j <= k; j++)
{
if ( b[j] > b[max])
{
max = j;
}
}
return(max);
}


void exchang(int b[10],int k)
{
int temp, big, j;
for ( j=k-1; j>=1; j--)
{

big = findmax(b,j);
temp = b[big];
b[big] = b[j];
b[j] = temp;
}
return;
}
Read more Similar C Programs

Data Structures


C Sorting

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program To Sort Names

Write a C program to read N names, store them in the form of an array and sort them in alphabetical order.Output the given names and the sorted names in two columns side by side with suitable heading.Program will sort the name strings using Bubble Sort technique. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include <stdio.h>
#include <conio.h>
#include <string.h>

void main()
{
char name[10][8], Tname[10][8], temp[8];
int i, j, N;

clrscr();

printf("Enter the value of Nn");
scanf("%d", &N);

printf("Enter %d namesn", N);
for(i=0; i< N ; i++)
{
scanf("%s",name[i]);
strcpy (Tname[i], name[i]);
}

for(i=0; i < N-1 ; i++)
{
for(j=i+1; j< N; j++)
{
if(strcmpi(name[i],name[j]) > 0)
{
strcpy(temp,name[i]);
strcpy(name[i],name[j]);
strcpy(name[j],temp);
}
}
}

printf("n----------------------------------------n");
printf("Input NamestSorted namesn");
printf("------------------------------------------n");
for(i=0; i< N ; i++)
{
printf("%stt%sn",Tname[i], name[i]);
}
printf("------------------------------------------n");

} /* End of main() */
Read more Similar C Programs

Data Structures


C Sorting

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C Program to read an English sentence and replace lowercase characters by uppercase and vice-versa.

Write a C program to read an English sentence and replace lowercase characters by uppercase and vice-verso. Output the given sentence as well as the case converted sentence on two different lines. Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/


#include <stdio.h>
#include <ctype.h>
#include <conio.h>

void main()
{
char sentence[100];
int count, ch, i;

clrscr();

printf("Enter a sentencen");
for(i=0; (sentence[i] = getchar())!='n'; i++)
{
;
}

sentence[i]='';

count = i; /*shows the number of chars accepted in a sentence*/

printf("The given sentence is : %s",sentence);

printf("nCase changed sentence is: ");
for(i=0; i < count; i++)
{
ch = islower(sentence[i]) ? toupper(sentence[i]) : tolower(sentence[i]);
putchar(ch);
}

} /*End of main()*/
Read more Similar C Programs

C Strings


Data Structures


C Sorting

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to check whether a given string is palindrome or not

Write a C program to read a string and check whether it is a palindrome or not (without using library functions). Output the given string along with suitable message.Palindrome is a word, sentence, group of characters, or number, that remains same, when reversed.
For example: GADAG, 9009… Read more about C Programming Language .

/***********************************************************
* You can use all the programs on  www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
* 
*                                  Happy Coding
***********************************************************/

#include <stdio.h>
#include <conio.h>
#include <string.h>

void main()
{
 char string[25], revString[25]={''};
 int  i,length = 0, flag = 0;

 clrscr();

 fflush(stdin);

 printf("Enter a stringn");
 gets(string);

 for (i=0; string[i] != ''; i++) /*keep going through each */
 {                                 /*character of the string */
  length++;                     /*till its end */
 }

 for (i=length-1; i >= 0 ; i--)
 {
  revString[length-i-1] = string[i];
 }

 /*Compare the input string and its reverse. If both are equal
   then the input string is palindrome. Otherwise it is
   not a palindrome */

 for (i=0; i < length ; i++)
 {
  if (revString[i] == string[i])
   flag = 1;
  else
   flag = 0;
 }

 if (flag == 1)
  printf ("%s is a palindromen", string);
 else
  printf("%s is not a palindromen", string);

}   /*End of main()*/
Read more Similar C Programs
Searching in C

C Strings

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com

C program to find the transpose of a given Matrix.

Write a C program to read A (MxN), find the transpose of a given matrix and output both the input matrix and the transposed matrix.
Transpose of a matrix is the interchanging the rows and columns, If A is matrix of order(i*j), where i is the row and j is the column, then Transpose of A is A(j*i). Read more about C Programming Language .

/***********************************************************
* You can use all the programs on www.c-program-example.com
* for personal and learning purposes. For permissions to use the
* programs for commercial purposes,
* contact [email protected]
* To find more C programs, do visit www.c-program-example.com
* and browse!
*
* Happy Coding
***********************************************************/

*/

#include <stdio.h>
#include <conio.h>

void main()
{
int i,j,M,N;
int A[10][10], B[10][10];

int transpose(int A[][10], int r, int c); /*Function prototype*/

clrscr();

printf("Enter the order of matrix An");
scanf("%d %d", &M, &N);

printf("Enter the elements of matrixn");
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
scanf("%d",&A[i][j]);
}
}

printf("Matrix A isn");
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
printf("%3d",A[i][j]);
}
printf("n");
}

/* Finding Transpose of matrix*/
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
B[i][j] = A[j][i];
}
}

printf("Its Transpose isn");
for(i=0;i<M;i++)
{
for(j=0;j<N;j++)
{
printf("%3d",B[i][j]);
}
printf("n");
}

} /*End of main()*/
Read more Similar C Programs
Matrix Programs
Learn C Programming

You can easily select the code by double clicking on the code area above.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Share this program with your Facebook friends now! by liking it

(you can send this program to your friend using this button)

Like to get updates right inside your feed reader? Grab our feed!

(c) www.c-program-example.com