Friday, 27 June 2014
JNTU Syllabus Books For All Years & All Branches
JNTU HYD board decided to complete the evaluation of btech 1st year external exams as soon as possible.
Wednesday, 25 June 2014
Warning: Over 0.3 Million Routers Around The Globe Have Been Compromised!
Warning: Over 0.3 Million Routers Around The Globe Have Been Compromised!
Specifically, a majority of these lie in countries like Vietnam, India, Italy and Thailand. The routers in the mentioned countries have been affected by changing their DNS settings from their ISP’s default to two UK IP addresses (5.45.75.11 and 5.45.75.36). Routers were affected in two ways. In one, a malicious code was used to target those routers which had their GUI's accessible from the internet. Secondly, the other target routers were those that were vulnerable to ROM-O attacks, with a majority that ran ZyXEL’s ZynOS falling under the category.
The research team has however still not detected any evidence to suggest the two IP addresses were being used for malicious activities. Meanwhile, Cymru has advised users to check the DNS settings on their routers to make sure that they match the ISP’s DNS.
| Wednesday, March 05, 2014:
A recent report by internet security research firm, Cymru has
shockingly revealed that over 0.3 million small office and home routers
(SOHOs) around the world have been compromised using man-in-the-middle
attacks. The 'Growing Exploitation of Small Office Routers Creating
Serious Risks' report clearly indicates that routers primarily in Europe
and Asia have been compromised by what they term as SOHO pharming. |
|
Specifically, a majority of these lie in countries like Vietnam, India, Italy and Thailand. The routers in the mentioned countries have been affected by changing their DNS settings from their ISP’s default to two UK IP addresses (5.45.75.11 and 5.45.75.36). Routers were affected in two ways. In one, a malicious code was used to target those routers which had their GUI's accessible from the internet. Secondly, the other target routers were those that were vulnerable to ROM-O attacks, with a majority that ran ZyXEL’s ZynOS falling under the category.
The research team has however still not detected any evidence to suggest the two IP addresses were being used for malicious activities. Meanwhile, Cymru has advised users to check the DNS settings on their routers to make sure that they match the ISP’s DNS.
Saturday, 1 March 2014
hyderabad
Hyderabad is the capital and largest city of the southern Indian state of Andhra Pradesh. Occupying 650 square kilometres (250 sq mi), along the banks of the Musi River, it has a population of 6.8 million and a metropolitan population of 7.75 million in hyderabad. making it the fourth most populous city and sixth most populous urban agglomeration in India.
At an average altitude of 542 metres (1,778 ft), much of Hyderabad is
situated on hilly terrain around artificial lakes, including Hussain Sagar—predating the city's founding—north of the city centre in hyderabad .
Established in 1591 by Muhammad Quli Qutb Shah, Hyderabad remained under the rule of the Qutb Shahi dynasty for nearly a century before the Mughals captured the region in hyderabad . in hyderabad In 1724, Mughal viceroy Asif Jah I declared his sovereignty and created his own dynasty, also known as the Nizams of Hyderabad. The Hyderabad State ultimately became a princely state during British rule, and remained so for 150 years, with the city serving as its capital. The city continued as capital of a new Hyderabad State after joining the Indian Union in 1948 and before attaining its current status as the focal point of Andhra Pradesh in 1956. Hyderabad is expected to be part of Telangana when the new state is carved out of Andhra Pradesh.
Relics of Qutb Shahi and Nizam rule remain visible today, with the Charminar—commissioned by Muhammad Quli Qutb Shah himself—coming to symbolise Hyderabad. That legacy is also evident in the city's distinctive cuisine, which includes Hyderabadi biriyani and Hyderabadi haleem. The Qutb Shahis and Nizams established Hyderabad as a cultural hub, attracting men of letters from different parts of the world. Hyderabad emerged as the foremost centre of culture in India with the decline of the Mughal Empire in the mid-19th century, with artists migrating to the city from the rest of the Indian subcontinent. While Hyderabad is losing its cultural pre-eminence, it is today, due to the Telugu film industry, the country's second-largest producer of motion pictures in hyderabad
Hyderabad was historically known as a pearl and diamond trading centre, and it continues to be known as the City of Pearls. Many of the city's traditional bazaars, including Laad Bazaar, Begum Bazaar and Sultan Bazaar, have remained open for centuries. However, industrialisation throughout the 20th century has also attracted major Indian manufacturing, research and financial institutions, including the Bharat Heavy Electricals Limited, National Geophysical Research Institute and the Centre for Cellular and Molecular Biology. Special economic zones dedicated to information technology have encouraged companies from across India and around the world to set up operations and the emergence of pharmaceutical and biotechnology industries in the 1990s led to the title of Genome Valley. With an output of US$74 billion, Hyderabad is the fifth-largest contributor to India's overall gross domestic product.in hyderabad
Established in 1591 by Muhammad Quli Qutb Shah, Hyderabad remained under the rule of the Qutb Shahi dynasty for nearly a century before the Mughals captured the region in hyderabad . in hyderabad In 1724, Mughal viceroy Asif Jah I declared his sovereignty and created his own dynasty, also known as the Nizams of Hyderabad. The Hyderabad State ultimately became a princely state during British rule, and remained so for 150 years, with the city serving as its capital. The city continued as capital of a new Hyderabad State after joining the Indian Union in 1948 and before attaining its current status as the focal point of Andhra Pradesh in 1956. Hyderabad is expected to be part of Telangana when the new state is carved out of Andhra Pradesh.
Relics of Qutb Shahi and Nizam rule remain visible today, with the Charminar—commissioned by Muhammad Quli Qutb Shah himself—coming to symbolise Hyderabad. That legacy is also evident in the city's distinctive cuisine, which includes Hyderabadi biriyani and Hyderabadi haleem. The Qutb Shahis and Nizams established Hyderabad as a cultural hub, attracting men of letters from different parts of the world. Hyderabad emerged as the foremost centre of culture in India with the decline of the Mughal Empire in the mid-19th century, with artists migrating to the city from the rest of the Indian subcontinent. While Hyderabad is losing its cultural pre-eminence, it is today, due to the Telugu film industry, the country's second-largest producer of motion pictures in hyderabad
Hyderabad was historically known as a pearl and diamond trading centre, and it continues to be known as the City of Pearls. Many of the city's traditional bazaars, including Laad Bazaar, Begum Bazaar and Sultan Bazaar, have remained open for centuries. However, industrialisation throughout the 20th century has also attracted major Indian manufacturing, research and financial institutions, including the Bharat Heavy Electricals Limited, National Geophysical Research Institute and the Centre for Cellular and Molecular Biology. Special economic zones dedicated to information technology have encouraged companies from across India and around the world to set up operations and the emergence of pharmaceutical and biotechnology industries in the 1990s led to the title of Genome Valley. With an output of US$74 billion, Hyderabad is the fifth-largest contributor to India's overall gross domestic product.in hyderabad
Saturday, 8 February 2014
Union in c
Union
Prev Next
C Union is also like structure,
i.e. collection of different data types which are grouped together. Each
element in a union is called member.
- Union and structure in C are same in concepts, except allocating memory for their members.
- Structure allocates storage space for all its members separately.
- Whereas, Union allocates one common storage space for all its members
- We can access only one member of union at a time. We can’t access all member values at the same time in union. But, structure can access all member values at the same time. This is because, Union allocates one common storage space for all its members. Where as Structure allocates storage space for all its members separately.
- Many union variables can be created in a program and memory will be allocated for each union variable separately.
- Below table will help you how to form a C union, declare a union, initializing and accessing the members of the union.
| Type | Using normal variable | Using pointer variable |
| Syntax | union tag_name { data type var_name1; data type var_name2; data type var_name3; }; |
union tag_name { data type var_name1; data type var_name2; data type var_name3; }; |
| Example | union student { int mark; char name[10]; float average; }; |
union student { int mark; char name[10]; float average; }; |
| Declaring union variable | union student report; | union student *report, rep; |
| Initializing union variable | union student report = {100, “Mani”, 99.5}; | union student rep = {100, “Mani”, 99.5};report = &rep; |
| Accessing union members | report.mark report.name report.average |
report -> mark report -> name report -> average |
Example program for C union:
C
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include <stdio.h>
#include <string.h>
union student
{
char name[20];
char subject[20];
float percentage;
};
int main()
{
union student record1;
union student record2;
// assigning values to record1 union variable
strcpy(record1.name, "Raju");
strcpy(record1.subject, "Maths");
record1.percentage = 86.50;
printf("Union record1 values example\n");
printf(" Name : %s \n", record1.name);
printf(" Subject : %s \n", record1.subject);
printf(" Percentage : %f \n\n", record1.percentage);
// assigning values to record2 union variable
printf("Union record2 values example\n");
strcpy(record2.name, "Mani");
printf(" Name : %s \n", record2.name);
strcpy(record2.subject, "Physics");
printf(" Subject : %s \n", record2.subject);
record2.percentage = 99.50;
printf(" Percentage : %f \n", record2.percentage);
return 0;
}
|
Output:
|
Union record1 values example
Name : Subject : Percentage : 86.500000 Union record2 values example Name : Mani Subject : Physics Percentage : 99.500000 |
Explanation for above C union program:
There are 2 union variables declared in this program to understand the difference in accessing values of union members.
Record1 union variable:- “Raju” is assigned to union member “record1.name” . The memory location name is “record1.name” and the value stored in this location is “Raju”.
- Then, “Maths” is assigned to union member “record1.subject”. Now, memory location name is changed to “record1.subject” with the value “Maths” (Union can hold only one member at a time).
- Then, “86.50” is assigned to union member “record1.percentage”. Now, memory location name is changed to “record1.percentage” with value “86.50”.
- Like this, name and value of union member is replaced every time on the common storage space.
- So, we can always access only one union member for which value is assigned at last. We can’t access other member values.
- So, only “record1.percentage” value is displayed in output. “record1.name” and “record1.percentage” are empty.
- If we want to access all member values using union, we have to access the member before assigning values to other members as shown in record2 union variable in this program.
- Each union members are accessed in record2 example immediately after assigning values to them.
- If we don’t access them before assigning values to other member, member name and value will be over written by other member as all members are using same memory.
- We can’t access all members in union at same time but structure can do that.
Example program – Another way of declaring C union:
In this program, union variable “record” is declared while declaring union itself as shown in the below program.
C
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include <stdio.h>
#include <string.h>
union student
{
char name[20];
char subject[20];
float percentage;
}record;
int main()
{
strcpy(record.name, "Raju");
strcpy(record.subject, "Maths");
record.percentage = 86.50;
printf(" Name : %s \n", record.name);
printf(" Subject : %s \n", record.subject);
printf(" Percentage : %f \n", record.percentage);
return 0;
}
|
Output:
|
Name :
Subject : Percentage : 86.500000 |
Note:
We can access
only one member of union at a time. We can’t access all member values at
the same time in union. But, structure can access all member values at
the same time. This is because, Union allocates one common storage space
for all its members. Where as Structure allocates storage space for all its members separately.
Difference between structure and union in C:
| S.no |
C Structure
|
C Union
|
| 1 |
Structure allocates storage space for all its members separately.
|
Union allocates one common storage space for all its members. Union finds that which of its member needs high storage space over other members and allocates that much space |
| 2 | Structure occupies higher memory space. | Union occupies lower memory space over structure. |
| 3 | We can access all members of structure at a time. | We can access only one member of union at a time. |
| 4 | Structure example: struct student { int mark; char name[6]; double average; }; |
Union example: union student { int mark; char name[6]; double average; }; |
| 5 | For above structure, memory allocation will be like below. int mark – 2B char name[6] – 6B double average – 8B Total memory allocation = 2+6+8 = 16 Bytes |
For
above union, only 8 bytes of memory will be allocated since double data
type will occupy maximum space of memory over other data types. Total memory allocation = 8 Bytes |
Prev Next
Typedef in c
Typedef
Prev Next
- Typedef is a keyword that is used to give a new symbolic name for the existing name in a C program. This is same like defining alias for the commands. ……
- Consider the below structure.
struct student
{
int mark [2];
char name [10];
float average;
}
{
int mark [2];
char name [10];
float average;
}
- Variable for the above structure can be declared in two ways.
1st way :
struct student record; /* for normal variable */
struct student *record; /* for pointer variable */
struct student *record; /* for pointer variable */
2nd way :
typedef struct student status;
- When we use “typedef” keyword before struct <tag_name> like above, after that we can simply use type definition “status” in the C program to declare structure variable.
- Now, structure variable declaration will be, “status record”.
- This is equal to “struct student record”. Type definition for “struct student” is status. i.e. status = “struct student”
An alternative way for structure declaration using typedef in C:
typedef struct student
{
int mark [2];
char name [10];
float average;
} status;
{
int mark [2];
char name [10];
float average;
} status;
- To declare structure variable, we can use the below statements.
status record1; /* record 1 is structure variable */
status record2; /* record 2 is structure variable */
status record2; /* record 2 is structure variable */
Example program for C typedef:
C
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// Structure using typedef:
#include <stdio.h>
#include <string.h>
typedef struct student
{
int id;
char name[20];
float percentage;
} status;
int main()
{
status record;
record.id=1;
strcpy(record.name, "Raju");
record.percentage = 86.5;
printf(" Id is: %d \n", record.id);
printf(" Name is: %s \n", record.name);
printf(" Percentage is: %f \n", record.percentage);
return 0;
}
|
Output:
|
Id is: 1
Name is: Raju Percentage is: 86.500000 |
- Typedef can be used to simplify the real commands as per our need.
- For example, consider below statement.
typedef long long int LLI;
- In above statement, LLI is the type definition for the real C command “long long int”. We can use type definition LLI instead of using full command “long long int” in a C program once it is defined.
Another example program for C typedef:
C
|
1
2
3
4
5
6
7
8
9
10
11
12
|
#include <stdio.h>
#include <limits.h>
int main()
{
typedef long long int LLI;
printf("Storage size for long long int data " \
"type : %ld \n", sizeof(LLI));
return 0;
}
|
Output:
|
Storage size for long long int data type : 8
|
Prev Next
.C – Structure Padding
C – Structure Padding
Prev Next
- In order to align the data in memory, one or more empty bytes (addresses) are inserted (or left empty) between memory addresses which are allocated for other structure members while memory allocation. This concept is called structure padding.
- Architecture of a computer processor is such a way that it can read 1 word (4 byte in 32 bit processor) from memory at a time.
- To make use of this advantage of processor, data are always aligned as 4 bytes package which leads to insert empty addresses between other member’s address.
- Because of this structure padding concept in C, size of the structure is always not same as what we think.
For example, please consider below structure that has 5 members.
..
struct student
{
int id1;
int id2;
char a;
char b;
float percentage;
};
..
- As per C concepts, int and float datatypes occupy 4 bytes each and char datatype occupies 1 byte for 32 bit processor. So, only 14 bytes (4+4+1+1+4) should be allocated for above structure.
- But, this is wrong. Do you know why?
- Architecture of a computer processor is such a way that it can read 1 word from memory at a time.
- 1 word is equal to 4 bytes for 32 bit processor and 8 bytes for 64 bit processor. So, 32 bit processor always reads 4 bytes at a time and 64 bit processor always reads 8 bytes at a time.
- This concept is very useful to increase the processor speed.
- To make use of this advantage, memory is arranged as a group of 4 bytes in 32 bit processor and 8 bytes in 64 bit processor.
- Below C program is compiled and executed in 32 bit compiler. Please check memory allocated for structure1 and structure2 in below program.
Example program for structure padding in C:
C
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#include <stdio.h>
#include <string.h>
/* Below structure1 and structure2 are same.
They differ only in member's allignment */
struct structure1
{
int id1;
int id2;
char name;
char c;
float percentage;
};
struct structure2
{
int id1;
char name;
int id2;
char c;
float percentage;
};
int main()
{
struct structure1 a;
struct structure2 b;
printf("size of structure1 in bytes : %d\n",
sizeof(a));
printf ( "\n Address of id1 = %u", &a.id1 );
printf ( "\n Address of id2 = %u", &a.id2 );
printf ( "\n Address of name = %u", &a.name );
printf ( "\n Address of c = %u", &a.c );
printf ( "\n Address of percentage = %u",
&a.percentage );
printf(" \n\nsize of structure2 in bytes : %d\n",
sizeof(b));
printf ( "\n Address of id1 = %u", &b.id1 );
printf ( "\n Address of name = %u", &b.name );
printf ( "\n Address of id2 = %u", &b.id2 );
printf ( "\n Address of c = %u", &b.c );
printf ( "\n Address of percentage = %u",
&b.percentage );
getchar();
return 0;
}
|
Output:
| size of structure1 in bytes : 16
Address of id1 = 1297339856 Address of id2 = 1297339860 Address of name = 1297339864 Address of c = 1297339865 Address of percentage = 1297339868 size of structure2 in bytes : 20 Address of id1 = 1297339824 Address of name = 1297339828 Address of id2 = 1297339832 Address of c = 1297339836 Address of percentage = 1297339840 |
Structure padding analysis for above C program:
Memory allocation for structure1:
- In above program, memory for structure1 is allocated sequentially for first 4 members.
- Whereas, memory for 5th member “percentage” is not allocated immediate next to the end of member “c”.
- There are only 2 bytes remaining in the package of 4 bytes after memory allocated to member “c”.
- Range of this 4 byte package is from 1297339864 to 1297339867.
- Addresses 1297339864 and 1297339865 are used for members “name and c”. Addresses 1297339866 and 1297339867 only is available in this package.
- But, member “percentage” is datatype of float and requires 4 bytes. It can’t be stored in the same memory package as it requires 4 bytes. Only 2 bytes are free in that package.
- So, next 4 byte of memory package is chosen to store percentage data which is from 1297339868 to 1297339871.
- Because of this, memory 1297339866 and 1297339867 are not used by the program and those 2 bytes are left empty.
- So, size of structure1 is 16 bytes which is 2 bytes extra than what we think. Because, 2 bytes are left empty.
Memory allocation for structure2:
- Memory for structure2 is also allocated as same as above concept. Please note that structure1 and structure2 are same. But, they differ only in the order of the members declared inside the structure.
- 4 bytes of memory is allocated for 1st structure member “id1″ which occupies whole 4 byte of memory package.
- Then, 2nd structure member “name” occupies only 1 byte of memory in next 4 byte package and remaining 3 bytes are left empty. Because, 3rd structure member “id2″ of datatype integer requires whole 4 byte of memory in the package. But, this is not possible as only 3 bytes available in the package.
- So, next whole 4 byte package is used for structure member “id2″.
- Again, 4th structure member “c” occupies only 1 byte of memory in next 4 byte package and remaining 3 bytes are left empty.
- Because, 5th structure member “percentage” of datatype float requires whole 4 byte of memory in the package.
- But, this is also not possible as only 3 bytes available in the package. So, next whole 4 byte package is used for structure member “percentage”.
- So, size of structure2 is 20 bytes which is 6 bytes extra than what we think. Because, 6 bytes are left empty.
How to avoid structure padding in C?
- #pragma pack ( 1 ) directive can be used for arranging memory for structure members very next to the end of other structure members.
- VC++ supports this feature. But, some compilers such as Turbo C/C++ does not support this feature.
- Please check the below program where there will be no addresses (bytes) left empty because of structure padding.
Example program to avoid structure padding in C:
C
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <stdio.h>
#include <string.h>
/* Below structure1 and structure2 are same.
They differ only in member's allignment */
#pragma pack(1)
struct structure1
{
int id1;
int id2;
char name;
char c;
float percentage;
};
struct structure2
{
int id1;
char name;
int id2;
char c;
float percentage;
};
int main()
{
struct structure1 a;
struct structure2 b;
printf("size of structure1 in bytes : %d\n",
sizeof(a));
printf ( "\n Address of id1 = %u", &a.id1 );
printf ( "\n Address of id2 = %u", &a.id2 );
printf ( "\n Address of name = %u", &a.name );
printf ( "\n Address of c = %u", &a.c );
printf ( "\n Address of percentage = %u",
&a.percentage );
printf(" \n\nsize of structure2 in bytes : %d\n",
sizeof(b));
printf ( "\n Address of id1 = %u", &b.id1 );
printf ( "\n Address of name = %u", &b.name );
printf ( "\n Address of id2 = %u", &b.id2 );
printf ( "\n Address of c = %u", &b.c );
printf ( "\n Address of percentage = %u",
&b.percentage );
getchar();
return 0;
}
|
Output:
| size of structure1 in bytes : 14
Address of id1 = 3438103088 Address of id2 = 3438103092 Address of name = 3438103096 Address of c = 3438103097 Address of percentage = 3438103098 size of structure2 in bytes : 14 Address of id1 = 3438103072 Address of name = 3438103076 Address of id2 = 3438103077 Address of c = 3438103081 Address of percentage = 3438103082 |
Prev Next
Subscribe to:
Posts (Atom)