Académique Documents
Professionnel Documents
Culture Documents
Data Objects
Flowchart:
Start
Set Constant
No. of days in a year
Enter Name,
Age in Years
Compute
corresponding
Age in Days
Output result
End
/*This program asked
you of your name and age in years
*then convert it into number of days, assuming that there are
*365 days in one year
*/
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
#define Days_in_a_Year 365
int main()
{
char char_1, char_2, char_3; /*use to enter three character name*/
int age_in_years;
/*entered age in years*/
int age_in_days;
/*converted age in days*/
cout <<Enter your 3 letter short name: ;
/*enter nickname*/
memory
memory
machine language
age in days
program
machine language
age in days
program
age_in_years
38
age_in_days
age_in_days
13870
all of these data will change their values within program run. In data
definitions or data declaration each data is defined as to what type data they
are, char_1 is to type character and year is type integer.
Type
char
int
float
Description
Sample Values
Character data type
a, B, !
Integer numbers (whole numbers)
343, 100, -5
Float Precision numbers
3.1416, 12e+6
Assignment Statements
The assignment = operator or the assignment statement is used to store a
certain value into a variable name. The assignment statement:
age_in_days = year * days_in_a_year;
assigns the value of the computation into the variable name
age_in_days
input list
INTERPRETATION:
The scan function copies into memory data typed at the keyboard during
program execution. The format is a quoted string of placeholders, one
placeholder for each variable in the input list. Input list is variables separated
by comma.
The \n at the end of the format will print a new line.
The \n terminator will print the next output on a new line on the screen.
Example:
printf(First output line.);
printf(Second output line.\n);
1. Write a C program that will ask the radius of a circle in inch (es) and
then computes the area and circumference of the circle. The formulas
useful for this problem are:
area_circle = PI *radius *radius;
circumference = 2 * PI * radius;
where PI is a constant that has a value 3.14159