Posts

Showing posts from February, 2016

Encryption and Decryption using a c program

encryption is process through which we can change a text into a coded language  with this method we can hide data for unwanted users and  used for security purpose. in networking our data transfer from one end to another using this encryption and decryption .decryption means to decode the previously coded message. here in this program we are just adding a integer 2 value in each character of the given message and for decoding we are just subtracting 2 from the previously coded message. #include<stdio.h> #include<conio.h> #include<string.h> void main() { char str[50]; int i,x;        do{ printf("press 1.Encryption \n 2.Decryption\n3.exit\n"); scanf("%d",&x); clrscr();        switch(x)        { case 1: puts("Enter your message\n"); gets(str);   printf("encrypted message is here:\n"); for(i=0;str[i]!='\0';i++) {       str[i]=str[i]+2 ;    

Opening and page wise viewing of a file using c program :

This post is about page wise printing a file on console using file input and output. When we print file from disk on console so it will break it into parts specified by us using the following code just use a counter and increase its value and use an if condition to reach at that particular position , from where we want to break that page into parts .The number of lines in a file can vary you can adjust according to your need. #include<stdio.h> #include<conio.h> #include<string.h> void main() { int m=0; char c; FILE *fp; clrscr(); fp=fopen("c:avg_dma.c","r"); if(fp==NULL) { printf("File Opening error"); exit(0); } else while(1) { c=fgetc(fp); if(c==EOF) break; else if(m== 132)                    /*here the number given 132 can vary according to your need you can                                                           set it by increasing and decreasing it/ getch(

FIBONACCI WORD

In this the program will print fibonacci series of word : if f(0)="a",f(1)="b",f(2)="ba",f(3),"bab",f(4)="babba",etc. here program is given to print the series: #include<stdio.h> #include<conio.h> #include<string.h> void main() { char ch1[5]={"a"},ch2[5]={"b"},ch3[5]={"b"}; int i; clrscr(); puts(ch1); printf("\n"); for(i=0;i<5;i++) { puts(ch3); printf("\n"); strcat(ch3,ch1);       strcpy(ch1,ch2); strcpy(ch2,ch3); } getch(); }

SUDOKU CHECKING PROGRAM

Image
A Sudoku is a number placement puzzle ,it has 9*9 rows and columns . the rule is that any row or column should not contain similar value if any of the element contain same value then that Sudoku is not right. here a program is given to show this:   #include<stdio.h> #include<conio.h> void main() { int k,i,j,a[9][9]={5,3,4,6,7,8,9,1,2, 6,7,2,1,9,5,3,4,8, 1,9,8,3,4,2,5,6,7 , 8,5,9,7,6,1,4,2,3, 4,2,6,8,5,3,7,9,1, 7,1,3,9,2,4,8,5,6, 9,6,1,5,3,7,2,8,4, 2,8,7,4,1,9,6,3,5, 3,4,5,2,8,6,1,7,9}; static int f; for(k=0;k<9;k++) { for(j=k;j<9;j++) { for(i=0;i<9;i++) { if(a[i][j]==a[i][j+1]) { f=1; break; } else if(a[i][j]==a[i+1][j]) { f=1; break; } } } } if(f==1) printf("sudoku is not right"); else printf("sudoku is right"); }

CREDIT CARD CHECKING PROGRAM

This program is to check a credit card number weather it is valid or not .A valid credit card is a 16 digit number would satisfy the following rule. from rightmost digit -1 every digit is multiplied by 2. and digits which is multiplied by 2 should not be greater than 10. and sum of all the digits will be equal to 38. and sum of other digits which is not multiplied by 2 will be equal to 42. and adding sum1 and sum2 will give 80 which is divisible by 10  then this will be a valid credit card number. The following dummy credit card number will show all the above given points: 4   5   6   7            1    2    3   4   5   6   7   8   9   1   2   9      8       12               2           6        10     14      18       4 Then subtract 9 from the numbers greater than 10 8 3 2 6 1 5 9 4 Add them all up to get 38. Add all other digits to get 42 ,the digits which is not multiplied by 2:    5      7                2      4      6      8      1      9 sum of 32 and 42 is