Guru Gobind Singh Indraprastha Vishwavidyalaya 2003 B.Tech ETCS – 109 Subject : Introduction to Computers - Question Paper
Wednesday, 29 May 2013 04:50Web
Page 2 of 2
}(d) This function allows a user to repeatedly input a number till she enters 'N' to a ques.. 4
int getnum()
{
char ans; int num;
while(ans!='N') {
printf?("Any more numbers?\n");
if((ans=getchar())!='N'&&ans!='n')
num=getchar(); }
return num;
}
Q3
Write (1) an iterative function (2) a recursive function for calculating the factorail of a number. Compare the 2 versions in terms of : 5
(i) Total number of function calls.
(ii) Maximum number of local variables stored during the execution of the program.
Write a recursive function which reverses a string ranging from provided begin and end positions. 5
Enumerate 3 advantages of writing C programs as a collection many small functions. 5
Q4
What is the output of the subsequent program? The user inputs the strings “Indraprastha” and “University”.7
#include
#include
int main(void)
{
char s1[80],s2[80];
char *c;
scanf("%s",s1);
scanf("%s",s2);
printf("Lengths of the 2 strings are: \n%d%d
\n",strlen(s1),strlen(s2));
strcat(s1,s2);
printf("%s\n",s1);
if(strchr(s2,'a')) printf("a is in %s\n",s2);
c=strstr(s1,"Univ");
printf("%s\n",c);
return 0;
}Write a program which allows the user to input lines of text till she enters a 'O' (the program should display prompts to do this). After inputting all the lines, the program redisplays the lines entered. 7
An array has been initialised as int arr[4][3]={0,1,2,3,4,5,6,7,8,9,10,11}; Write the contents of the following:- 3
arr[1][1]
*((int*)txt+5)
*((int*)(&txt[3]+1)
Q4
elaborate the standard I/O streams opened automatically when a program begins execution. Write the prototype of the library function which redirects a standard I/O stream from/to a new file. provide an example where the standard output has been redirected to a file named “Result”. 3
Write a program which reads a file, reverses every word in it (words are separated by blanks, full-stops, newlines and tabs), and outputs them to a different file. 8
Write a program which modifications every tenth byte of a file to the character '$', starting from the beginning of the file. 4
Q6
discuss the various kinds of accesss modifiers in C. 4
Write a program which inputs a short integer and prints its multiples in powers of 2, using shift operators. Take care that there are no overflows. 6
Write a function that executes an infinite loop, within which it inputs a string. Compares it with a string placed as its parameter and comes out of the loop only is a match is found. 5
Q7
Make a flowchart for sorting an array of numbers in ascending order, using any algorithm. 5
Write short notes on: 6
The DOS and Unix operating systems
The world wide web
discuss the subsequent constructs, illustrating their uses:- 4
The ? “alternative” operator in C.
The break, continue on and the default choices in case statement.
Earning: Approval pending. |