Home » » Data Types in C Programming with Example

Data Types in C Programming with Example

Data Types in C Programming with Example

Data Types in C Programming with Example

     It has five types
     1. int - whole number - %d - 100, 200
     2. float - decimal point number - %f - 10.50, 20.50
     3. double - more decimal number - %f - 8.664464, 5.333333
     4. char - single word - %c - a, b, c
     5. string - word - %s - arun, kumar

Int Program :


#include

int main()
{
int a,b,c;
printf("enter the value of a and b is:");
scanf("%d%d",&a,&b);
c=a+b;
printf("The value of c is %d",c);

return 0;
}

Output:


enter the value of a and b is:2
6
The value of c is 8

Float Program :


#include

int main()
{
float a,b,c;
printf("Enter the value of a and b is:");
scanf("%f%f",&a,&b);
c=a+b;
printf("The value of c is %f",c);
return 0;
}

Output :


Enter the value of a and b is:1
2.4
The value of c is 3.400000

Double Program :


#include

int main()
{
double a,b,c;
printf("Enter the value of a and b is :");
scanf("%f%f",&a,&b);
c=a+b;
printf("The value of c is %f",c);
return 0;
}

Output :


Enter the value of a and b is :1
2.33
The value of c is 0.000000

Char Program :


#include

int main()
{
char a;
printf("Enter the letter of a is:");
scanf("%c",&a);
printf("The given letter of a is %c",a);
return 0;
}

Output :


Enter the letter of a is:f
The given letter of a is f

String Program :


#include

int main()
{
char a[20];
printf("Enter the name of a is:");
scanf("%s",&a);
printf("The given name of a is %s",a);
return 0;
}

Output :


Enter the name of a is:kumar
The given name of a is kumar

0 coment�rios:

Post a Comment

Link you don't want to vouch for Read more: https://html.com/seo/#ixzz5zVltiZ5g