Pages

Tuesday, January 31, 2017

Program to Print Process ID

Following C program will print Process ID.

#include<stdio.h>
int main(void)
{
printf("My process ID %ld",getpid());
return 0;
}

Output of the program:

My process ID 2213.

Note: You will get different process ID on your system.

* * * * *

Sunday, January 29, 2017

Thanks for Visit...

A New Topic will be added to this place soon....



Saturday, January 28, 2017

Bit Stuffing Simulation

Networking  >> Bit Stuffing Simulation Program


In bit stuffing processing, we add 0 after five consecutive 1's in databits.

#include<stdio.h>
int main()
{
 int i=0,count=0;
 char databits[80];

 printf("Enter Data Bits: ");
 scanf("%s",databits);

 printf("Data Bits Before Bit Stuffing:%s",databits);
 printf("\nData Bits After Bit stuffing :");
 
 for(i=0; i<strlen(databits); i++)
 {
    if(databits[i]=='1')
        count++;
    else
        count=0;
printf("%c",databits[i]);
  if(count==5)
    {
        printf("0");
        count=0;
    }
 }
 return 0;
}

Output of the Program:

Enter Data Bits: 101111111000
Data Bits Before Bit Stuffing:101111111000
Data Bits After Bit stuffing :1011111011000

Back to Networking Page >


Playfair Key Matrix Generation: Keyword validation according to the specification given in the algorithm.


/*Playfair Key Matrix Generation: Keyword validation according to the specification given in the algorithm.*/

#include<stdio.h>

int main(){

  char key[10];
  int i,j,flag=0, cnt=0, key_check[26]={};

  printf("Enter your keyword:");
  scanf("%s",key);

  //Logic to count character frequency in MONARCHY
  for(i=0; i<strlen(key); i++)
  {
key_check[key[i]%65]++;
  }

  for(i=0; i<26; i++)
  {
if(key_check[i] > 1)
flag=1;
//Logic to display frequency
//printf("%c=%d \n",i+65, key_check[i]);
  }

  if(flag==1)
printf("Keyword %s is not suitable for generating Playfair Key Matrix.", key);
  else
printf("Keyword %s is ok for generating Playfair Key Matrix.", key);

  return 0;
}

//This program will check only keywords enter in Capital letters.

Output - 1
Enter your keyword:MONARCHY
Keyword MONARCHY is ok for generating Playfair Key Matrix.

Output - 2
Enter your keyword:HELLO
Keyword HELLO is not suitable for generating Playfair Key Matrix.


Monday, January 16, 2017

Difference between C and C++ Programming


Criteria
C Programming
C++ Programming
Language Type
C is Procedural and Function oriented programming language.
C++ is Object oriented and procedural programming language.
Level of Language
Low / Middle level
Middle / High level
Source file extension
.c
.cpp
Developed by
C originally developed by Dennis Ritchie between 1969 and 1973 at Bell Lab.
C++ was developed by Bjarne Stroustrup 
Supports
It has no support for encapsulation, polymorphism and inheritance
It supports for encapsulation, polymorphism and inheritance.
Security
Limited
Built in to language due to object oriented nature.
Basic Program
#include<stdio.h>
int main(){
   printf(“Hello”);
   return 0;
}
#include <iostream>
using namespace std;
int main(){
     cout << "Hello";
     return 0;
}

Printing output using variable
printf(“Maths=%d”, marks);
cout << “Maths=” << marks;


* * * * *


* * * * *

Friday, January 13, 2017

Difference between C and Java Programming


Criteria
C Programming
Java Programming

Language Type
C is Procedural and Function oriented programming language.

Java is Object oriented programming language.
Level of Language
Low/Middle level
High level

Source file extension

.c
.java
Developed by
C originally developed by Dennis Ritchie between 1969 and 1973 at Bell Lab.

Java originally developed by James Gosling at Sun Microsystems 
Platform dependency / Portability
C is platform dependent.
Java is platform independent.
Security
Limited

Built in to language
Basic Program
#include<stdio.h>
int main(){
printf(“Hello”);
return 0;
}
public class HelloWorld {
   public static void main(String[] args) {        System.out.println("Hello");
   }
}
Printing output using variable

printf(“Maths=%d”, marks);
System.out.print(“Maths” + marks);
Basic compiler
gcc

javac
Known IDE / Editors

BorlandC, TurboC, Dev C++, CodeBlocks
Eclipse, NetBeans


* * * * *


* * * * *