//PROGRAM TO CHECK SYNTAX OF for STATEMENT
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void main()
{
FILE *fp1,*fp2;
char a[100],ch,b[50];
int col=0,i=0,bra1=0,bra2=0,flag=0;
clrscr();
fp1=fopen("c:\\file1.txt","w");
if(fp1==NULL)
{
printf("\n ERROR IN OPENING FILE ... ");
getch();
exit(0);
}
else
{
printf("\n ENTER THE for STATEMENT ... ");
gets(a);
fprintf(fp1,"%s",a);
for(i=0;i<3;i++)
b[i]=a[i];
b[i]=0;
if(strcmp(b,"for")!=0)
{
printf("\n ERROR: UNDEFINED SYMBOL for ");
getch();
exit(0);
}
if(a[i]=='(')
flag=1;
else
flag=0;
fclose(fp1);
fp1=fopen("c:\\file1.txt","r");
while(1)
{
ch=getc(fp1);
if(ch==EOF)
break;
else if(ch=='(')
bra1++;
else if(ch==')')
bra2++;
else if(ch==';')
col++;
}
if(flag==0)
printf("\n ERROR: UNDEFINED SYMBOL for ");
else if(bra1!=1)
printf("\n ERROR: BRACKET ERROR '(' ");
else if(bra2!=1)
printf("\n ERROR: BRACKET ERROR ')' ");
else if(col!=2)
printf("\n ERROR: SEMICOLON ERROR ';' ");
else
printf("\n NO ERROR: ");
}
fclose(fp1);
getch();
}
basic unit of C is structure like procedure ,syntax's, error's compiler etc
then your program will never ends, too unless you pressing the ctrl+c or kill it through your os. can i know the purpose of you creating the loop that never ends? is it just a mistake or are you doing it on purpose?
It's a syntax error, which is detected during compilation, yes.
The Java language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities
In C (and C++ and Java), the semicolon is used to mark the end of a statement. It is also used the separate the expressions in a for loop.
for(i=0;i<=0;i++)
Compilers check correctness of your program syntax, memory allocation procedures and so on.
odd loop means at least the loop execute once.
"C" is a programming language. It is implemented by writing a program using the C syntax and then translated by a compiler, which is an application program.
Exactly what do you mean by 'C program in Java'
Wr
yes
for (<exp1>; <exp2>; <exp3>) <statement> exp1 and exp3 are optional; statement can be null-statement or block-statement. Correction: All expressions are optional. An infinite loop has no expressions: for(;;);
Not used
You have to be more specific. What part of C syntax? Do you want the syntax for outputing a number or sentence, do you want to syntax for creating a array, struct, a user defined function or what? #include iostream using namespace std; int main { cout << "Hello World!" << endl; return 0; };
for is a loop in C++. It is used to repeat some instructions for required time. Syntax : for(counter initialization;condition;counter update) e.g. //Program to print numbers from 1-100 #include<iostream.h> #include<conio.h> void main() { int i; for(i=1;i<=100;i++) cout<<i<<endl; getch(); }
basic unit of C is structure like procedure ,syntax's, error's compiler etc