Advanced 'C' Programming : FYBCS : Semester II : PYQ - BCS Guruji

Ad

Thursday, March 16, 2023

Advanced 'C' Programming : FYBCS : Semester II : PYQ

 Chapter 1: Pointers

1 mark

--Q. What is pointer variable? Give example.

Q. What is the use of * operator?

Q. What is formal parameter?

--Q.What is dynamic memory allocation?

Q. While passing array to a function, address of first element of array is passed.State true or false.

Q. What is the meaning of & and * operators in pointer ?

2 mark

Q. Differentiate between static & dynamic memory allocation.

4 mark

Q. Explain various operations possible on pointers.

-Q. Explain the concept of pointer to pointer with example.

Q. Explain actual parameters and formal parameters.

Q.  Explain malloc and calloc functions with example.

Q. Write short notes on the following with example :

 (a) Call by value (b) Call by reference.

Q. Explain two methods of passing arguments to function with example.

Programs [4 mark each]

Q. Write a ‘C’ program to calculate area, & perimeter and diameter of circle using one function for all & use pointers.

Q. Write a ‘C’ program to accept a time from user as hh:mm:ss & check the validity of it. If it is invalid, validate it. Use pointer to structure.

Q. Write the output of following code . Justify

#include<stdio.h>

void main()

{

char *S="hello";

char *P=S;

printf("%c\t%c",*(p+3),s[1]);

}

Q. Find and justify output of the following:

main()

{

int p[6]- {1,2,3,4,5,6};

int *ptr= p;

printf("%d", *(p+4));

printf("%d",p[2]);

printf("%d", *ptr);

}

Q. What is the output of following C code? Justify. 

int main ( ) 

int a =5, b = 10, c = 7; 

predict ( a, & b, c); 

printf (“% d - % d- % d”, a, b, c); 

void predict (int p, int *q, int r) 

p = 50; 

*q = *q * 10;

 r = 77; 

}

Q. Find and justify the output of the following program : 

main( ) 

int x [25]; 

x[0] = 100; 

x[24] = 400; 

printf (“\n %d %d”, *x, *(x + 24) + * (x + 0)); 

}

Q. main( ) 

struct student *ptr=stu; 

for (i=0, i<4; i++) 

printf("At address % u : %.s % d", ptr, ptr  name, ptr  rollno); 

ptr ++; 

} }

Q. What is the output of the following program?

void main ()

{

char str[]="program";

char *ptr= str;

printf("%c%c",*ptr,*ptr+4);

ptr= ptr+3;

printf("%c%c", *ptr, *(ptr+2));

}

Q. What is output of following code, justify:

int change(int x, int *y)

{

x=x+5;

*y=*y+5;

}

main()

{

int a=10, b=20;

change(a,&b);

printf("%d%d",a,b);

}


Q. Find and correct error in the following code : 

#include(stdio.h) 

int main() 

char ch='c'; 

const char *ptr=&ch; 

*ptr='a'; 

return 0; 

}

Chapter 2: Strings

1 mark

Q. What is the use of strcpy() function in C?

Q. What is the use of strncat () function.

Q.Demonstrate puts () function.

-Q. What is string? Give example.

Q. Which function is used to join two strings? Give syntax.

-Q. Write any two string functions

Q. State the use of fopen() function.

2 mark 

Q. Explain the use of fgets() and fputs() with suitable example

4 mark

Q. Write a menu driven program using string library functions for :

-(i) length of string

(ii) comparing two strings.

(iii) copy of string

(iv) concatention of two string.

Q. Explain any four string handling functions with usage.

Q.  Give syntax and use of following functions:

i) strlen ii) strcat iii) strcmp iv) strcpy v) strrev vi)strupr (vii)strlwr

Program [4 mark each]

Q. Give syntax and use of following functions:

 i) getchar ii) putchar iii) puts iv) printf v) scanf vi)putc vii) gets()

Q. Write 'C' program to copy one string to another without using standard library function such that the cases of the characters are inverted. [e.g. Delhi o/p dELHI]

Q. Write a ‘C’ program to accept a string & convert in uppercase without using built - in function

Q. Write a 'c' program to insert a number of characters of substring at given positin in string. (eg: s1=abcedf , s2= pqr, position = 2, o/p=abcpqrdef.)

Q. What is the output of following C code? Justify. 

int main ( ) 

static char name [] = “programming”; 

char *s ;

 s = & name [6] - 4; 

while (*s) 

printf (“%c”, * s ++); 

}

Q. What is the output of following code? 

# include 

int main () 

char str[100]; 

char *ptr; 

strcpy(str, “India is GREAT”); 

ptr = str + strlen (str)

printf (“The string is:”); 

while (*ptr ! = str) 

printf (“%c”, *ptr --); 

return 0; 

}

Chapter 3: Structures and Unions

1 mark

Q.  Demonstrate “structure within structure” with example.

-Q.  Give the difference between structure and union.

Q. What is size of the following union ?

union xyz

{

int x[20];

char s[20];

}

4 mark

----Q. Differentiate structure and union.

Program [4 mark each]

Q. Write a C program to declare book structure (bookno, bookname, author). Accept details of n books and display books of particular author.

Q. Write a program in ‘C’ to accept details ‘n’ employees & print the details of highest salaried employee. Use structure to store the employee data.

Q. Write a 'C' program for creating a structure employee with employee number, employee name and salary. Accept details of n employees and display the employee details having the highest salary.

Q. Predicate the output for the following : 

(a) Struct student 

char name [10]; 

int rollno; 

stu[4]= { "smaran", 1, "sankalp", 2, "spandan", 3, "sarthak", 4 }

Q. What is the output of following C code? Justify. 

struct employee 

char ename [20]; 

int empno; 

} el, * ptr, e[20]; 

int main ( ) 

printf (“\n%d”, sizeof (el));

 printf (“\n%d”, sizeof (ptr)); 

printf (“\n%d”, sizeof (el)); 

}

Q. Write a ‘C’ program to count no. of digits, no. of spaces, no. of lower case letters and no. of upper case letters from a given input string.

Q. Write a program to accept student information using structure (roll number, name, percentage) for n students. Display student details having highest percentage.

Q. Write a 'C' program to store the information of player with attributes: name, number of innings and total score. Calculate the average score of each player an display information of all players.

Chapter 4: File Handling

1 mark

Q. What is file opening mode.

Q. Which function is used to move file pointer?

Q.  Give the use of rewind ( ) function.

2 mark

Q. Explain the file opening modes for text file.

4 mark

Q. Write 'C' program to create a new file and accept data from user and save it in file. Display the count of total number of characters from file.

-Q. Write a ‘C’ program to copy the contents of one file to another file.

-Q. Write a program to copy the contents of one text file to another.

Q. Write the output of following code:

#include 

int print(int a, int b) 

printf(''\n a=%d\n'', a); 

printf(''\n b=%d\n'', b); 

 return 0; 

main() 

int(*fptr) (int, int); 

fptr=print; print(2, 3); 

fptr(2, 3); 

return 0; 

Q.  Define file. Explain any four file functions.

Q. Explain following functions with syntax and example.fgetc(), fputc(), fscanf (), fprintf ().

Q. Write a C program to read a file and display alternate characters from a file.

Q.  Explain the following functions with proper syntax : 

(1) fflush( ) (2) remove( ) (3) rename( ) -(4) ftell( )

fclose(), fopen(), fgets(), fputs(), fcloseall()

fread(), fwrite()

Chapter 5: Preprocessor

1 mark

--Q.What is macro?

---Q. Define preprocessor.

---Q. What is command line argument.

Q. Demonstrate type def keyword with example.

2 mark

 Q. What is the use of # include directive.

Q. Explain in brief concept of macros.

4 mark

Q. Differentiate between function and macro.

Q. Explain macro preprocessor directives with suitable example.

Q. How are command line arguments declared? Give the advantages of command line arguments.

Q. Differentiate macros and functions.

Q. Explain : (i) Simple macro substitution (ii) Macros with argument (iii) Nesting of macros.


No comments:

Post a Comment