0% found this document useful (0 votes)
23 views

Computer Programming in C-Assignment November 2024

Uploaded by

blackcreator420
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Computer Programming in C-Assignment November 2024

Uploaded by

blackcreator420
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment

Subject: Computer Programming in C Session: 2024-25


Subject code: 307/1(N) 2nd Yr 3rd Sem
----------------------------------------------------------------------------------------------------------------------------- -
Answer of all the questions in standard format and submit hard copy within 8th November 2024.

1. a) What is keyword? Give four examples of keywords.


b) Define user defined function. Why are they needed?
c) What is the output of the following piece of code?
int i = 1, j = 1;
for( i = 1; i < 4; i++)
{
for( j = 1; j < 4; j++)
{
if(i == j)
break;
prinf(“%d %d”, i, j);
}
}
d) What is the output of the following program?
int main()
{
char *str="ABCDEF";
str++;
printf("%s ",str);
}
e) Differentiate between while loop and do-while loop.
f) What are the advantages of switch-case statements over nested if-else structures?
g) What do you mean by precedence and associativity of an operator?

2.a) Differentiate between gets() and scanf() functions.


b) Describe various storage classes of C variable with suitable example.

3.a) Distinguish between formal arguments and actual arguments in function calling.
b) Write a recursive function to get GCD of two numbers.

4.a) Write a C program to display list of all leap years between 1800 and 2200.
b) Explain conditional operator with suitable example.

5.a) Write a program to enter a number and then calculate the sum of its digits.
b) What will be the output of the following code?
main()
{
int x = 3, y, z;
y=x=10;
z=x<10;
printf(“\n x = %d, y = %d, z = %d”,x,y,z);
}
6.a) What happens when an array is initialized with fewer initializers as compared to its size?
b) Write a program to count the total number of non-zero elements in a two-dimensional array.

1
7.a) How are arrays related to pointers? Explain with example.
b) Write a program in C to find the length of a string without using library functions.

8.a) Write a program to swap two integers using call by reference of passing arguments to a function.
b) What will be the output of the following program?
main()
{
int arr[] = {1,2,3,4,5};
int *ptr, i;
ptr = arr + 4;
for(i = 0; i < 5; i++)
printf(“ %d”, *(ptr - i));
}

You might also like