APJ ABDUL KALAM TECHNOLOGICAL UNIVERSITY Previous Years Question Paper & Answer

Course : B.Tech

Semester : S1 and S2

Year : 2018

Term : MARCH

Branch : BIOTECHNOLOGY

Scheme : 2015 Full Time

Course Code : CS 100

Page:22





PDF Text (Beta):

char *str1 ="geeks"; char *str2 ="forgeeks";
swap1(&str1, &str2); printf("str1 15 %s, str2 is %s",
511, 512); getchar(); return 0;
}
This method cannot be applied if strings are stored using character arrays.
Method 2(Swap Data)

If you are using character arrays to store strings then preferred way is to swap the data of both arrays.
#include

#include

#include

/* Swaps strings by swapping data*/ void
swap2(char *5111, char *str2)

{

ऽ00नि( निति; (शग) प्१६।॥०८((५1617(511) + 1) * sizeof(char))
5112); strcpy(str2, temp);
free(temp);
}
int main()
{
char str1[10] = "geeks"; char str2[10] =
"forgeeks"; swap2(str1, 5112); printf("str1 is %s,

str2 is %s", str1, 512); getchar();

return 0)

}

This method cannot be applied for strings stored in read only block of memory.

b) A variable declared as an array of some type acts as a pointer to that type. When used by itself, it
points to the first element of the array.

A pointer can be indexed like an array name.
#include int
main()

{

Similar Question Papers