IP class in c

On-campus and online computer science courses to Learn the basic concepts of Computer Science.This tutorial will cover c ,c++, java, data structure and algorithm,computer graphics,microprocessor,analysis of algorithms,Digital Logic Design and Analysis,computer architecture,computer networks,operating system.
code in C:
#include<stdio.h>
int main()
{
	int b[100],i,j,temp=0,x;
	char a[100];
	printf("Enter ip address:\n");
	scanf("%s",a);
	for(i=0;i<3;i++)
	{
		x=a[i]-'0'; 			// to convert char to int
  		temp=temp*10+x;
	}
	if(temp < 128)
			printf("class A");
		else if(temp < 192)
			printf("class B");
		else if(temp < 224)
			printf("class C");
		else if(temp < 240)
			printf("class D");
		else if(temp < 256)
			printf("class E");
	return 0;
}
output:-
Enter ip address:
211.72.39.60
class C
--------------------------------

0 comments: