(a)
#include<stdio.h>
int addmult(int, int);
int main()
{
int i = 3, j = 4, k, l ;
k = addmult ( i, j ) ;
l = addmult ( i, j ) ;
printf ( "\n%d %d", k, l ) ;
return 0;
}
int addmult ( int ii, int jj )
{
int kk, ll ;
kk = ii + jj ;
ll = ii * jj ;
return ( kk, ll ) ;
}
Error:
1. A semicolon missing in the prototype declaration of the function.
2. A function cannot return more than one values.
(b)
#include<stdio.h>
void message();
int main()
{
int a ;
a = message( ) ;
return 0;
}
void message( )
{
printf ( "\nViruses are written in C" ) ;
return;
}
Error: message function has return type void, so it cannot be assigned to any variable.
(c)
#include<stdio.h>
int main()
{
float a = 15.5;
char ch = 'C';
printit ( a, ch );
return 0;
}
printit ( a, ch )
{
printf ( "\n%f %c", a, ch ) ;
}
Error:
1. Function definition argument should have a datatype.
2. The function is not defined before calling, or there should be a prototype declaration of the function.
(d)
#include<stdio.h>
void message();
int main()
{
message();
message();
return 0;
}
message( );
{
printf ( "\nPraise worthy and C worthy are synonyms" ) ;
}
Error: invalid use of semicolon after function name in the function definition.
(e)
#include<stdio.h>
int main()
{
let_us_c( )
{
printf ( "\nC is a Cimple minded language !" ) ;
printf ( "\nOthers are of course no match !" ) ;
}
return 0;
}
Error: Function definition is invalid in other functions.
(f)
#include<stdio.h>
void message();
int main()
{
message(message());
return 0;
}
void message()
{
printf("It's a small world after all...\n");
}
Error: void is sent in the message as an argument, which is invalid.