0% found this document useful (0 votes)
14 views6 pages

Data Types Simple C Program

This document discusses basic C data types and arithmetic operations. It includes: 1) Common C data types like char, int, float, and void and their format specifiers for input/output. 2) Basic arithmetic operations in C like addition, subtraction, multiplication, and division. 3) Three code examples showing how to use different data types and arithmetic operations - one for char and int, one for int only, and one for float.

Uploaded by

Calledo JL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views6 pages

Data Types Simple C Program

This document discusses basic C data types and arithmetic operations. It includes: 1) Common C data types like char, int, float, and void and their format specifiers for input/output. 2) Basic arithmetic operations in C like addition, subtraction, multiplication, and division. 3) Three code examples showing how to use different data types and arithmetic operations - one for char and int, one for int only, and one for float.

Uploaded by

Calledo JL
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

DATA TYPES

SIMPLE C
PROGRAM
C Data Types

Data Type Control String Description Example

char “%c” Used for outputting letter or ‘y’ , ‘w’


symbol

char “%s” Used for outputting two or more “melo” “P103”


letters or symbols and alphanumeric
“prof_melo”

int “%d” Used for outputting whole 8, 12, -5, 12854


numbers

float “%f” Used for outputting numbers with 8.12, 16.06 -23.813
decimal places

void Valueless
Basic Arithmetic Operation

SYMBOL DESCRIPTION

+ Used in addition

- Used in subtraction

/ Used in division

* Used in multiplication

Increment
++
Decrement
--
#include<stdio.h>
void main()
{
char name [10];
int age;

printf("\n Enter Name: ");


scanf("%s", &name);

printf("\n\n\n Enter age: ");


scanf("%d", &age);

printf("\n\n\n Hello %s, you are %d years old.", name, age);

getch ();
}
/*This program adds and multiplies two values*/

#include<stdio.h>
void main()
{
int a , b , c , e;

printf("\n\n Enter your first value:");


scanf("%d", &a) ;

printf("\n\n Enter your second value:");


scanf("%d", &b) ;

c = a+b;
e = a*b;
printf("\nThe sum of the two values is %d",c);
printf("\nThe product of the two values is %d",e);

getch();
}
#include<stdio.h> printf("\nThe sum of the two values is %.3f",c);
void main() printf("\nThe product of the two values is %.3f",e);
{
printf("\nThe difference of the two values is %.3f",f);
float a , b , c , e, f, g; printf("\nThe product of the two values is %.3f",g);

getch();
printf("\n\n Enter your }
first value:");
scanf("%f", &a) ;

printf("\n\n Enter your


second value:");
scanf("%f", &b) ;

c = a+b;
e = a*b;
f = a-b;
.3f – up to three decimal places only
g = a/b;

You might also like