₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,190 members, 8,449,056 topics. Date: Tuesday, 21 July 2026 at 09:13 AM

Toggle theme

Timtoday's Posts

Nairaland ForumTimtoday's ProfileTimtoday's Posts

1 2 (of 2 pages)

ProgrammingRe: Is It Advisable To Start Learning Programing With C++ by timtoday: 8:13pm On Mar 25, 2016
There is nothing wrong if you start programming learning C++. With C++11, C++14 and C++17 on the way, you really don't have to master C, to get your hands dirty. However, it depends on what you will like to major on. But even at that you can't be wrong knowing some stuff with either C++ or C.
Then like someone previously mentioned. You can even start up with JavaScript. That language has a lot to offer these days than many people even realised. I will even prefer it to python in so many ways.
However in the end languages are just tools. I will also advice to check the pin write on this forum too.
Hope this helps.
ProgrammingRe: The Greatest Programmer On Nairaland by timtoday: 8:55am On Feb 27, 2016
seunthomas:
Thanks for your observation ohh. But the question asked if a recursive program could exit without an exit path and the answer is YES. those examples are just those that could come to mind, like i told that bros that likes to argue there are many scenerios and if we now put more programming languages into play i know some languages by design that dont even require a recursive function to have an exit loop.
But the "thought" of such EXIT is horrifying to say the least. While on some system you could be "presented" with BSOD - blue screen of death. So, am sure that is why asking such question and giving an answer without explanation would raise some dust in so many corners and quarters.
ProgrammingRe: The Greatest Programmer On Nairaland by timtoday: 8:36am On Feb 27, 2016
seunthomas:
A recursive function can actually terminate without an exit path
a. scenerio out of memory (know this about java)
b. stack overflow( saw this online)
For all intent and purpose, why would one want to terminate a recursive function "allowing" stack overflow or scenario of out of memory? This has nothing to do with side taking.

Whether a function return a data type or not (in the case of void, though void is consider a data type in a way), that should not make a program "crash" as an exit path. Am sure that wouldn't be a good program at all, except you are probably showing a case that causes such. But if the purpose of the function or program is to solve a specific issue but instead crashes, I don't think that is acceptable.
CelebritiesRe: Let's Stop This Folly - The Bread Seller Story Is Fake! by timtoday: 8:45pm On Feb 20, 2016
Time reveals all things! "Sooner" or later, we shall know!
ProgrammingRe: When Angry Programmer Get An Error! by timtoday: 6:04pm On Feb 17, 2016
Lol....
HealthRe: Zika Virus Is In Nigeria- Health Minister by timtoday: 10:43pm On Feb 09, 2016
Check this https://en.wikipedia.org/wiki/Zika_virus#History

and then this
http://trstmh.oxfordjournals.org/content/46/5/509.short

check to download this pdf
Zika virus : A report on three cases of human infection during an epidemic of jaundice in Nigeria
ProgrammingRe: Who Did More For Programming: Steve Jobs Or Dennis Ritchie? by timtoday: 7:05pm On Jan 31, 2016
Dennis Ritchie. Any day, any time. Though he was recognised before he died, but not as much as the contribution he make to computing and programming generally. So so sad..
ProgrammingRe: Hope For C++ Newbies: Gui Toolkits by timtoday: 9:19pm On Jan 30, 2016
exxy:
My Oga na so i come take run the program, @timtoday, u too much. and codemarshal08, i hail bro.
the thing be hard me small sha
based on say i just newly start to code. @timtoday, i go pm u bro.

// Emmanuel.cpp : Defines the entry point for the console application.
//ocean level now

#include <iostream>
using namespace std;
/*first represent variable of ocean level in millileter
second reprsent variable in milliter to centimeter
third represent variable in centimeter to inches
fourth represent variable in millimeter multiply by total number of years*/
int main()
{
double first;
double second;
double third;
double fourth;

cout<< "what is the new ocean level after 20 years? ";
cin>> first;
fourth = first + (3.1 * 20);

second = fourth * 0.1;

third = second / 2.54;

cout<< third <<" inches" <<endl;
cout<< second <<" centimeters" <<endl;

return 0;
}
/*
what is the new ocean level after 20 years? 62
inches4.88189
centimeter12.4
Press any key to continue . . .

what is the new ocean level after 20 years? 50
4.40945 inches
11.2 centimeters
Press any key to continue . . .
*/
Are you sure your calculation is right? Nice work on getting something going.

There are a number of thing, I think you can still work on though. Your variable should have meaningful name. Not first, second and the rest. Yes, I know you commented on that, but imagine writing a few hundred lines of codes, how do you remember which is which? Will you keep going back to the beginning of your program file? So names like: initial_ocean_level, ocean_level_mm, ocean_level_cm etc will be a lot better and reduce number of line of comments.

Secondly, the way you are using namespace is not a very good habit. That is for another day. But I think you need to know that up front. You are inputting all the std namespace in another file all together. Yes, is a common practice is not a good one. Am sure you will appreciate it when you are taught scope and namespace.

Lastly, check your calculations and your prompt string. I thought, what you are suppose to have is something like: "Input or Enter initial ocean level: " or somewhat according to the question. Just thinking aloud though. I have no seen your pm Ooo..
ProgrammingRe: Hope For C++ Newbies: Gui Toolkits by timtoday: 10:56am On Jan 29, 2016
exxy:
Ok boss, but doing this assignment is looking hard tho
Please let us remain the
boss
thing. Thank you for that.
The assignment is really simple like I mentioned earlier. Am sure you have it solved on paper already?
ProgrammingRe: Hope For C++ Newbies: Gui Toolkits by timtoday: 9:44am On Jan 29, 2016
exxy:
Ok, How do i go with the syntax bro?
What do you have written? I mean


#include <iostream>

int main() {

// your codes goes here
return 0;
}
ProgrammingRe: Hope For C++ Newbies: Gui Toolkits by timtoday: 6:13am On Jan 29, 2016
exxy:
My Ogas, make una help me check this assignment whether una fit write the code for C++

During the past decade ocean levels have been rising faster than in the past, an average of approximately 3.1 millimeters per year. Write a program that given the initial ocean level, will compute how much ocean levels are expected to rise during the next 20 years if they continue to rise at this rate. Display the answer in both centiments and inches. The final output should be the projected ocean level.
How would you write it?
Before we start using the syntax of C++ to express our thought, the question is just an arithmetic conversion. if for the past decade (10) years, the ocean level has raised 3.1 mm / yr. What is the value now? Then, in the next 20 yrs what will it be at the same rate.
Do you remember 10mm make 1 cm songs we sang in primary school then grin, if you don't ask google, for how many mm makes 1 cm, then do the conversion, then how many cm makes 1 inch, or [ how many mm makes 1 inch ] then do the conversion.
If you can do that with pen and paper, the rest will be a piece of cake! That is the C++ programming syntax!
ProgrammingRe: 6 Programming Exercises by timtoday: 5:32pm On Jan 28, 2016
# 2

#!/usr/bin/perl
use warnings;
use strict;

# call the closedBracket subroutine
# on the first argument on the command line interface
print closedBracket( $ARGV[0] );

# closedBracket subroutine
sub closedBracket {

# get the variable
my $str = shift;
my $open_bracket = 0;
my $close_bracket = 0;
my $state = "true";

# split the variable
for ( split //, $str ) {

# if the variable matches open bracket
if (/\(/) {
$open_bracket++;
$close_bracket--;
}
elsif (/\)/) { # else if it matches closed bracket
$open_bracket--;
$close_bracket++;
}
}

# check if the value open bracket and
# close bracket is 0, if not, take the absolute
# of the variable with negative value
if ( $open_bracket != 0 and $close_bracket != 0 ) {
if ( $open_bracket < 0 ) {
$open_bracket = abs $open_bracket;
$str = join '' => '(' x $open_bracket, $str;
}
else {
$close_bracket = abs $close_bracket;
$str = join '' => $str, ')' x $close_bracket;
}
return join ', ' => "false", $str;
}
return $state;
}



Used the following input (3+3), (5+2)*3), (2+2((
I might not have tested this enough though! Enjoy!!!
ProgrammingRe: 6 Programming Exercises by timtoday: 2:41pm On Jan 28, 2016
Language: Perl - one-liner

#1

perl -we "print scalar split// => $ARGV[0]" hello # print 5

to use the default function provided by Perl is like so:

perl -we "print length $ARGV[0]" hello # 5, notice the length function


# 3

perl -we "print join ', ' => map {$_, scalar split//} join '' => grep /[aeiou]/ => split// => $ARGV[0]" "Hello, world"


# 4

perl -we "print $ARGV[argSwitch(@ARGV)] for 1 .. 3; sub argSwitch{ @m=@_;$n = 0; print sub {$m[$n++]}->()}" me you


# 6

perl -we "print join ' ' => grep {!/$ARGV[1]/i} (split/\s+/ => $ARGV[0]), $ARGV[2]" "Hello, World" world Nairalanders


All are one-liner Perl Scripts.
ProgrammingRe: Shutting Down A Computer Using Notepad (beginners Tutorial) by timtoday: 10:08pm On Jan 22, 2016
sinequanon:
I did. You are the only one hopping around, seeing "drama". cool
How is that? Very Funny!!!
ProgrammingRe: Shutting Down A Computer Using Notepad (beginners Tutorial) by timtoday: 9:48pm On Jan 22, 2016
But you can use ctrl+alt+delete to open task manage.
In the screenshot below i simply used task manager to launch chrome only, that is why everything at the background of this browser is blue.
Ahhaaa.. Simply, launching explorer again instead of chrome, which will restore the desktop and all the files not closed when the bat file that kill explorer was first ran.

Don't follow blindly is the advice.
You can say that without all the drama.
ProgrammingRe: Shutting Down A Computer Using Notepad (beginners Tutorial) by timtoday: 7:02pm On Jan 22, 2016
I can even show the poor newbies how to shutdown your explorers:

You guys now know how to shutdown abi, okay, i dare you to try this:

create a batch file called bsod.bat and enter the following command
taskkill /f /im explorer.exe
That is simply showing off bro. The bat files doesn't do any damage whatsoever. Simply, using Ctrl+Alt+Del, then switching off and re-logging in will restore the desktop. So what? In fact, using the help switch will tell anyone the function of the command to start with.

You really want it to be so disturbing, then makes the bat file a start up services. Even at that you can work around it and delete the bat file.
More so, are you using bsod as in "blue-screen-of-death"? Come on bro you can do better!
ProgrammingRe: Shutting Down A Computer Using Notepad (beginners Tutorial) by timtoday: 12:17am On Jan 21, 2016
Nice work on the tutorial. But all these could be done on a single line either on window OS or Linux OS.

On Command Line Interface (CLI) on windows like thus:

C:\> shutdown /s /t 45 /c "Shutting Down in 45secs"

There is a whole lots of stuff can do with this just check using the help option on the shutdown command like so:

C:\> shutdown \h

You will see how to use the command and a whole lots of options that you can combine with it.

On Linux OS:

prompt> sudo /sbin/shutdown -h now

1 2 (of 2 pages)