Posts

Showing posts from September, 2018

C++ Self-Project traffic light program

So I will make the logical part then will write the code in C++ in a 1-week cause of college assignments

C++ programming toll plaza simulation program

So the code is; #include<iostream> using namespace std; #define Toll=10.50 #define ESC=27 class tollplaza { private:   int  totalcar;   double  totalcash; public: tollplaza()   {     totalcar=0;     totalcash=0.0;   } void payingcar()  {     totalcash=totalcash+Toll;     totalcar=totalcar+1;   } void nonpayingcar() {   totalcar++; } void printcardetail() {   cout<<"totalcash";   cout<<"totalcar"; } }; int main() {   tollplaza plaza1;   char ch;   cout<<"Press 0 for no pay car\nPress 1 for pay car\nPress ESC to exit program";   do {     cin>>ch;     if(ch=='0')     {       plaza1.nonpayingcar();     }     else if(ch=='1')     {       plaza1.printcardetail();     }   } while(ch!=ESC); ...

C program to validate input

Image

C program for tax system

Image

C program to find sum made using while loop

Image
The output: If its needed comment below

C program to find sum made using for loop

Image
The output is: i think i will skip this one

C program to find sum of numbers 3 times

Image
The output is:

C program to find sum of two numbers

Image
The output:

C program to interchange two numbers

Image
The output is : oh no both the number print same as the output i don't understand it if anyone find answer please comment i will be grateful for it.

C program of Grading system

Image
So this program calculates grade and the output is like this:

Loops and beginning of c programming

Image
Loop is a statement which allows repetition of execution of statements subject to fulfillment of a condition. It contains three parts Initialization: Contol variable is assigned a value. Condition testing: The condition testing part of the loop evaluate a condition and the result of this evaluation decides if the loop execute or will be skipped. Increment: The control variable is set from the initial value to its final value. There are three loops in c I know 1.while loop:The example will make you understand  Output: 2.for loop

Function,Algorithm and Flowcharts

Image
The function it is a named block of code that performs some specific task. It got three parts Return type function name arguments Return type: When a function is executed it may or it may not return a result to its caller if it is not returning a result then a keyword void is used. Function Name: Any valid name can be given. Argument: If some value is given to the function as input they are called arguments. Algorithm: In the most simpler way it gives a rough idea of a program by not following and programming language just simple language like English and logic of the program. E.g. write an algorithm for a program to accept three numbers and find the largest among them Step-1 Start Step-2 Insert three numbers Step-3 Accept three numbers in n1,n2,n3 Step-4 Compare n1>n2 and n1>n3 Step-5 If true display n1 is the largest Step-6 If false compare n2>n1 and n2>n3 Step-7 If true display n2 is the largest Step-8 If false display n3 is the largest Ste...

Operators and branching

Let's start with operators so the list starts now... Mathematical:+,-,*,/% Relational:<,<=,>=,==,!= Logical: AND(&&)&OR(||) Unary operator:++(inceremant e.g.i++=i+1),--(e.g.i--=i-1) then the next topic is branching or condition testing: if keyword is used for contion testing e.g.  A C program for if: if (avg>=75) { printf("Congrats you secured first divison"); } Similarly, else and else if can also be tested e.g. A C program to find the biggest number between three numbers: #include <stdio.h> int main() { int a,b,c; printf("Enter three numbers"); scanf("%d%d%d",&a,&b&c); if(a>b&&a>c) { printf("A is the largest among three numbers");  // if a is big than b and c then its the largest } else if(b>c&&b>a) { printf("B is the largest among three numbers");  // if b is big than a and c then its the largest } else { printf(...

Data type introduction

So, data types well they are in the most common words are different types of values like integers, characters, float(decimal), double(it basically double any data type it attaches to e.g. double int) They allocate memory space for different types of data in memory like for character it will assign one-bit memory similarly for integers it allocates memory 1,2,4...so you get the point. Different types of data types Numeric: It includes all types of numbers Integer: It stores numbers without the fraction. Float: It represents a number with a decimal value. Character: It stores only one character. String: Combination of two or more characters. Logical: Operating on only two values 0 or 1.

Introduction to programming concept

Starting from the six steps of problem-solving because in most cases programming does problem-solving. Identifying the problem Understand the problem Identify alternate ways to solve the problem Select the best ways to solve the problem List introductions that enable you to solve the problem using selected solution Evaluate the solution So the upper statements are quite simple and easily understandable and if it creates a doubt I am always staring at my computer screen so I will reply as soon as I could. (These points are used by taking reference from book problem solving and programming concept by Maureen Sprankle) So, coming to the second part I learned about variables its definition, rules for naming them. Definition: It   is a name given to a memory location whose value may change during the execution of the program. Rules for naming variables: Name a variable according to what it represents. There is no spacing between names if you want t...