Tag Archives: 2009

What are the precautions that must be taken care to use macros in ‘C’? 5m Dec 2009

What are the precautions that must be taken care to use macros in ‘C’?   Caution in using macros You should be very careful in using Macros. In particular the textual substitution means that arithmetic expressions are liable to be corrupted by the order of evaluation rules (precedence rules). Here is an example of a… Read More »

Explain fscanf ( ) statements with an example. 10m Dec 2009

Explain fprintf ( ) and fscanf ( )statements with an example of each. 10m Dec 2009 fscanf() Declaration int fscanf ( FILE * stream, const char * format, … ); Description Read formatted data from stream Reads data from the stream and stores them according to the parameter format into the locations pointed by the additional arguments. The additional… Read More »

What is pointer variable? How its declared? How its address is determined? How pointer can be used to pass an entire array to a function in C? 10m Dec 2009

What is pointer variable? How is a pointer variable declared? How is the address of a pointer variable determined? How pointer can be used to pass an entire array to a function in C? Explain with the help of an example. 10 An ordinary variable is a location in memory that can hold a value.… Read More »

Explain syntax of switch case statement in ‘C’ language. Also compare switch case with if else statement. 5m Dec 2009

Explain the syntax of switch case statement in ‘C’ language. Also compare the performance of switch case with if else statement. 5m Dec 2009   The Switch Statement Its objective is to check several possible constant values for an expression, something similar to what we had studied in the earlier sections, with the linking of… Read More »

What is scope of a variable ? Differentiate between Global and Local variables

What do you mean by scope of a variable ? Differentiate between Global and Local variables giving an example of each. 5m Dec 2009  Scope of a Variable Scope of a Variable means the bondaries of the variable in which it appears and can be accessible.   Global vs. Static variables: Global variables are recognized… Read More »

List and explain bitwise operators in ‘C’. 10m jun2009

List and explain bitwise operators in ‘C’. 10m The following table lists the Bitwise operators supported by C. Assume variable ‘A’ holds 60 and variable ‘B’ holds 13, then – Operator Description Example & Binary AND Operator copies a bit to the result if it exists in both operands. (A & B) = 12 i.e.,… Read More »

Explain the meaning and usage of each of the following function prototypes. jun2009

Explain the meaning and usage of each of the following function prototypes: 5×2=10m (i) getch ( )       (ii) strcmp ( )         (iii) getchar ( )       (iv) gets ( )        (v) puts ( ) (i) getch ( ) getch ( ) gets a character from console but… Read More »

Write a Program in ‘C’ to copy one file to another. The program should read the filenames at command line. 10m Jun2009

Write a Program in ‘C’ to copy one file to another. The program should read the filenames at command line. 10m Jun2009 Code: #include<stdio.h> int main(int argc,char *argv[]) { FILE *fs,*ft; int ch; if(argc!=3) { printf(“Invalide numbers of arguments.”); return 1; } fs=fopen(argv[1],”r”); if(fs==NULL) { printf(“Can’t find the source file.”); return 1; } ft=fopen(argv[2],”w”); if(ft==NULL)… Read More »

Write a Program in ‘C’ to print the following output ‘n’ rows. 10m june2009

Write a Program in ‘C’ to print the following output ‘n’ rows. For example, if n=3, the following should be output by the program: 10m june2009   #include <stdio.h> void main() { int I,J,N=3,K=0,ODD=1,SPACE; clrscr(); SPACE=N; for(I=1;I<=N;I++) { for(J=1;J<SPACE;J++) { printf(” “); } K=0; for(J=1;J<=ODD;J++) { if(J<=I) { K++; } else { K–; } printf(“%d… Read More »

Write a program that does not use the inbuilt string function to concatenate two strings 10m Jun2009

Write a program that does not use the inbuilt string function to perform the following: 10m Jun2009 (ii) To concatenate two strings Code:- #include<stdio.h> void main() { void str_concat(char*,char*,char*); char Str1[50],Str2[50],Str3[100]; clrscr(); printf(“\nENTER FIRST STRING TO CONCATE : “); scanf(“%s”,&Str1); printf(“\nENTER SECOND STRING TO CONCATE : “); scanf(“%s”,&Str2); str_concat(Str1,Str2,Str3); printf(“\nSTR1 IS : %s”,Str1); printf(“\nSTR2 IS :… Read More »