P
prasoonthegreat
Consider the following code......
#include<stdio.h>
#include<stdlib.h>
int fact()
{
int i , j=1;
if( scanf ( "%d" , &i )) {
while( i ) {
if ( j = j * i-- ) {
}
}
if( printf ( "%d" , j )) {
{}
}
}
exit(0);
return 0;
}
int x=fact();
int main(){}
This is not a valid C program......(since initializer used to
initialize a global variable is not a constant)
The code is to be modified such that it should work without having
anything inside main( )......
What are the necessary modifications required to have a successful
compilation.......
Prasoon
#include<stdio.h>
#include<stdlib.h>
int fact()
{
int i , j=1;
if( scanf ( "%d" , &i )) {
while( i ) {
if ( j = j * i-- ) {
}
}
if( printf ( "%d" , j )) {
{}
}
}
exit(0);
return 0;
}
int x=fact();
int main(){}
This is not a valid C program......(since initializer used to
initialize a global variable is not a constant)
The code is to be modified such that it should work without having
anything inside main( )......
What are the necessary modifications required to have a successful
compilation.......
Prasoon