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.
Showing posts with label C language. Show all posts
Showing posts with label C language. Show all posts
C++ Lanuage | String Counts
Tuesday, 11 June 2013
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);
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;
}
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:
Wednesday, 5 December 2012
After I showed you how the Do-While Loop executes, I will now show you the second looping statement which is more easier to use, the For Loop. For Loop repetition statement is a one line argument. It holds the control variable, condition and the increment of control variable in one line/argument, which makes it more easy. For Loop is used on most programs because it helps a lot in making a program short and straight.
Now, I made a sample program to show you how the for loop works. The sample I made is the same example I had in the do-while loop. I just changed it to for loop statement. In this example, you will observe the difference between the do-while and for loop statements and how the codes are arranged. Check out the codes below.
1:
2: #include <stdio.h>3: #include <conio.h>4:5: int main()6: {7: int n;8: int value = 1;
C Language | Do-While Loop Statement
From my previous codes, we encountered looping statements that helped us with the repetitive parts of the program. Now, I will introduce you the two looping statements that is very useful in program control. These looping statements are the Do-While Loop and For Loop.
Now, I will show you the Do-While Loop. Do-While Loop processes the statement once before processing the condition. Do-While loop is used on programs that statements are needed to be executed first before processing the condition. To show you how the do-while loop work, I made a simple program that will execute it. Check out the codes below.
1:
2: #include <stdio.h>
3: #include <conio.h>
4:
5: int main()
6: {
7: int n;
8: int generate = 1;
9:
10: printf("Enter number: ");
11: scanf("%d", &n);
12:
13: do
14: {
C Language | Addition part 1
Wherever we went we always encounter math, either when you're at home, in school or even in the market. Most of time, basic mathematics is always useful like addition and subtraction. Before, adding or subtracting is used with beads or stones or whatever things that might represent the figure all of it can be useful. Then, new generation has come and calculators were born. Today, computers are used. So, I thought of making a program that can add numbers just like a calculator using C language.
The program is designed to add two (2) numbers/integers using the basic mathematics and C language commands. Check out the codes below.
The program is designed to add two (2) numbers/integers using the basic mathematics and C language commands. Check out the codes below.
#include<stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
printf("Enter number: ");
scanf("%d", &a);
printf("\nEnter number: ");
scanf("%d", &b);
c = a + b;
printf("\nThe sum is %d", c);
getch();
}
Monday, 3 December 2012
C language is a basic programming language used to create simple to complex programs. C has different kinds of commands such as pre-processors, arrays, strings, if else statements and switch case statements. During my first lecture in this subject, programming, my professor introduce to us C language using the well known Hello World program. So, to introduce to you C language I will show you the Hello World program.
In this program, we used simple codes. We have there the pre-processor command which is the #include and the header files stdio.h and conio.h. There is also our command for output which is the printf. Lastly, to terminate the program getch(); is the key for that. It prompts user to input any character that will not show but rather to terminate the program. Check out the codes below.
In this program, we used simple codes. We have there the pre-processor command which is the #include and the header files stdio.h and conio.h. There is also our command for output which is the printf. Lastly, to terminate the program getch(); is the key for that. It prompts user to input any character that will not show but rather to terminate the program. Check out the codes below.
1: #include <stdio.h>
2: #include <conio.h>
3:
4: int main()
5: {
6: printf("Hello World!");
7: getch();
8: }
Subscribe to:
Posts (Atom)