Question:5
Write a function in C language to take input for a number and print its table?
Sol:
#include <stdio.h>
//function definition
void table()
{
int n,i,t;
printf("Enter any no ");
scanf("%d",&n);
for(i=1;i<=10;i++)
{
t=n*i;
printf("%d * %d = %d\n",n,i,t);
}
}
int main()
{
table(); //function calling
return 0;
}
Question: 6
Write a function in C language to take input for three numbers check and print the lowest number?
Sol:
#include <stdio.h>
//function definition
void lowest()
{
int a,b,c,m;
printf("Enter 3 nos ");
scanf("%d %d %d",&a,&b,&c);
if(a<b && a<c)
m=a;
else
if(b<c)
m=b;
else
m=c;
printf("Min no = %d",m);
}
int main()
{
lowest(); //function calling
return 0;
}
Question:7
Write a C program to take input for 2 numbers, calculate and print their sum, prod and difference?(using multiple functions)
Sol:
#include <stdio.h>
void sum()
{
int a,b,c;
printf("Enter 2 nos ");
scanf("%d %d",&a,&b);
c=a+b;
printf("Sum = %d\n",c);
}
void prod()
{
int a,b,c;
printf("Enter 2 nos ");
scanf("%d %d",&a,&b);
c=a*b;
printf("Prod = %d\n",c);
}
void diff()
{
int a,b,c;
printf("Enter 2 nos ");
scanf("%d %d",&a,&b);
if(a>b)
c=a-b;
else
c=b-a;
printf("Diff = %d\n",c);
}
int main()
{
sum();
prod();
diff();
return 0;
}




