Tag Archives: 2006

Design an algorithm and draw corresponding flowchart to print the value of the number in words when the number entered is in the range of 1 to 299. 10m Dec2006

Design an algorithm and draw corresponding flowchart to print the value of the number in words when the number entered is in the range of 1 to 299. 10m Dec2006 #include <stdio.h> #include <string.h> #include <stdlib.h> void main() { char num[3]; void convert_to_words(char*); clrscr(); printf(“Enter any number between 1 to 299 : “); scanf(“%s”,&num); convert_to_words(num);… Read More »

Using pointers, write a program in ‘C’ to count the occurrence of each character in a given string. 10m Dec2006

Using pointers, write a program in ‘C’ to count the occurrence of each character in a given string. 10m Dec2006   #include <stdio.h> #include <string.h> void main() { char string[100],*ptr; int c=0,count[26]={0}; clrscr(); printf(“Enter a string\n”); gets(string); ptr=string[0]; while (*ptr) { /* Consider characters from ‘a’ to ‘z’ only */ if ( ptr >= ‘a’… Read More »

Write a program in C’ that accepts 10 words of varying length and arranges the words in the descending order of word length. Use arrays. 10m Dec2006

Write a program in C’ that accepts 10 words of varying length and arranges the words in the descending order of word length. Use arrays. 10m Dec2006 #include<stdio.h> #include<string.h> void main() { int i,j; char array[10][10],temp[10]; clrscr(); printf(“Enter ten words : \n”); for(i=0;i<10;i++) { printf(“%d : “,i+1); gets(array[i]); } for(i=0;i<10;i++) { for(j=i;j<10;j++) { if(strlen(array[i])<strlen(array[j])) {… Read More »

Write a program in ‘C’ for the addition of two polynomials. Use Arrays and Structures. 10m Dec2006

Write a program in ‘C’ for the addition of two polynomials. Use Arrays and Structures. 10m Dec2006 #include<stdio.h> void main() { int poly1[6][2],poly2[6][2],term1,term2,match,proceed,i,j; printf(“Enter the number of terms in first polynomial : “); scanf(“%d”,&term1); printf(“Enter the number of terms in second polynomial : “); scanf(“%d”,&term2); printf(“Enter the coeff and expo of the first polynomial:\n”); for(i=0;i<term1;i++)… Read More »

Design an algorithm, draw a corresponding flow chart and write a program in C, to print the Fibonacci series.10m Jun2006

Design an algorithm, draw a corresponding flow chart and write a program in C, to print the Fibonacci series.10m Jun2006 An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in pseudo code – something resembling C language or Pascal, but with some statements in English… Read More »

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 »

Summarize the purpose of the format strings (like %s, %d, %c) that are’ commonly used within the printf function, with an example for each.10m Jun2006

Summarize the purpose of the format strings (like %s, %d, %c) that are’ commonly used within the printf function, with an example for each.10m Jun2006 If printf function format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers. It can… Read More »

Design an algorithm, draw a corresponding flowchart and write a C program to check whether a given string is a palindrome or not. 10m Jun2006

Design an algorithm, draw a corresponding flowchart and write a C program to check whether a given string is a palindrome or not. 10m Jun2006 An algorithm is a finite set of steps defining the solution of a particular problem. An algorithm is expressed in pseudo code – something resembling C language or Pascal, but… Read More »