Tag Archives: following

Write a program that does not use the inbuilt string functions to perform the following: 10m Jun2006

Write a program that does not use the inbuilt string functions to perform the following: 10m Jun2006 (i) To compare two strings [codesyntax lang=”c”] #include<stdio.h> void main() { int str_cmp(char*,char*); char Str1[50],Str2[50]; int val; clrscr(); printf(“\nENTER FIRST STRING TO COMPARE : “); scanf(“%s”,&Str1); printf(“\nENTER SECOND STRING TO COMPARE : “); scanf(“%s”,&Str2); val=str_cmp(Str1,Str2); if(val==0) printf(“\nSTR1 IS… Read More »

A C program contains the following declarations: 10m Jun2006

A C program contains the following declarations: 10m Jun2006 int i, j; long iX; short S; float X; double dX; char C; Determine the resultant data type of each of the following expressions: (i) i + C                        – int (resultant data type) (ii) X + C                     – float (resultant data type) (iii) dX + X                … Read More »

Explain the meaning of each of the following functions prototypes and mention the return data type of each of them: 10m Jun2006

Explain the meaning of each of the following functions prototypes and mention the return data type of each of them: 10m Jun2006   (i) double f(double a, int b);  –   This function has two arguments, first of double data type and second of int data type. The return data type is double.   (ii) void… Read More »

Write the functions to perform the following : 10m Dec2005

Write the functions to perform the following : 10m Dec2005  To accept a string and print the rightmost “n” characters   #include<stdio.h> #include<string.h> #include<alloc.h> char *rightsub(char *,int n); void main() { char s1[20],s2[20],ch,*s; int n; clrscr(); printf(“enter the string s1:”); gets(s1); printf(“enter the no of characters to extract=”); scanf(“%d”,&n); s=rightsub(s1,n); printf(“\nright sub string: %s”,s); free(s); getch();… Read More »

Write a symbolic constant or a macro definition for each of the following : 9m Dec2005

 Write a symbolic constant or a macro definition for each of the following : 9m Dec2005 (i) Define a macro called AREA, which will calculate area of circle in terms of radius. Use the constant PI in calculation. # include<stdio.h> # define PI 3.142857 # define AREA(radius) PI * radius * radius main( ) {… Read More »

Write the syntax and explain the purpose of the following function: Fprintf( ) 2m Dec2005

Write the syntax and explain the purpose of the following function: 2m Dec2005   (iii) Fprintf( ) Description The C library function int fprintf(FILE *stream, const char *format, …) sends formatted output to a stream. Declaration Following is the declaration for fprintf() function. [codesyntax lang=”c”] int fprintf(FILE *stream, const char *format, …) [/codesyntax]Parameters stream — This… Read More »

Write the syntax and explain the purpose of the following functions : Fclose() 2m Dec2005

Write the syntax and explain the purpose of the following functions : 2m Dec2005 (ii) Fclose( ) Description The C library function int fclose(FILE *stream) closes the stream. All buffers are flushed. Declaration Following is the declaration for fclose() function. [codesyntax lang=”c”] int fclose(FILE *stream) [/codesyntax]Parameters stream — This is the pointer to a FILE… Read More »

Write the syntax and explain the purpose of the following functions : Fseek() 2m Dec2005

Write the syntax and explain the purpose of the following functions : 2m Dec2005 (i) Fseek( ) Description The C library function int fseek(FILE *stream, long int offset, int whence) sets the file position of the stream to the given offset. Declaration Following is the declaration for fseek() function. [codesyntax lang=”c”] int fseek(FILE *stream, long… Read More »

Write the functions to perform the following : 10m Dec2005

Write the functions to perform the following : 10m Dec2005   (i) To find mn where m, n > 0 #include<stdio.h> void main() {  long int power(int,int);  int M,N;  long int RES;  printf(“ENTER M : “);  scanf(“%d”,&M);  printf(“ENTER N : “);  scanf(“%d”,&N);  RES=power(M,N);  printf(“\nRESULT IS %ld “,RES);  getch(); } long int power(int M,int N) {  long… Read More »