Documente Academic
Documente Profesional
Documente Cultură
AIM
To write a c program to implement dynamic memory allocation concept.
ALGORITHM
1. start.
2. Declare a character pointer variable.
3. Allocate the size to the pointer variable using malloc.
4. Print the size of the pointer variable.
5. Copy the string Bangalore to the pointer variable.
6. Reallocate the size of the pointer variable using realloc function.
7. Copy the string mysore to the pointer variable.
8. Print the content of the pointer variable.
9. Free the memory space using the free function.
10. Stop.
FUNCTION WITHOUT ARGUMENT AND WITHOUT RETURN VALUE
AIM
To write a C program to implement a function without argument and without return type.
ALGORITHM
1.
2.
3.
4.
5.
6.
Start.
Declare two function in the main function.
Call the function.
Inside the function1, print output from function1.
Inside the function2, print output from function2.
Stop.
Start.
Declare two variables in the main function.
Get the values of two variables.
Call the function largest by passing two variables as arguments.
Start.
Declare variables and pointer variables of different types(int, float, char).
Assign the values to the variables.
Assign the address of the variables to pointer variables.
Print the address and content of the variable using pointer variables.
Stop.
CALL BY VALUE
AIM
To write a C program to print the value of the variable using call by value method.
ALGORITHM
1. Start.
2. In the main function,
Declare two variables.
Assign values to two variables.
Print the values of two variables.
Call the function func passing the values of variables as arguments.
Print the value of variables.
3. In the function func,
Add the argument1 with argument1 and assign to argument1.
Add the argument2 with argument2 and assign to argument2.
4. Stop.
CALL BY REFERNECE
AIM
To write a C program to print the value of the variable using call by reference method.
ALGORITHM
1. Start.
2. In the main function,
Declare two variables.
Assign values to two variables.
Print the values of two variables.
Call the function func passing the address of variables as arguments.
Print the value of variables.
3. In the function func,
Add the argument1 with argument1 and assign to argument1.
Add the argument2 with argument2 and assign to argument2.
4. Stop.
WRITING INTO A FILE
AIM
To write a C program to create a file and to write some content into it.
ALGORITHM
1.
2.
3.
4.
5.
6.
Start.
Declare a file pointer.
Open a file in write mode.
Print the content into the file.
Close the file.
Stop.
READING THE CONTENT OF A FILE
AIM
To write a C program to read the content of a file.
ALGORITHM
1.
2.
3.
4.
5.
6.
Start.
Declare a file pointer.
Declare a character variable.
Open a file in read mode.
Get a character from the file and assign it the character variable.
When the value of character variable is not equal to end of file,
Print the character.
7. Repeat the steps 5 and 6.
8. Close the file.
9. Stop.
APPENDING THE CONTENT INTO FILE
AIM
To write a C program to append the content into a file.
ALGORITHM
1.
2.
3.
4.
5.
6.
7.
Start.
Declare a file pointer.
Declare a character variable.
Open a file in append mode.
Print the content to be appended into the file.
Close the file.
Stop.