/* Fibonacci series using recursion */ #include<stdio.h> #include<conio.h> void main() {
Category: C programs
#include <stdio.h> #include <conio.h> void main()
/* Write a C program to find the sum of odd numbers and * * sum of even numbers from 1 to N. Output the computed * * sums on two different lines with suitable headings */
1 2 3 |
/* Implementation of SLR Parser */ #include<stdio.h> |
1 |
#include<ctype.h> |
1 |
#include<conio.h> |
1 |
#include<stdlib.h><!--more--> |
1 |
#include<string.h> |
1 |
#include<iostream.h> |
1 |
#define epsilon '^' |
1 |
char prod[20][20],T[20],NT[20],c[10][10],foll[10][10],fir[10][10]; |
1 |
int tt,tnt,tp,a; |
1 |
int follow[20][20],first[20][20]; |
1 |
void first_of(char); |
1 |
int count(int j); |
1 |
void rhs(int j); |
1 |
void read_tnt(); |
1 |
int rhs(int j); |
1 |
void read_tnt() |
1 |
{ cout<<"For SLR parser: "; |
1 |
cout<<"\nEnter number of terminals: "; |
1 |
cin>>tt; |
1 |
cout<<"\nEnter terminals: "; |
1 |
for(int i=0;i<tt;i++) |
1 |
T[i]=getche(); |
1 |
getch(); |
1 |
cout<<"\nEnter number of Non-terminals: "; |
1 |
cin>>tnt; |
1 |
cout<<"\nEnter Non-terminals: "; |
1 |
for(i=0;i<tnt;i++) |
1 |
NT[i]=getche(); |
1 2 |
getch(); } <strong><span style="color: #ff0000;">Also Read : </span><span style="color: #ff0000;"><a title="Permalink to C program to implement lexical analyzer" href="http://csetips.catchupdates.com/c-program-to-implement-lexical-analyzer/" rel="bookmark"><span style="color: #ff0000;">C program to implement lexical analyzer</span></a></span></strong> |
1 |
void read_prod() |
1 |
{ int j; |
1 |
char x=0; |
1 |
cout<<"\n\nEnter number of productions: "; |
1 |
cin>>tp; |
1 |
cout<<"\n Enter productions: "; |
1 |
for(int i=0;i<tp;i++) |
1 |
{ j=x=0; |
1 |
while(x!='\r') |
1 |
{ prod[i][j]=x=getche(); |
1 |
j++; } |
1 |
cout<<"\n"; } |
1 |
getch(); } |
1 |
return(i); |
1 |
if(t=='$') |
1 |
return(tt); |
1 |
return(-1); } |
1 |
int terminal(char x) |
1 |
{ for(int i=0;i<tt;i++) |
1 |
if(T[i]==x) |
1 |
return(1); |
1 |
return(0); } |
1 |
int nonterminal(char x) |
1 |
{ for(int i=0;i<tnt;i++) |
1 |
if(NT[i]==x) |
1 |
return(1); |
[…]
/* Before moving towards the program, a little introduction to the one who dose not know what is palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction i.e if we look from the backwards or from the front […]
/* Before moving towards the program, a little introduction to the one who dose not know what is palindrome. A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction i.e if we look from the backwards or from the front […]