القائمة الرئيسية

الصفحات

 منصة تحفيظ القران الكريم اون لاين 

https://quranmo.com


// Program character encryption

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

void  main()
{
    char mychars[10] =
 {'g','h','i','a','b','c','d','e','f', 'l'};
    clrscr();
   
    for(int i = 0; i < 10; i++)
    mychars[i] = toupper(mychars[i]);
   
    for( i = 0; i < 10; i++)
    cout << mychars[i];
    cout << '\n';

    for( i = 0; i < 10; i++)
    mychars[i] += 3;
   
    for( i = 0; i < 10; i++)
    cout << mychars[i];
    cout << '\n';
   
    for( i = 0; i < 10; i++)
    mychars[i] -= 3;
   
    for( i = 0; i < 10; i++)
    cout << mychars[i];
    getch();
   
    
}


// Program2  for illustrating basic encryption and decryption using functions

#include<iostream.h>
#include<conio.h>

#define     FACTOR 95

  void  encrypt (char  *);
  void  decrypt (char  *);

  void main(void)
  {
   char str[20]="I like C++";

   cout<<"Original String:\n";
   cout<<str;
   cout<<endl<<endl;

   encrypt(str);

   cout<<"After Encryption:\n";
   cout<<str;
   cout<<endl<<endl;

   cout<<"After Decryption:\n";
   decrypt(str);
   cout<<str;
   cout<<endl;
   getch ();
  }

  void encrypt(char *str)
  {
   while(*str!='\0')
   {
    *str+=FACTOR;
    str++;
   }
  }
  void decrypt(char *str)
  {
   while(*str!='\0')
   {
    *str -= FACTOR;
    str++;
   }  }
/* Program3. C++ example program to show  how case(uppercase and lowercase) of strings can be changed from one to the other */

   #include<iostream.h>
  #include<conio.h>

  void to_upper(char *);
  void to_lower(char *);

  void main(void)
  {
   char str[50]="I Love C++. The         number 1 language!";
   clrscr();
   to_upper(str);
   cout<<str;
   to_lower(str);
   cout<<endl;
   cout<<str;
   cout<<endl;
   getch();
  }
    void to_upper(char *str)
  {
   while(*str!='\0')
   {
    if(*str>=97 && *str<=122)
      *str-=32;
    str++;
   }
  }
  void to_lower(char *str)
  {
   while(*str!='\0')
   {
     if(*str>=65 && *str<=90)
      *str+=32;
    str++;
   }
  }
Program4:  // Program for string handling functions
#include<iostream.h>
#include<conio.h>
#include<string.h>
Void main()
{
     Char s1[20], s2[20];
     Cout<<” \n enter the first string \n”;
     Cin>>s1;
     Cout<<” \n enter the second string \n “;
     Cin>>s2;
     Cout<<” \n Length of the first string is \n”;
     Cout<<strlen(s1);
     Cout<<” \n Length of the Second string is \n”;
     Cout<<strlen(s2);
     If(!strcmp(s1,s2))
     Cout<<”\n the strings are same \n”;
     Strcat(s1,s2);
     Cout<<” \n concatenated string is \n”;
     Cout<<s1<<endl;
     Strcpy(s1, “ this is a test \n“);
     Cout<<” \n after copying the string is \n”<<s1<<endl;
     Getch();
}

تقييم:

تعليقات

تعليق واحد
إرسال تعليق

إرسال تعليق

شاركنا الآراء ،،