Have you tried counting string inputs manually? Isn't it difficult? That is why I made a program that enables a user to input his desired string length and string name then activates the program to count how many characters are there in the input.
We all know that a string is a random inputs of different characters. Today, I'm about to show you how to count characters in a srtring input. This program is used with the string length statement which enables the program to count how many characters are there in a string. Check out the sample code below.
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <string.h>
int main()
{
char string[127];
std::cout<<"Enter a string: ";
Easy to learn programs using C/C++ language. C/C++ is the basic computer language and the foundation in creating simple to complex computer programs. On this site we present you different examples of programs from the simplest forms to the complex ones using C/C++ language.
C++ Lanuage | String Counts
Tuesday, 11 June 2013
Sunday, 26 May 2013
TIME is GOLD. This is the most famous saying when it comes to valuing time management. We know that every second/s of the day is important because we know that we can do a lot of things already in such time. One of the most useful job a time can do is allowing us to manage our day, our priorities and our lives. Time is composed of two main parts: minutes and seconds.
Usually, seconds time is used in sports especially running. There are runners who time check their selves to check how long had they run in 60 seconds and more. This is used by seconds timers either digital or analog. Now, I made a program that converts seconds to days, minutes and seconds. This program is used with long data type identifier because we need to convert large numbers. Check out the sample codes below.
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
long seconds,days,mins,sec;
cout<<"Enter the number of seconds: ";
cin>>seconds;
Usually, seconds time is used in sports especially running. There are runners who time check their selves to check how long had they run in 60 seconds and more. This is used by seconds timers either digital or analog. Now, I made a program that converts seconds to days, minutes and seconds. This program is used with long data type identifier because we need to convert large numbers. Check out the sample codes below.
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
long seconds,days,mins,sec;
cout<<"Enter the number of seconds: ";
cin>>seconds;
Saturday, 25 May 2013
Nowadays, technology is extremely fast growing. It's not just making our lives more easier but also it let us connect to other people from anywhere around the globe. When we hear the word technology we see it as the gadgets that we use and the World Wide Web (www) that holds any information we need. All of these things are very important because it is handy and the more important it is the more we need to secure it. That is why passwords where invented. Passwords are secret combinations of characters, numbers and even symbols just to protect our confidential information in the digital world.
I decided to make one password program to show you how it looks. Since we are going to make a password program we will be using the string command because users are going to use either characters, numbers or symbols for their passwords. We will also use the string compare statement to compare the inputted password to the original password. Check out the sample codes below.
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
char password [100];
int i;
for(i=0;i!=3;i++)
I decided to make one password program to show you how it looks. Since we are going to make a password program we will be using the string command because users are going to use either characters, numbers or symbols for their passwords. We will also use the string compare statement to compare the inputted password to the original password. Check out the sample codes below.
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
char password [100];
int i;
for(i=0;i!=3;i++)
Wednesday, 8 May 2013
Based on experience, I'm used to making programs using only integers in inputting choices or just doing plain mathematics but I thought that making programs doesn't just revolve around numbers it also has characters such as letters and symbols. That's when I encountered string and array.
String is used when you have to input a lot of characters or simply a phrase or sentence. On the other hand, array is used as a large storage of your inputs either characters or numbers. In this program, we are going to copy a value from one memory to another using string, array and the memcpy command. In this example, string1 will copy the value of string2. The string value would be, "This is a string.". Check out the codes below.
String is used when you have to input a lot of characters or simply a phrase or sentence. On the other hand, array is used as a large storage of your inputs either characters or numbers. In this program, we are going to copy a value from one memory to another using string, array and the memcpy command. In this example, string1 will copy the value of string2. The string value would be, "This is a string.". Check out the codes below.
1: #include<iostream>
2: #include<conio.h>
3: #include<cstring>
4:
5: using namespace std;
6:
7: main()
8: {
9: char str1[20];
10: char str2[]="This is a string.";
11:
12: cout<<"Before memcpy()\n\nstr1 contains: "<<str1<<endl<<"str2 contains: "<<str2< <endl<<endl;
13: memcpy(str1,str2,17);
Friday, 3 May 2013
All of us are all familiar with the way a market runs. There are people who sells foods and there are people who buys. Before when we buy something, sellers use a calculator to compute how much are we going to pay. Nowadays, sellers use computers for a faster transactions.
In the streets, automatic machines are also out everywhere giving you instant foods and drinks. One example of this machine is the soda machines, where you'll just insert a coin and automatically it will drop your choice of food or drink.
My idea is this, I thought that some of us love fruits, so some of us are always going to the market to buy some. Some hate delays because they're busy, so some of us depend on automatic vending machines. Now, the program that I will introduce to you today is the combination of the two ideas I have. It is called the Automated Fruit Selling Machine. This program is used for selling fruits easily. In the machine chosen fruits are all indicated and its prices. All you need to do is choose which fruit you would like to have, how many you would like to take and then the machine will automatically compute how much you need to pay and after that you can then get your orders.
The program is used with switch case statement for easier handling. Switch case statement is more user friendly when you need to make a wide variety of choices in your program. Check the codes below.
In the streets, automatic machines are also out everywhere giving you instant foods and drinks. One example of this machine is the soda machines, where you'll just insert a coin and automatically it will drop your choice of food or drink.
My idea is this, I thought that some of us love fruits, so some of us are always going to the market to buy some. Some hate delays because they're busy, so some of us depend on automatic vending machines. Now, the program that I will introduce to you today is the combination of the two ideas I have. It is called the Automated Fruit Selling Machine. This program is used for selling fruits easily. In the machine chosen fruits are all indicated and its prices. All you need to do is choose which fruit you would like to have, how many you would like to take and then the machine will automatically compute how much you need to pay and after that you can then get your orders.
The program is used with switch case statement for easier handling. Switch case statement is more user friendly when you need to make a wide variety of choices in your program. Check the codes below.
1: #include <stdio.h>
2: #include <conio.h>
3: #include <stdlib.h>
4:
5: int mango=0;
6: int apple=0;
7: int orange=0;
8: int durian=0;
9: int q1,q2,q3,q4;
10: main()
11: {
12: int order;
13: char a;
14:
Wednesday, 1 May 2013
Being a student is challenging, there are a lot of pressures not just in your subjects but also with your professors, yet you can still find lots of fun with your friends. One thing we look forward to when semesters are near ending are the grades we get from our professors. Most of us hope for the best grades, some of us accept any grades as long as it is on the passing rate.
Thinking about this, I come up with the idea of making a grade scale program which will determine if your grade is poor, satisfactory or excellent. In this program, the grades you input will be evaluated. Check out the codes below.
Thinking about this, I come up with the idea of making a grade scale program which will determine if your grade is poor, satisfactory or excellent. In this program, the grades you input will be evaluated. Check out the codes below.
#include<stdio.h>
#include<conio.h>
main()
{
float var2; printf("PASSED or FAILED??\n"); printf("Enter your grade in any subject: "); scanf("%f", &var2); printf("\nYour grade is %.2f. ", var2); if(var2==75) printf("Just enough to get you through!\n"); else if(var2<75) printf("Sorry but you have to repeat the subject!\n"); else if(var2>75 && var2<80) printf("You made it, but you have to try harder next time!\n"); else if(var2>=80)
Relationship Between Two Numbers
We all know that numbers are simple yet complex figures. First thing we understand about numbers is that they differ from one another when it comes to equality. Every numbers like letters, when combined together they form another kind of figures which may be larger than the other numbers, smaller, they may also be equal or not equal.
Since kindergarten, we are taught how to determine the relationship between two integers/numbers, if it is equal to or not equal to than the other number. So I made a program that is used to determine the relationship between two integers/numbers easily. The program that is shown below is more faster in figuring out the relationship and more useful when teaching your younger ones. Check out the codes below.
Since kindergarten, we are taught how to determine the relationship between two integers/numbers, if it is equal to or not equal to than the other number. So I made a program that is used to determine the relationship between two integers/numbers easily. The program that is shown below is more faster in figuring out the relationship and more useful when teaching your younger ones. Check out the codes below.
#include<stdio.h>
#include<conio.h>
main()
{
int var1, var2;
printf("Enter two numbers and I will tell you \n the relationships they satisfy: ");
scanf("%d%d", &var1, &var2);
if(var1==var2)
printf("%d is equal to %d\n", var1, var2);
else
printf("%d is not equal to %d\n", var1, var2);
Simple "printf" command
In making C/C++ programs we always encounter these commands: printf and %d. Both of these commands are vital in making programs because both of it are useful especially in printing integers for mathematical purposes. So, I thought of making a simple program to showcase the printf and %d commands.
Furthermore, printf command is used to instruct the computer to perform an action. While, %d is a conversion specifier which means that an integer must be printed out on the screen. In this program, it shows how to use the printf and %d commands. It will simply call the integers declared at the top and there will be no need to get inputs from the user. Check out the codes below.
Furthermore, printf command is used to instruct the computer to perform an action. While, %d is a conversion specifier which means that an integer must be printed out on the screen. In this program, it shows how to use the printf and %d commands. It will simply call the integers declared at the top and there will be no need to get inputs from the user. Check out the codes below.
#include<stdio.h>
#include<conio.h>
main()
{
int var1 = 9, var2 = 10, var3 = 9;
if(var1!=var2)
printf("\n%d", var1);
if(var1!=var3)
printf("\n\n%d", var1);
printf("\n%d", var2);
printf("\n%d", var3);
Sunday, 6 January 2013
Average is basically the sum of all numbers within a list divided by the size of the list. In my world as a student, average means the overall total of my grades. Professors usually give grades after every end of the exams and as a student you really need to supervise your grades to prevent from failing. One thing to do that is to get your average grade.
Computing average is a little confusing especially if your calculator is not around. So, I made a program that will compute for your average to make computing more easier and it is user-friendly. The program is structured with the basic commands in C++ language. Check out the code below.
Computing average is a little confusing especially if your calculator is not around. So, I made a program that will compute for your average to make computing more easier and it is user-friendly. The program is structured with the basic commands in C++ language. Check out the code below.
1: #include <iostream>2:3: #include <conio.h>4:5: using namespace std;6:7:8:9: int main()10:11: {12:13: float num1 = 0.0f;14:15: float num2 = 0.0f;16:17: float num3 = 0.0f;
Wednesday, 2 January 2013
In mathematics specially in equations in algebra, there are times that square roots and cube roots appear. Square root is the process of multiplying a number by itself. While, cube root is the process of multiplying a number by itself three times to get an answer. Sometimes people tend to confuse these two equations because they sound almost the same.
Thinking about this, I come up with an idea to make a program that can compute for the cube root of a number. This program is used with a float data identifier to allow users enter a number with or without decimal points. Check out the codes below.
1: #include <iostream>
2: #include <conio.h>
3:
4: using namespace std;
5:
6: int main()
7: {
8: float side = 0.0f;
9: float sideCubed = 0.0f;
10: cout << "Enter a real number: ";
11: cin >> side;
String | A Site Welcome Message
We are all familiar with networking sites, emails and other sites that gives us entertainment over the internet. Before we can access these sites we need to register first to become one of their members and access lots of features you might really like. One thing we observe after registration process is the welcome message we see on the screen bearing our names, like this, "Welcome Reymond Ayala". These welcome notes only mean one thing, we are successfully registered.
I thought of making a program that will look like that welcome note on sites. This program is used with a string command that will basically read all your character inputs. Check out the codes below.
1: #include <iostream>
2: #include <conio.h>
3: #include <string>
4:
5:
6:
7: int main()
8: {
9: std :: string firstName = "";
10: std :: string lastName = "";
11: std :: cout << "Enter your first name and press Enter: ";
12: std :: cin >> firstName;
13: std :: cout << std::endl;
14: std :: cout << "Enter your last name and press Enter: ";
C++ Language | Basic Calculator
Calculators are made to calculate simple to difficult equations or even just the basic math equations. Addition, Subtraction, Multiplication and Division are the four basic mathematical operation and the foundation in creating equations that are used for calculating specific or certain things. Since kindergarten, we are taught how those operations work with numbers. So, I thought of making a program that can be helpful not just in our daily encounter with mathematics but also in teaching our younger ones about the four basic mathematical operation.
This program is used with a float data type identifier. The difference of float (%f) from int (%d) is that int only accepts whole numbers for input even on outputs. While float accepts numbers with decimal points, also with the outputs. It is also a C++ language code. Check out the codes below.
#include <iostream> #include <conio.h> using namespace std; int main() { float num1 = 0.0f; float num2 = 0.0f; cout << "Enter a real number n1: "; cin >> num1; cout << "Enter a real number n2: "; cin >> num2;
Friday, 21 December 2012
I was playing a game with some kids called "is it hot", when I thought of putting it into a program. This game is mostly played with little kids. All you have to do is assign numbers in each temperature. For example, 1=hot, 2=cold and 3=warm. It is played by saying random numbers but the kids must take note that every time you say 1 or 2 or 3 they must answer you with hot, cold or warm. If you say other numbers except the three they should say, "out of order". This is kind of game is fun if the kids are in groups because they need to work with their teams to win.
As for me, I made a program out of this game to show you how you can put up If Statement, If-else Selection Statement and For Loop Statement in one program. There are certain programs that needs a strong foundation to be more productive especially programs with a lot of selection, decision making and repetitive statements. This example I have is one of those programs. Check out the codes below.
#include<stdio.h>
#include<conio.h>
main()
{
int a=1, b=1;
int count;
printf("Enter how many counts: ");
scanf("%d",&count);
if(count>30) {
printf("\nYou have exceeded the maximum input of 30");
getch();
return 0;
}
Wednesday, 19 December 2012
Trigonometry is a study of triangles. In trigonometry, there are a lot of theorems, postulates and equations for specific triangles. There are also great mathematicians and philosophers who created formulas for specific topics.
During my first semester in a trigonometry class we were asked to make a program in C language out of the topics we discussed the whole semester. As for me, I made a program that calculates the area of a triangle given only three sides. This program was based on the theorem which Heron, a Greek philosopher and mathematician, created. This theorem is known as the SSS Theorem, made out from the Law of Cosines.
The program I made is basically filled with mathematical equations and statements. So, I included a header file that reads specific mathematical commands and that is math.h. To experience the program, check out the codes below.
Hopefully this program helped you a lot. Hope to hear from you soon. Thanks!
During my first semester in a trigonometry class we were asked to make a program in C language out of the topics we discussed the whole semester. As for me, I made a program that calculates the area of a triangle given only three sides. This program was based on the theorem which Heron, a Greek philosopher and mathematician, created. This theorem is known as the SSS Theorem, made out from the Law of Cosines.
The program I made is basically filled with mathematical equations and statements. So, I included a header file that reads specific mathematical commands and that is math.h. To experience the program, check out the codes below.
#include<conio.h> #include<stdio.h> #include<math.h> int main() { float a,b,c; float s,area; printf("Enter side a: "); scanf("%f",&a); printf("Enter side b: "); scanf("%f",&b); printf("Enter side c: "); scanf("%f",&c); s = (a+b+c)/2; area = sqrt(s*(s-a)*(s-b)*(s-c)); printf("\nArea of triangle is: %.2f",area); getch(); }
The program runs like these. When executed, the program will ask the user to enter three inputs which will be the given sides of a triangle. Then the inputs will be stored on the three storage variables declared above namely a, b and c. These variables will go through the equations. As seen above, there are two equations present, the semi perimeter equation and the equation in finding the area. After executing the equations the program will now show you the result running the printf statement. Then you can now terminate the program. Check out the sample output below.
Hopefully this program helped you a lot. Hope to hear from you soon. Thanks!
C Language | Trigonometric Function SINE
Trigonometry is the study of any triangles. In this, trigonometric functions are present to help us calculate anything from missing areas to missing sides to elevations. There are six (6) Trigonometric Functions namely sine, cosine, tangent, cotangent, secant and cosecant.
In connection to trigonometric functions I made a program that shows you how it works. This program shows you how to calculate for the sine function equivalent of any triangle. This program is used with the header file math.h to allow mathematical commands inside the program. Check out the sample codes below.
1: #include <stdio.h>
In connection to trigonometric functions I made a program that shows you how it works. This program shows you how to calculate for the sine function equivalent of any triangle. This program is used with the header file math.h to allow mathematical commands inside the program. Check out the sample codes below.
1: #include <stdio.h>
2: #include <conio.h>
3: #include <math.h>
4: # define pi 3.14159265
5:
6:
7: int main()
8: {
9: int angleA;
10:
11: printf ("Enter angle: ");
12: scanf("%d", &angleA);
Sunday, 16 December 2012
ATM machines are now used around the globe because it is the only and convenient way of getting cash immediately especially if you have emergencies. Nowadays, ATM machines are not just for personal banking, it is also used in paying your employees wages or sending money to your relatives. ATM is a card-to-cash basis transaction. Now, as I was thinking about this kind of program I come up with the idea of making a program that converts the check figures into words to automate a billing system.
This program is used with selection statements and decision making statements namely If Statements and Switch case statements. The program also has a limit input of 100,000,000. Check out the codes below.
1: #include <stdio.h>
2: #include <conio.h>
3:
4: main()
5: {
6:
7:
8: int num;
9: int num1,num2,num3,num4;
10:
11:
12: printf("\nEnter Numbers: ");
13: scanf("%d", &num);
14: if ( num > 100000000 ) {
15: printf("\n\nYou have exceeded the maximum input of 100,000,000.\n");
16: }
17: if(num<=100000000)
18: {
19: num1=num/1000 % 10;
20: num2=num/100 % 10;
21: num3=num/10 % 10;
22: num4=num/1 % 10;
23:
Friday, 14 December 2012
Centuries ago, people were using the Roman Numerals as their numbers. Today, we are using the Decimal numbers. Before, roman numerals is a specific letter that has an equivalent value. For example, capital letter I indicates that its value is one (1). Though we are not really using roman numerals today, we are still studying about this because this is one of the important history and foundations in mathematics.
Today's generation, there a a lot of kids that have difficulties in studying the roman numerals especially that it is composed of letters. So, there are a lot of confusions going on in the process of learning. Because of this, I made a program that can convert decimal numbers to roman numerals to make it more easy for the kids to learn. This program will also expand the knowledge of the future programmers about decision making statements and repetitive statements. Decision making statement is what we call Switch case statements. While, repetitive statements are the Do-While and For Loop statements. For this program we will be using for loop statement. To start, check out the codes below.
Today's generation, there a a lot of kids that have difficulties in studying the roman numerals especially that it is composed of letters. So, there are a lot of confusions going on in the process of learning. Because of this, I made a program that can convert decimal numbers to roman numerals to make it more easy for the kids to learn. This program will also expand the knowledge of the future programmers about decision making statements and repetitive statements. Decision making statement is what we call Switch case statements. While, repetitive statements are the Do-While and For Loop statements. For this program we will be using for loop statement. To start, check out the codes below.
9: #include <stdio.h>
10:
11: #include <conio.h>
12:
13:
14:
15: main()
16:
17: {
18:
19:
20:
21: int count;
22:
23: int b;
24:
25:
26:
27: int num=1;
28:
29: int num1,num2,num3,num4;
30:
31:
32:
33: printf("Enter how many counts: ");
34:
35: scanf("%d",&count);Sunday, 9 December 2012
In Geometry, there are a lot of shapes that has different sides and sizes but there is one shape that has no sides and that is circle. A circle has an infinity line because of its round shape. The area of a circle is the simple thing you can calculate because of its simple equation. You only need to multiply the radius and pi then multiply again the result to the radius: a = ((PI * r) * r), respectively.
To calculate the area of a circle easily I made a program out of its equation. Since we're going to use PI anywhere in the program we need to declare it globally, meaning we need to declare it out of the main program. Check out the sample code below.
1: #include <stdio.h>
To calculate the area of a circle easily I made a program out of its equation. Since we're going to use PI anywhere in the program we need to declare it globally, meaning we need to declare it out of the main program. Check out the sample code below.
1: #include <stdio.h>
2: #include <conio.h>
3: #define PI 3.141
4:
5: int main()
6: {
7: float r, a;
8:
9: printf("Radius: ");
10: scanf("%f", &r);
11:
Saturday, 8 December 2012
Most Filipinos have relatives who migrated abroad especially in the US. Most of them migrated because they married foreigners, others migrated because of petitions and there are others who migrated because of work. Being a relative living abroad, there are instances that you need to help your relatives back in your hometown and that means sending money. People receiving money from their relatives living in the other countries, especially first timers, tend to confuse the value of the money they receive. US Dollars is one of the currency holding a high currency exchange rate value in the Philippines. That means one (1) US Dollar can be converted to atleast forty (40) Php. But there are instances that the value of US Dollars change due to economic changes as well.
To prevent confusions and to help first timers understand the difference of the two currencies, I made a program that will help people convert currencies easily depending on how much the value of US Dollars are in the Philippines. This program is used with three functions namely main, display and convert. Main function will hold the main program and the other functions hold the conversion and the currency being converted. Check out the codes below.
1:
2: #include<stdio.h>
3: #include<conio.h>
4:
5: float convert(float pesoValue, int choice, float amount);
6: void display(int choice, float result);
7:
8: int main()
9: {
10: int choice;
11: float pesoValue, amount, result = 0.0;
12:
13: printf("USD 1 is equivalent to Php ");
14: scanf("%f", &pesoValue);
Friday, 7 December 2012
When we play board games there will always be a dice that holds a series of numbers that represents how many our moves must be in the game. A dice is shaped like a cube, it has six equal sides. Cube shaped things are seen everywhere. I was always amazed by the cube because of its special form and unique shape, because of this I always wonder how to calculate its area and volume considering how big it can be.
As I was going through my High School and College years I learned how to calculate the area and volume of a cube and so much more things. To share and help you with calculating the area and volume of a cube I made a program that allows a user to calculate the said areas easily. Check out the sample code below.
1:
As I was going through my High School and College years I learned how to calculate the area and volume of a cube and so much more things. To share and help you with calculating the area and volume of a cube I made a program that allows a user to calculate the said areas easily. Check out the sample code below.
1:
2: #include <conio.h>
3: #include <stdio.h>
4: #include <math.h>
5:
6: float sol1(float y, float n1)
7: {
8: return y = n1 * n1 * n1;
9:
10:
11: }
12: float sol2(float z, float n1)
13: {
Subscribe to:
Posts (Atom)