A in CS235 Object Oriented Programming with C++ at JCCC Spring 2015
A in CS200 Concepts Programming Algorithms C++ at JCCC Fall 2014
Information Technology Pro Chuck Johnson
Wednesday, July 24, 2019
Tuesday, December 4, 2018
C program counts down from 100 to count up to 100
One Compiler Directive One Line of Code Count 'em. |
C++
At the developers’ group I went to one Saturday morning they were talking about “programmers” who show up for programming interviews who can’t even do this countdown from 100 to 1 with the constraint in the article:http://www.thousandtyone.com/blog/EasierThanFizzBuzzWhyCantProgrammersPrint100To1.aspx
I just wrote this in about a minute:
#include <iostream>
using namespace std;
int main()
{
for(int i=0;i<100;i++)
{
cout<<100-i<<endl;
}
system(“pause”);
return 0;
}
It works.
THEN I squeezed it down to four lines INCLUDING the header. That’s the whole program. The only function is the main function.
NOW I got it down to TWO lines including the header and it still runs.
The source doesn’t look as pretty but it still works and produces the same output. That “for” loop is really just one line.
The compiler I’m using pauses the output in the console window so you can read it before it closes without the system(“pause”). Using the standard library class “std” with the scope resolution operator “::” eliminates the “using namespace std;” line and I only did that to reduce the line count.
Here is my two-line program:
#include <iostream>
int main() {for(int i=0;i<100;i++){std::cout<<100-i<<std::endl;}return 0;}
Sunday, May 6, 2012
Monday, March 19, 2012
March 1, 2012:
Johnson County Community College course completed
PHP and MySQL for Dynamic Websites
Other software used:
Wednesday, February 29, 2012
Tuesday, February 21, 2012
Completed Advanced HTML and CSS at Johnson County Community College
February 16, 2012
Web Development Certificate IN PROGRESS THIS SEMESTER |
Programming Fundamentals, PHP and MySQL next...
Friday, January 20, 2012
More Rails!
Rails Best Practices
100% Complete | Date Completed: 01/20/2012
Maybe now I'll finish up some of the easier courses at Code School this weekend.
How hard could it be?
Code School is really kind of a fun way to learn some new programming and web development skills.
Code School is really kind of a fun way to learn some new programming and web development skills.
You should check it out:
Subscribe to:
Posts (Atom)