Assignment For IP April25
Assignment For IP April25
int main()
{
int N = 2 + 1;
if (N == 4)
{
/* unreachable code */
printf("equal");
}
return 0;
}
21. Find the output of the following code
Void main()
{
int val=1;
do{
val++;
++val;
}while(val++>25)
printf(“%d\n”,val);
}
f(x)=x-x3/3!+x5/5!-x7/7!+..
2) What are void pointers? Explain difference between null and void pointer.
3) Write a C program to reverse a 1D array using pointers (no indexing).
4) Write a program to find GCD using recursive function.
5) Write a program to implement the following diagram using for loop.
*
***
*****
*******
*********
6) Explain the use of multi-dimensional arrays.
7) Write the output:
a) void main(){
int m[2];
int *p=m;
m[0]=100;
m[1]=200;
printf("%d%d",++*p,*p);
}
b) void main()
{
int val=1;
do{
val++;
++val;
}while(val++>25);
printf("%d\n",val);
}
8) What are pre-processor directives? Differentiate between macro and function with
necessary examples.
9) Write a program to sort an array in ascending order using pointers.
10)Write a program to count vowels and consonants in a string.
11)Compute the address of marks[18][4] in a 20×5 array stored in row-major order.
Base = 1000, word size = 2.
12)Describe string. Explain any three string handling function with examples.
13)Differentiate between(Any two):
1. (i) Write a C program to implement a function that reverses a given 1D matrix of integers
in-place, using only pointers (no array indexing allowed).
(ii) Write a C program that demonstrates the behavior of all four storage classes (auto,
register, static, and extern) by printing their values across multiple function calls and files.
2. Compare and contrast dynamic memory allocation using malloc() and static memory
allocation for arrays in C. Discuss the advantages and limitations of each approach with
respect to flexibility, memory usage, and execution time.
3. What is function? Describe different function prototype. Write a program to calculate the
sum of squares of first n even numbers.
(ii) Consider a 20×5 two-dimensional array marks which has base address=1000 and
number of words per memory location of array =2. Now compute the address of the
element marks [18,4] assuming that the element are stored in a row major order.