This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.
Toggle SlidingBar Area

Learning Printf for College Students

In the last article on learning C programming for college students, I left you with a program to see if you could interpret it. The program is shown below. In the last article I covered all but one of these lines of code, the one that I did not cover is the printf statement. Now printf may look like someone got a little to typo happy with the keyboard and accidentally typed printf instead of print, which is the statement for outputting code to the screen normally, however, printf is a statement that means “formatted printing” or formatted output. By the end of this article on learning printf for college students you will understand why.


#include 
#include 

int main(void)
{
    printf("Hello World!");
    return 0;
}

Quick Summary of Data Types

In C there are several primitive data types, similar to the way a caveman is similar to evolved humans. I will cover these in another post on beginning data types, however I will briefly explain a few and how to use them in a printf statement and try to make learning printf for college students as simple as possible.
So for example, let’s say we have an integer that has the value of a gymnast’s olympic performance on a scale of 0 to 10, and we want to output that to the screen. We will make an integer value for simplicity that holds a value between 0 and 10 and then I will show you how to output that to the screen.


#include 
#include 

int main(void)
{
   int score = 10; //This statement has the type of the data, an integer or int, a name of our variable, score, and a value of that integer, 10, that can change later in the program.
   
   printf("The gymnast's score is a %d!", score);//This is where the magic happens, this outputs the text "The gymnast's score is a " and then has the "%d" in parenthesis that signals the printf statement that a variable of type int should be placed there. This variable's name goes after the quotes following a comma.

   return 0;
}

Formatting the Printf Statement

Printing can also be performed with other data types besides integers, such as characters, ‘a’, ‘b’ and so on, as well as floating point numbers, or decimal numbers like 3.14 or 3.3333. Here are the codes, similar to %d to use for each data type:

Characters char %cLearning Printf for College Students
Integers int %d
Floating point float %f

These are the basic ones you will need for now, more will come in the future, but for right now these are the only ones that are necessary.

Now comes the formatting part and where printf gets its name. There are certain character codes in printf statements that signal the program what to do. For instance, the “\n” character tells the program to go to the next line, like hitting enter on the keyboard, similarly “\t” tells the program to tab over like hitting tab on the keyboard.

Rounding

The next and last thing in this article is rounding floating point numbers using a printf statement. An example is shown below:


#include 
#include 

int main(void)
{
   float GPA = 3.141592654 //creates a floating point decimal number with the first 10 digits of pi
   
   printf("Your GPA to 2 decimal places is \t%.2f\n", GPA);//Prints the GPA variable to 2 decimal places
   printf("Your GPA to 5 decimal places is \t%.5f\n", GPA);
   
   return 0;
}

Conclusion

That is all for the printf statements right now, they will come up later for sure and at that point they will get more useful, but not more difficult, feel free to comment with any questions you may have, and for the next article on learning scanf for college students I will leave you with a snippet of code to figure out what it does.


#include 
#include 

int main(void)
{
   float GPA = 0;
   
   printf("Enter your current GPA: ");
   scanf("%f", &GPA);

   printf("Your GPA is %.3f", GPA);
   
   return 0;
}
Sources:
1. http://nootropicsuniversity.com/adderall-xr-addiction-long-term
By |April 27th, 2017|Categories: C Lesson|Tags: , |0 Comments

About the Author:

Leave A Comment