Tag Archives: use

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’ 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 »

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 »