5 Pet Peeves of Every Astronomer

Every astronomer has had to explain one of the following facts to an amateur! It can often get quite frustrating to reiterate the same point over and over again. Thus, I have created this guide for amateur astronomers, so that they don’t make silly mistakes! 1. I have seen images of the Milky Way in its entirety.  That’s not possible because we have never taken … Continue reading 5 Pet Peeves of Every Astronomer

C++: Learning the Basics – Making Patterns

Situation: Make the following patterns – 1. Patterns with asterisks #annotated #include <iostream.h> #include <conio.h> void main() { clrscr(); int rows=5, counter, sym; #you can ask the user for number of rows, but I have just stated that rows=5 for simplicity for (counter=1; counter<=rows; counter++) { for (sym=1; sym<=counter; sym++) #sym stands for symbol. sym essentially acts as a counter for the number of asterisks. … Continue reading C++: Learning the Basics – Making Patterns

C++: Learning the Basics – Palindromes

Situation: User enters a number and program displays whether the number is a palindrome or not. What is a palindrome number? A palindromic number is a number that is the same when written forwards or backwards. Examples: 121, 222, 101, 66. #include <iostream.h> #include <conio.h> void main() { clrscr(); int num, org, rev=0, rem; cout<<“\n\t Enter a number: “; cin>>num; org=num; while (num>0) { rem=num%10; … Continue reading C++: Learning the Basics – Palindromes

C++: #CoolCodez

Situation: User types in a number and the program gives the number reversed. #include<iostream.h> #include<conio.h> void main() { clrscr(); int num, rev=0, rem; cout<<“\n\t Enter a number: “; cin>>num; while (num>0) { rem=num%10; rev=rev*10+rem; num=num/10; } cout<<rev; getch(); }   I had initially written this code for the same situation, but I realized that there was a quicker way to do this. I am still … Continue reading C++: #CoolCodez

C++: #CoolCodez

Now, we’ll go through some cool codes, applying all the things we have learned up till now. We will go through such kinds of codes periodically as we learn more and more C++ programming, which is why I created the hashtag. Situation #1: User enters a number and the program displays the number of digits in the number. #include<iostream.h> #include<conio.h> void main() { clrscr(); int … Continue reading C++: #CoolCodez

C++: Learning the Basics – FOR LOOP

Situation: User enters ten numbers and the program displays the sum. Format for For Loop:  for (init; condition; increment or decrement) Code: #include <iostream.h> #include <conio.h> void main() { clrscr(); int num, counter, sum=0; for (counter=0, counter<10; counter++) { cout<<“\n\t Enter a number “; cin>>num; sum=sum+num; } cout<<“\n\t Sum= “<<sum; getch; } Continue reading C++: Learning the Basics – FOR LOOP