Tag Archives: given

Write a program to count the number of characters and words in a given file. 10m Jun2007

Write a program to count the number of characters and words in a given file. 10m Jun2007  #include<stdio.h> #include<process.h> void main() { FILE *fp; int chr=0,wrd=1,str; clrscr(); if((fp=fopen(“test.txt”,”r”))== NULL) { printf(“File does not exist\n”); exit(0); } while(!(feof(fp))) { str=fgetc(fp); if(str==’ ‘) wrd++; chr++; } printf(“The number of characters in file :%d\n”,chr); printf(“The number of words… Read More »

Write an algorithm and draw a corresponding flowchart to print the sum of all integers starting from 2 to the given positive integer x where x >= 2. 10m Dec2006

Write an algorithm and draw a corresponding flowchart to print the sum of all integers starting from 2 to the given positive integer x where x >= 2. 10m Dec2006 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… Read More »

Write a recursive program in ‘C’ to find the L.C.M. (Least Common Multiple) of two given numbers. 10m Dec2006

Write a recursive program in ‘C’ to find the L.C.M. (Least Common Multiple) of two given numbers. 10m Dec2006 #include<stdio.h> int lcm(int,int); void main() { int NUM1,NUM2,LCM; clrscr(); printf(“ENTER ANY TWO POSITIVE NUMBERS TO FIND ITS L.C.M. : “); scanf(“%d%d”,&NUM1,&NUM2); if(NUM1>NUM2) LCM = lcm(NUM1,NUM2); else LCM = lcm(NUM2,NUM1); printf(“LCM OF TWO NUMBERS IS %d”,LCM); getch();… 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 »

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 »

Write an algorithm and draw a corresponding flowchart to search a number in the given list of numbers and also display its position. 10m Dec2005

 Write an algorithm and draw a corresponding flowchart to search a number in the given list of numbers and also display its position. 10m Dec2005  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 »

Write a recursive program in ‘C’ to find whether a given five digit number is a palindrome or not. 10m Dec2005

Write a recursive program in ‘C’ to find whether a given five digit number is a palindrome or not. 10m Dec2005 #include<stdio.h> int flag=0; void palin(int,int*); void main() { int a; clrscr(); printf(“Enter the number “); scanf(“%d”,&a); palin(a,&a); if(flag==0) printf(“\nThe number is palindrome…”); else printf(“\nThe number is not palindrome…”); getch(); } void palin(int x,int* y)… Read More »

Design an algorithm and draw corresponding flowchart to find all the prime numbers between two given numbers ‘m’ and ‘n’, where m, n > 0. 10m Dec2005

Design an algorithm and draw corresponding flowchart to find all the prime numbers between two given numbers ‘m’ and ‘n’, where m, n > 0. 10m Dec2005 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… Read More »

Write a program in ‘C’ to find the length of a given string including blank spaces, tabs and other special symbols use “Pointers” concept. 10m Dec2005

Write a program in ‘C’ to find the length of a given string including blank spaces, tabs and other special symbols (new line character should be taken as a string terminating character) Note : You should use “Pointers” concept. 10m Dec2005   Use while(str[i] != “\n”)  instead of while(*str)   Solved program can be found… Read More »

Write a program in ‘C’ to add the given number of days to the current date and print the (final) resultant date. (for e.g. adding 12 days to 22/08/2005 will result in 03/09/2005) 10m Dec2005

Write a program in ‘C’ to add the given number of days to the current date and print the (final) resultant date. (for e.g. adding 12 days to 22/08/2005 will result in 03/09/2005)  10m Dec2005     #include <time.h> #include <stdio.h> void  main() { struct tm date = {0} ; time_t timer; clrscr(); timer=time(NULL); date =… Read More »