Re: Re: C- help with Clear screen

Home Forums C Programming C- help with Clear screen Re: Re: C- help with Clear screen

#3466

This version works with this file format:

A for loop is designed to

a.)run only if the condition is false
b.)run a set number of times
c.)run at least once
d.)run when there are no conditions
@
A while loop is designed to

a.)run only if the condition is true
b.) run a set number of times
c.)run at least once
d.)run when there are no conditions
@

code :

#include
#include

int main ( void )
{

int questionNum;
char questions [ 80 ];
char c; /*variable to hold character input by user*/
char choice[2]; /*create character array*/
int i = 0; /*initialize counter i*/
FILE * pFile;
char ch;
pFile = fopen ( “c:\programs\data2.txt” , “r” );
if ( pFile == NULL )
{
perror (“FILE COULD BE OPEN”);
return 1;
}

ch = getc ( pFile );
while ( ! feof ( pFile ) )
{

printf(“n___________________n”);
printf(“n Question n”);
printf(“___________________nn”);

while ( ch != ‘@’)
{
putchar ( ch );
ch = getc ( pFile );
}/*end else*/
printf( “nnENTER YOUR ANSWER HERE: “); /*prompts user to input answer*/
c = getchar ();
getchar ();
choice [ i ++ ] = c;
ch = getc ( pFile );
printf ( “n press any ‘ENTER’ for next Questions: “);

}
printf ( “n answers: n” );
int j = 0;
while ( j < i )
{
putchar ( choice [ j ] ) ;
printf ( “n” );
j ++;
}

return 0;

}

0 Shares
Share
+1
Tweet
Share
Stumble