try this
CREATE FUNCTION example
(
@id int
)
RETURNS @tableout TABLE( col1 int)
begin
declare @sum float,@lstname nvarchar(50),@fstname nvarchar(50)
select @sum=sum(marks),@lstname=lastname,@fstname=firstname from student where @id=idstud
insert into @tableout values (@sum)
return
end
GO
You forgot to include column in the datatable. ALso after that you have to include return keyword before end.