Unit 1 Graded 1
1. Please explain what is happening with each line of coding syntax in the programming shell
template up above.
1. The first line instructs the preprocessor to take account of the contents of
the standard input/output header (<stdio.h>) in the program
2. The next line is the main function
3. Then it goes to the function/programing.
2. What is meant by declaring a variable? What is a data type and why do we assign one to a
variable? What are some great variable naming conventions? What can we not include in a
variable name?
1. It means that you are setting up and stating what kind of input/variable you are going
to be using. A data type is what kind of data is going to be used, integer or something
else. Integer1 and interger2 are good ones for example. No special symbols or
reserved words should be used.
3. What is the difference between the scanf() and printf() functions? What is the syntax that is
needed for both types of statements? Please provide a coding sample of each.
Printf is for writing output. scanf is for reading input.
scanf(format_string, list_of_variable_addresses);
printf("FSU has %d students", numStudents);
4. What is the difference between a decisional statement and a looping structure? Which one
includes increment or decrement operators and what is their function?
1. looping statement will be executed repeatedaly until the condition becomes false.
Decision statment have only one entry point but must have two exit points since
the answer to the question can be either a "YES" or a "NO". A looping does the
latter
5. Please provide a real world example of both a decisional statement and a looping structure and
include a coding snippet with your written examples.
For decisional statement this could be “Do you want pancakes?”
puts( Pancakewant = “yes” ? "Eat them up" : "Maybe next time" );
For a looping structure one could be “Has the total reached 10?”
for ( int x = 0; x < 10; x++ )
Part 2
1.
#include <stdio.h>
int main(void)
{
int number1; //variable declaration
printf("Enter number1: "); //prompt
scanf_s("%d", &number1);
printf("Number1 is %d", number1); //display text and value stored in number1
printf("\n"); // displays new line