Posts

Showing posts with the label c string

Lexical Analysis

Write a program to get the following equation as input from a file and create token(s) on another file for the possible variable to get the value from the user. After get the value from the user, regenerate all the token(s) on another file for calculation .  Equation: x = (a+b)/2 + 4*b

c program to calculate any kind of equation

Write a program using c/c++/java, which can calculate any kind of equation. Implement the concept of Lexical with Semantic Analysis. Sample input: x = (a+b)/2 + 4*b. << Go to Index Page >>

c program to count vowel, consonant, arithmetic operator, special character, word and sentence from a multiple line string

Write a c program to count vowel, consonant, arithmetic operator, special character, word and sentence from a string in a file and save the output in another file << Go to Index Page >>

c program to count vowel, consonant, arithmetic operator, special character, word and sentence

Write a c program to count vowel, consonant, arithmetic operator, special character, word and sentence from a string in a file and save the output in another file << Go to Index Page >>

c program to read a string from a file and write it to the another file

Write a c program to read a string from a file and write it to the another file << Go to Index Page >>

c program to read a string from a file

Write a c program to read a string from a file << Go to Index Page >>

c program to write a string into a file

Write a c program to write a string into a file << Go to Index Page >>

c program to count word and sentence

Write a c program to count word and sentence from a given string as like "I love Bangladesh." << Go to Index Page >>

c program to count vowel and consonant

Write a c program to count vowel and consonant from a given string as like "I love Bangladesh" # include <stdio.h> main(){ int i , con=0 , vow=0 , space=0 , sentence=0; char ch[]="i love bangladesh."; for(i=0;ch[i]!='\0';i++){ if(ch[i]=='A' || ch[i]=='a' || ch[i]=='E' || ch[i]=='e' || ch[i]=='I' || ch[i]=='i' || ch[i]=='O' || ch[i]=='o' || ch[i]=='U' || ch[i]=='u'){ vow++; } else if(ch[i]==' '){ space++; } else if(ch[i]=='.'){ sentence++; } else{ con++; } } printf("number of consonant is : %d \n",con); printf("number of vowel is : %d \n",vow); } << Go to Index Page >>

string array sorting using bubble sort algorithm

Bubble sort in string array #include <stdio.h> #include <conio.h> #include <string.h> #define MAX 50 #define N 2000 void sort_words(char *x[], int y); void swap(char **, char **); int main(void) { char word[MAX]; char *x[N]; int n = 0; int i = 0; for(i = 0; scanf("%s", word) == 1; ++i) { if(i >= N) printf("Limit reached: %d\n", N), exit(1); x[i] = calloc(strlen(word)+1, sizeof(char)); strcpy(x[i], word); } n = i; sort_words(x, n); for(i = 0; i < n; ++i) printf("%s\n", x[i]); return(0); } void sort_words(char *x[], int y) { int i = 0; int j = 0; for(i = 0; i < y; ++i) for(j = i + 1; j < y; ++j) if(strcmp(x[i], x[j]) > 0) swap(&x[i], &x[j]); } void swap(char **p, char **q) { char *tmp; tmp = *p; *p = *q; *q = tmp; } << Go to Index Page >>