Program to understand data types
#include<stdio.h>
#include<stdlib.h>
datatypes()
{
int choice;
printf("to understand data types\n");
printf("1:integer\n 2:floating\n 3:chartype\n");
scanf("%d",&choice);
switch(choice)
{
case 1:printf("integer operation\n");
integer();
break;
case 2:printf("floating point operation\n");
floating();
break;
case 3:printf("character type operation\n");
chartype();
break;
default:printf("enter correct choice...\n");
printf("we are in main function\n");
}
}
integer()
{
int a,b,c,area,volume;
printf("enter values for a,b and c\n");
scanf("%d%d%d",&a,&b,&c);
area=2*(a*b+b*c+c*a);
volume=a*b*c;
printf("area of rectangle=%d\n",area);
printf("volume of rectangle=%d\n",volume);
}
floating()
{
float a,b,c;
printf("enter values for a and b\n");
scanf("%f%f",&a,&b);
c=a+b;
printf("result(sum) of c=%f\n",c);
}
chartype()
{
char ch;
ch=getchar();
putchar(ch='a');
printf("the entered character is %c",ch);
}
main()
{
datatypes();
}
OutPut:
to understand data types 1:integer 2:floating 3:chartype 1 integer operation enter values for a,b and c 1 2 3 area of rectangle=22 volume of rectangle=6 madan@madan-Lenovo-G570:~/madan$ ./a.out to understand data types 1:integer 2:floating 3:chartype 2 floating point operation enter values for a and b 12.33 23.44 result(sum) of c=35.770000 madan@madan-Lenovo-G570:~/madan$ ./a.out to understand data types 1:integer 2:floating 3:chartype 3 character type operation athe entered character is a





