Hello, welcome back we are here with the next article of Get Started with Java Programming. Here we would be talking about Data Type, Operations, Decision Statement and loops. Java supports boolean data types as a primitive data type.

Data Type

Data type specify the the size and type of the values to be stored in the variable. Java have lots of data types which allow programmers to select appropriate data type they needed. In Java we can categorise data types into "Primitive types" and "Derived types". We will be discussing about build-in types(Primitive).

Integer Types

Integer can hold whole numbers. Java supports four type of integers, bytes, short, int, long. The size of the values that can be stored in a variables depends upon the type of integer. In the table below we specify Types size and value range:-
Type Size Minimum Value Maximun value
bytes One byte -128 127
short Two bytes -32768 32767
int Four bytes -2147483648 2147483647
long Eight bytes -9223372036854775808 9223372036854775807

Floating Point Types

floating point types can hold number combination fractional numbers. In Java there are two types of floating point integer float and double. In the table below range and size of these two types are specified. Floating points supports a special value know as Not-a-Number(NaN). NaN is used to represent the result of operation as dividing by zero. Float are of 4 bytes whereas double are of 8 bytes.

Other Types:

char:- Char is used to store character value in Java program.  This type is of 2 bytes but can hold only one single character.
boolean: In Java boolean is accepted as a primitive data type. Whenever we have to test a condition during the execution of the program this can be used. There are only two possible values of boolean type:- true or false. This use only one bit of storage.

Operators

A operation is symbol that tells the computer to perform certain mathematical or logical operations. we can classified into a numbers of categories:-
Arithmetic:- Used to conduct mathematical expressions as in algebra. +, -, *, /, % We can use Arithmetic operations on any build in data type except boolean type.
Lets Learn more about % operator:- the % operator will gives the remainder of the number. a % b will give the remender number (the remember while dividing a by b). The symbol of the value of the % will be based on the numerator.
10 % 3 == 1
10 % -3 == 1
-10 % 3 == -1
-10 % -3 == -1

Logical Operator:- && (and), ||(Or), !(Not). Logical operator will yield a value either true or false.
Var1 Var1 Var1! Var1 && Var1 Var1 || Var1
ture ture false ture ture
ture false false false ture
false ture ture false ture
false false ture false false

Relational Operator:- > , < , >= , <= , != Relation operator is used to compare two quantities. We can use these operation on selecting some task whenever some condition is satisfied.
Assignments Operator:- = , -= , += , *= , /= , %=
a +=b is similar to a = a + b
Equality:- == To show that thow of them are equal.
Unary:- ++ , -- Used for increment or decrement A = A + 1 is similar to A++
Ternary (conditional):- ?: Used as in if else condition. (Expression)?(Do this if true):(else do this);

Decision Statements

Decision statement are to make decision the the basic of the condition whether it is true or false. Java supports two discussion statements.
1. if statement
2. switch statement

if statement

if statement is used in decision making during the execution of the program. The if statement take of the following form:
if (condition)
{
    statements;
}
If the condition is true the statement will be executed else it will be skipped. Depending upon the complexity of the program if can takes various form as below:
  • if statement
  • if .. else statement
  • nested if else statement
  • else if statements 

Switch Statements

In switch statement statements are executed upon the required case are true. Switch case takes the following form.
switch (case){
case 1:
statement1;
case2:
statement2;
}
The program will check for the value of the variable case if it matches 1 statement1 will be executed if 2 statement2. we can define the default option in switch case too in case non case satisfied the statement in the default will be executed.

We can use any data types in if statements and any expression are accepted in if statements. But we can only make equality comparison on switch and only accept integer, char and Strings (allowed by Java SE 7).

Looping in Java

Java supports all the three looping namely while, do while and for loop. Loops are used when we need to execute certain part of the program repitately. Whenever a loop check the condition while entering in the loop such loop is known as entry control loop. When a loop checks the condition at exit such looping is known as exit control loop. While and for loop are entry control loop where as do while is exit control loop. We can set certain number of turns or we can set till some conditions happens.
Stack is a data structure, which is not provided by any programming language as fundamentals data type. The last element inserted will be on top of the stack. Since deletion is done from same end, last element inserted will be the first element to be removed out from the stack and so on.

A stack is ordered collection of homogeneous data elements where the insertion and deletion operations only occurs at one end. The end is often known as Top Of the Stack (TOS).

As stack is not provided by any programming language we need to create our own stak. Use of control + Z (undo) is done through the use of Stack, Reversing of the string and checking the validation and matching the parentheses in programming language in compiler are done using programming language.

How Stack Works?

Stack is a one ended operation system. There are only two operations permitted in stack, Push and pop. Push to insert in the stack where as pop to delete the element form the stack. The TOS (Top Of the Stack) always point to the top position where the next can be popped off. We can add another element on the (TOS + 1).

When ever we try to push to the stack when the stack is full then we get the error which is known as Stack Overflow. Whenever we try to pop out from the empty stack then we get an error which is known as stack underflow.

When the stack is empty TOS = -1 When we insert the first element the TOS will be on 0. When we add another element again the TOS will be 1 and so on. So when new element is inserted the TOS will be incremented. When we pop the element the TOS will reduced by one. Let say TOS is on 5 now. when we pop a element, New TOS will be 4 then when we pop again the TOS will be 3 and so on. As we will get an error when we try push to the stack which is full and try to pop from the empty stack so we should always check whether we can pop and push or not.

Stack Implementation

we can implement stack using these two ways:
Static implementation: Using array
Dynamic Implementation: Using linked list

Static Implementation

Here we use array to realize the principle of stack. In array we can insert the data and access the data. Here we use the array in a such a way that we will insert the element in the TOS and access the element from TOS. So by default when the stack is empty TOS is -1. (As array begins with 0, we make TOS to -1 for easiness). Then we insert the element in the TOS+1 location of the array. So we pass element to be added, array and the TOS when ever we want to insert data in the Stack. And in the same way we will remove a data from the stack and reduce the TOS by one, thus we pass array and TOS during pop.

Algorithm:
#define MAX=5
push(s[MAX],element,TOS)
  if TOS == MAX - 1
    display "Stack is full"
  else
    TOS = TOS+1
    s[TOS] = element
  return;

pop(s[MAX],TOS)
  if TOS == -1
    display "Stack is Empty"
    return 0
  else
    element = s[TOS]
    TOS = TOS -1
    return element

Application of Stack

It is used in recursive function calling. Function calling and returing process are in reverse order.
It is used to reverse a string.
It is used to evalutate and check the correction ness of the mathematical operation.
Implementation by word processors to perform UNDO REDO operations.
Used in parenthesis matching by compilers.

Details of the examples

How Parenthesis matching by compiler using Stack?

In every programming language there must be even numbers of parenthesis in the program. Here we will discuss how stack helps on parenthesis matching. So when we open a parenthesis the program will save that on the stack and search for next parenthesis. If it find another opening parenthesis it will add that on the stack again. And again keep looking for the parenthesis. When a closing parenthesis is found it will remove the pair (Opening and Closing) together and keep looking for parenthesis. If at the end The stack is empty there is not error in parenthesis else of the stack is not empty, there must error in parenthesis.

Stack for UNDO and REDO

Every actions will be stored in stack. so when we undo it the last command will be removed. if undo again the second last command and third last and going on..... In the same way the poped commands will be stored in another stack in case of REDO. so when we press redo we will get the last undo and the undo then after and then after.
We will be discussing about data structure. You should have knowledge in basic programming. We will be using C and Java for some example programming. Here we would discuss about Array, Structure, Pointer and Class. These are the topics we will be using throughout this article series in Data Structures.

Array

Array is primitive data member provided by C programming. Array is the collection of similar data types. Memory allocation of the array is sequential. ie. Array are stored in contiguous block of memory. Array only supports similar data type. Strings are the array of character with \0 at the end. \0 = NULL

Structure

Structure is the collection of different type of data type. In C programming Structure is the only way to create complex data type. Structure is the heterogeneous collection of data. Theoretically it will not occupy any memory unless we create the variable of that Structure. Memory allocation  of structure is sequential. We can access members of array with dot operation(.) and Arrow operation(->). Dot operation is used to access memory of structure variables. and Arrow operation is used to access members from Pointer of the structure.

1
2
3
4
5
6
struct Person
{
    char name[30];
    int age;
    char address[40];
}

Self Referencial Structure

The structure that is pointing to self is called self referential structure. Ie a member of structure is pointer to that structure
struct list

1
2
3
4
5
struct List
{
    int age;
    struct List *next;
}

Union

It is similar as of the structure. The only difference is that union only occupy the memory of the largest member data. So we car use only one data of the union at a time. Can there be pointer to union? yes they can be :)

Courses to Complete During Software Engineering

Pointer

What is pointer in a word? A pointer is a variable. A pointer is a reference variable which store memory location. All the pointer occupy same memory bits. The pointer of the floating point data and the integer data. will occupy only 2 bits of memory. What is Void Pointer and null pointer? Void pointer is the pointer that can point to any kind of data type. This make use of type casting to to this job. Null pointer os the pointer which points to non or invalid address. Remember Structure pointer can only point to structure.

float data type is of 4 bit of memory, so when pointer points to the floating point it will point the base address of the variable. Points to the starting block of the memory for that variable.

Class

A class is data type. class is user defined variable that can be used to create objects. The difference between the structure and the class is that class have methods (Behaviour) which structure does not have. When ever the object are created the members are copied to the variables but not the methods. All the objects share the same methods. What is Abstract class? The class which have pure virtual function and cannot make any object.

Abstract means hiding the implementation details. We Drive the car but it is no concern to use how all the functions in the car works.
Java is a general-purpose, Object Oriented Programming Language high level programming language. It was developed by Sun Microsystem in 1991. Originally James Gosling, Mike Sheridian, Patrick Naughton start a project named "Green Project". They were developing special software for consumer electronic devices. They name this new programming language as "Oak". The World Wide Web appeared, then they develop a web browser called "HotJava" using the new programming language they developed, which demonstrate the Power the Programming language and it become popular among the internet. They Rename "Oak" into "Java" in 1995.

To run a java code in any machine we need JRE (Java Runtime Environment). JVM is a component of JRE. JVM(Java Virtual Machine). All programming language compilers translate source code into machine code for special computer. However Java first compile the java Source code into a bytecode for a the JVM. Then java interpreter generate the machine specific code. This is why java is Platform Independent. Any code written and compiled in Linux machine could be interpreted and run on Windows machine.

A java source file Hello.java is first compiled using compiler (Javac) which will generate a bytecode Hello.class then Java Interpret(Java) will gives the output. JDK(Java Development Kit)is used for java program development. JRE will be automatically installed when JDK is installed in the system. In Windows machine we need to set environmental variables to run Java or Javac command in Command Prompt. For that Right Click in My Computer and Click properties. Then Click in Environmental Variables. Add "path" as a name and <Location of java installation> in value field in System Variables. The location should be like "c:\program files\java\jdk\bin"

We set up the Environment verialbes now we are ready to go to Run our First Program

1
2
3
4
5
6
7
8
9
class Hello
{
        public static void main(String args[])
        {
                System.out.print("Hello ");
                System.out.println("Java ");
                System.out.println("Welcome to Java");
        }
}

Java contents Packages with any prederined functions and class to use while programming in java. Packages are those refered as Class Libararies in other programming language. While Defining Identifier. Always use UpperCase first character of class and every first Letter of next word without any space. for Functtion name use first lowercase and next word's first character as a UpperCase.
Identifier Examples:-
Class Name:- Hello, HelloJava, WelcomeToJavaProgramming
Method name:- display(), displayMessage(), displayNewMail()

In the above program we use String and System class from Package java.lang We should alway import the package name before using them in our program. But java.lang is a basic package which will be automaticlly inserted.

import java.lang.String will import only that class where as import java.lang.* will import all the classes in that Package. It is better to use .* while during studying purpose but for development we will impor individual package as required.

As java is purely object oriented programming language, we need to create at least one class to run the java program. The main function is automatically called when executing the program. ie the execution of the program starts from the main function. Main function is Public, can be accessed by outer function, Static because no object is created to call the main function. void as it do not return anything. The main function is called using the class name as Hello.main()

String args[] are known as Command line arguments. We could pass arguments to the main function from command line.
Check: Java, General-purpose Programming Language

Prerequisites:- Basic Knowledge of Object Oriented Programming.
Hello there Here we Will display all the data stored in database table in html.
For this example we use the Example code of

Php Program To Connect With Database, Create Table To Connect with database, create table and insert data to the database. And From this code below we can display the stored data.

Q.Write PHP code that retrieves all the districts from database in tabular format. Pokhara University [2012 -Spring] Course: Web Technology

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!doctype html>
<html>
<head>
 <title>All the datas from Table in Database</title>
</head>
<body>
 <?php
 include "connect.php";
 $sql = "SELECT id,name,email FROM info";
 $result = $conn->query($sql);
 echo "<table border='1'>";
  echo "<tr>";
   echo "<th> Id </th>";
   echo "<th> Name </th>";
   echo "<th> Email </th>";
  echo "</tr>";
 while($row = $result->fetch_assoc()) { 
  echo "<tr>";
   echo "<td>" . $row["id"]. "</td>";
   echo "<td>" . $row["name"]. "</td>";
   echo "<td>" . $row["email"]. "</td>";
  echo "</tr>";
 }
 echo "<table>";
 ?>
</body>
</html>

Here is our info Table in Database:
Here is the Output of the Code Above

Id Name Email
1 Sagar Devkota info@devkotasagar.com.np
2 Ram Hari ram@hari.com.np
3 Mr Bean mr@bean.com.np
4 Cristiano Ronaldo Cristiano@Ronaldo.com.np
5 Tom Cruise tom@cruise.com.np
6 Raffey Cassidy Raffey@Cassidy.com.np

This is all. You can find the code in Github https://github.com/InfoDevkota/phpformmysql/tree/master (Master Branch) Issuers and pull requested are accepted.
If something is wrong or Need more clarification  Please contact me: info[at]devkotasagar.com.np.
Change the font size and color of the text using java script We use onmouseover in this example code. You can use onClick and onmouseout too.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<html>
<head>
 <title>Display a table</title>
</head>
<body>
 <p id="Hello" onmouseover="change(this)">Hello How are you doing</p>
 <script>
 function change(obj){
  obj.style.margin = "90px";
  obj.style.fontSize = obj.style.fontSize == "200%" ? "300%" : "200%";
  obj.style.color= obj.style.color=="green" ? "red" : "green"; 
 }
 </script>
</body>
</html>


Here is a Java Script to display a table. To display a table always remember to set table row in first loop and table data in second loop. The loop will horizontal as per in the table. So make the inner loop in such way that it will display data in next column. Though here is only one loop.


JavaScript Display Possibilities
  • JavaScript can "display" data in different ways:
  • Writing into an HTML element, using innerHTML.
  • Writing into the HTML output using document.write().
  • Writing into an alert box, using window.alert().
  • Writing into the browser console, using console.log().

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<html>
<head>
 <title>Display a table</title>
</head>
<body>
 <script>
 var i = 0;
 var j = 0;
 document.write("<table border='1'>");
  document.write("<tr>");
   document.write("<th> S.No </th>");
   document.write("<th> Input </th>");
   document.write("<th> Output </th>");
  document.write("</tr>");
 for(i=1;i<6;i++)
 {
  document.write("<tr>");
   document.write("<td>" + i + "</td>");
   document.write("<td>" + (i+4) + "</td>");
   document.write("<td>" + (i+4)*(i+4) + "</td>");
  document.write("</tr>");
 }
 document.write("</table>");
 </script>
</body>

For Better Understanding of the loops for table  in Java Script There is another Multiplication table below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<html>
<head>
 <title>Display a table</title>
</head>
<body>
 <script>
 var i = 0;
 var j = 0;
 document.write("<table border='1'>");
        for(i=1;i<11;i++)
        {
          document.write("<tr>");
          for(j=1;j<11;j++)
          {
            document.write("<td>"+j+"*"+i+"="+(j*i)+"</td>");
          }
          document.write("</tr>");
        }
        document.write("</table>");
 </script>
</body>

As in the above loop we Use j*i Which makes the inner loop * outer loop as outer loop will changed as 10 inner loop so will display as 1*1=1 then in next row 2*1=2 ..... 10*1=10 Got it?
If something is wrong or Need more clarification  Please contact me: info[at]devkotasagar.com.np.
Hello There Here is a simple PHP Program to connect with MySQL database. Create a Table in the database and insert data into the database through the form.

Course: Web Technology
University: Pokhara University

Check The Internet and The Web – Introduction

Here is a connect.php file. We need Server, Database Name, Username and Password for that database.
new mysqli(server, username,password,database)
Will establish a database connection.

1
2
3
4
5
6
7
8
9
10
11
12
<?php
$server = "localhost";
$username ="test2";
$password ="test2";
$dbname ="test2";
$conn =new mysqli($server,$username,$password,$dbname);
if ($conn->connect_error)
{
  die("connection error " .$conn->connect_error);
}

 ?>

Here is createdb.php Which will create a table Named info with element name and email.
Here we save the SQL query in variable sql then run it in the Connection made above as
$conn -> query($sql)

1
2
3
4
5
6
7
8
<?php
include "connect.php";
$sql ="CREATE TABLE info(
  id INT(6) AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(60) NOT NULL,
  email VARCHAR(40) NOT NULL)";
$conn-> query($sql);
 ?>

Finally we are here in index.html, Here is a form with action test2.php. Whatever we send through this form will be send to test2.php (that is what action for)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <form class="" action="test2.php" method="post">
      Name: <input type="text" name="name" value="name"/><br>
      Email: <input type="email" name="email" value="email"/><br>
      <input type="submit" name="" value="send">

    </form>
  </body>
</html>

And here is test2.php which will get the values passed from the form and store them in the Database.
$_POST["name"] will get the value from the form with name name. The SQL query

INSERT INTO info(name, email) VALUES ('$name','$email')
Will insert the value of name and email to the table info and element name and email.
1
2
3
4
5
6
7
8
<?php
include "connect.php";
$name= $_POST["name"];
echo $_POST["name"];
$email = $_POST["email"];
$sql = "INSERT INTO info(name, email) VALUES ('$name','$email')";
$conn-> query($sql);
 ?>

This is all. You can find the code in Github https://github.com/InfoDevkota/phpformmysql/tree/master (Master Branch) Issuers and pull requested are accepted.
If something is wrong or Need more clarification  Please contact me: info[at]devkotasagar.com.np.
Aello This is a Simple JS Validation example Only to understand how it works.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!doctype html>
<html>
 <head>
  <title>This is a Test JavaScript Validation page</title>
  <script>
   function check() {
    var x = document.forms["test"]["firstname"].value;
    var y = document.forms["test"]["email"].value;
    if (x == "") {
     document.getElementById('error').innerHTML = "Name must be Filled!";
     return false;
    }
    if (y == "") {
     document.getElementById('error').innerHTML = "Email must be Filled!";
     return false;
    }
    var at = y.indexOf("@");
    var dot = y.lastIndexOf(".");
    if (at < 1 || dot < 4 || at > dot ) {
     document.getElementById('error').innerHTML = "Enter a valid email";
     return false;
    }
   }
  </script>
 </head>
 <body>
  <form name="test" method="post" onsubmit = 'return check()'>
   <input type="text" name="firstname" placeholder="Enter a name"/>
   <input type="text" name="email" placeholder="Enter your mail"/>
   <input type="submit" value="Send"/>
  </form>
  <p id="error"></p>
 </body>
</html>

Hey that's not Aello! its Hello..
<Pokhara University CPP>
Functions and all types.
Constructor and Destructor
Friend Function
Operation Overloading
Type Conversion (All 3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include<iostream>
using namespace std;
const double pi = 3.14; //If we try to alter the vaule of Pi compiler will generate a error.
class Test2;
class Test{
  int num1; //This will be in private section
  int num2; //This will be in private section
  public:
    //**************************Functions***************************//
    void add3(int a, int b, int c=5){ //Default arguments If only two args are pass last will take 5 if  all 3 are passed it will add those 3 numbers
      int add = a+b+c;
      cout<<"Sum = "<<add<<endl;
    }
    void add3(double a, double b, double c){ //Funtion Overloaded This function and above function name are same but if we pass int as arguments the above will be executed if float are passed this one will be executed
      double add = a+b+c;
      cout<<"Sum = "<<add<<endl;
    }
    void ifunction(){
      cout<<"I am a inline function"<<endl;
    } // FUnction definition inside class will be a inline function
    void anotherIFunc();// this is not a inline function as it is not defined here
    //**************************Constructor Destructor***************************//
    Test(){ //I am a default constructor
      num1=0;
      num2=0;
    }
    Test(int a, int b){ //I am a parameterised constructor
      num1=a;
      num2=b;
    }
    Test(Test &a){ //I am a copy constructor as i coppy the value of passed object to new object
      num1=a.num1;
      num2=a.num2;
    }
    //Here we use A function name Test to preform different taks, which is overload hence a constructor can be Overloaded
    ~Test(){ // Will be called automaticly Cannot be Overloaded as they takes no arguments
      cout<<"I am a Destructor"<<endl;
    }
    //**************************Friend Function***************************//
    friend void iaccess(Test a){//This is a friend function as there is keyword friend
      cout<<a.num2<<endl; // this can access the mamber data at private with a object.
      //no object is required to call a friend function.
    }
    friend void friendoftwo(Test a, Test2 b);
    //**************************Operator Overloading***************************//
    void operator -(){ //TO change the sign so a unary operator As this is unary operator we dont need to pass any args, as we will get a oject when it call
      num1 = num1*(-1);
      num2 = num2*(-1);
    }
    Test operator -(Test a){// TO subtract
      Test tmp;
      tmp.num1 = num1 - a.num1;
      tmp.num2 = num2 - a.num2;
      return tmp;
    }
    void display(){
      cout<<num1<<" and "<<num2<<endl;
    }
    //**************************Type Conversion***************************//
    Test(int a){ //Basic Type to Object Type Conversion
      num1=a;
      num2=a;
    }
    operator int (){ // Object to Basic Type conversion
      return num1+num2;
    }
    /* ******* DO YOU UNDERSTAND ******/ //YOU can OBtain the Object to Object Conversion by Defining constructor in Destination class or Operator conversion function in Source Class.
};
//*****************************************************//
class Test2{
  int age; //This will be in private section
  public:
    Test2(){
      age = 0;
    }
    friend void friendoftwo(Test a, Test2 b);
};
//*****************************************************//

inline void Test :: anotherIFunc(){ //Keyword "inline" makes it a inline function.
  cout<<"I am also a inline function"<<endl;
}

void friendoftwo(Test a, Test2 b){ //We dont need the friend keyword when defining the function.
  int tmp;
  cout<<a.num1<<" and "<<b.age<<endl;
  tmp = a.num1;
  a.num1= b.age;
  b.age = tmp; //Here we swap the private data of two classes using a friend function.
  cout<<a.num1<<" and "<<b.age<<endl;
}
int main()
{
  //Constructor and Function
  Test anum(2,10);
  anum.ifunction();
  anum.anotherIFunc();
  {
    //Destructor
    Test bnum;
    //Distructor will be automaticlly called when the program goes out of this "}"
  }
  //Friend Function
  iaccess(anum);
  Test2 bnum;//bnum.age is 0 because of the default constructor
  friendoftwo(anum, bnum);
  //Operator Overloading
  Test cnum(1,2);
  -cnum;
  cnum.display();
  Test add, dnum(7,15);
  add = dnum - anum;// Here the - FUnction is called by dnum and anum is passed as argument, as num1 is of dnum and a.num1 is of anum UNDERSTND THIS :) BE suer while using Greater then Operator.
  add.display();
  // Type conversion
  Test eanum;
  eanum = 9; //Both num1 and num2 gets the value of 9.
  eanum.display();
  int f = eanum; //f will get the value of num1+ num2 of eanum;
  cout<<f<<endl;

  return 0;
}

Is there anything Please do Comment, We will Update our Post Accordingly.
Q.Design a Soccer Player class that includes three integer fields: a player's Jersey number, number of goals, numbers of assists and necessary constructor to initialize the data members. Overload the ">" Operator (Greater than). One Player is considered greater if the sum of goals plus assists is greater than that of others. Create an array of 11 Soccer players, then use the overloaded ">" operator to ranks the players based on greatest goals plus assists.

Question for you:-
What is assists actually? Please answer in comment.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
using namespace std;

class Soccer{
  int jNumber, goals, assists;
  public:
  Soccer(){
    jNumber = 0;
    goals = 0;
    assists = 0;
  };
  Soccer(int, int, int);
  bool operator > (Soccer &);
  void display();
};
Soccer :: Soccer(int j, int g, int a){
  jNumber = j;
  goals = g;
  assists = a;
}
bool Soccer :: operator > (Soccer &s){
  if(goals + assists > s.goals + s.assists){
    return true;
  }
  else{
    return false;
  }
}
void Soccer :: display(){
  cout << "Jersey Number: " << jNumber << endl;
  cout << " Goals: " << goals << endl;
  cout << " Assists: " << assists << endl;
}
int main(){
  int i,j, jn, goal, assist;
  Soccer tmp,S1[11];
  for(i = 0; i <= 2; i++){
    cout << "Enter Data For Player "<< i+1 << ":-" << endl;
    cout << "Jersey number:- ";
    cin >> jn;
    cout << "Goals:- ";
    cin >> goal;
    cout << "Assists:- ";
    cin >> assist;
    Soccer tmp(jn, goal, assist);
    S1[i] = tmp;
  }
  for( j = 0; j<=2; j++){
    for( i = j; i<=2; i++){
      if(S1[i] > S1[j])
      {
        tmp = S1[i];
        S1[i] = S1[j];
        S1[j] = tmp;
      }
    }
  }
  cout << "Best User Ranking:-"<<endl;
  for( i = 0; i<=2; i++){
    cout << i + 1 << ": " ;
    S1[i].display();
  }
  return 0;
}


Well First I overload the > operator to return a Boolean value (true if the first value is greater than second, else false) then I use a sorting algorithm to arrange the players.

If you are asked to select the Best player only. First take one player as reference and follow the sorting algorithm to assign the greater value to it. And display that player.
Thanks Pradeep :)

Here is the code by Nischal Lal Shrestha.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
// #include <iostream.h>

using namespace std;

class Soccer_player{
   private:
   int jersey_number, number_of_goals, number_of_assists;
   string player_name;
   public:
   Soccer_player(){
      cout << "Enter Player Name: " << endl;
      cin >> player_name;
      cout << "Enter Jersey Number: " << endl;
      cin >> jersey_number;
      cout << "Enter Total Number of Goals: " << endl;
      cin >> number_of_goals;
      cout << "Enter Total Number of Assists: " << endl;
      cin >> number_of_assists;
      cout << "***** Player Info Updated *****" << endl;
   }

/* This is a copy constructor, 
We will used this to make another object called Best_Player
and first_player will be copied as best player for comparing it
with other(May we don't need this constructor )
*/

   Soccer_player(Soccer_player &Player){
      player_name = Player.player_name;
      jersey_number = Player.jersey_number;
      number_of_goals = Player.number_of_goals;
      number_of_assists = Player.number_of_assists;
    }

   void display(){
      cout << "Name: " << player_name << endl;
      cout << "Jersey Number: " << jersey_number << endl;
      cout << "Total Goals: " << number_of_goals << endl;
      cout << "Total Assists: " << number_of_assists << endl;
   }

   Soccer_player operator > (Soccer_player &P){
      if (number_of_assists + number_of_goals > P.number_of_assists + P.number_of_goals)
         return *this; // Return object which is already passed as default.
      else
         return P;
   }
};

int main(){
   Soccer_player Player[3];
   Soccer_player Best_Player = Player[0]; // First Player is made best player for comparision
   for(int i = 1; i < 3; ++i)
      Best_Player = Player[i] > Best_Player;
   cout << "\n\n\nOf all the info you updated\nThe Details of Best Player: \n\n" << endl;

   Best_Player.display();
   // getch();
   return 0;
}
Hello there, Here is a python code to convert what ever number you enter into words. First it will take a input. It wont ask with any message. Then it give back the number in words form. Here is no any code to handle unexpected user input. This program works for once to Hundred Billion.
Sample input:-
104382426112
Expected Output:-
One Hundred Four Billion Three Hundred Eighty Two Million Four Hundred Twenty Six Thousand One Hundred Twelve

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
one = ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine']
tenp = ['Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen']
tenp2 = ['', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']


def once(num):
    word = ''
    word = one[int(num)]
    word = word.strip()
    return word


def ten(num):
    word = ''
    if num[0] == '1':
        word = tenp[int(num[1])]
    else:
        text = once(num[1])
        word = tenp2[int(num[0])]
        word = word + " " + text
    word = word.strip()
    return word


def hundred(num):
    word = ''
    text = ten(num[1:])
    word = one[int(num[0])]
    if num[0] != '0':
        word = word + " Hundred "
    word = word + text
    word = word.strip()
    return word


def thousand(num):
    word = ''
    pref = ''
    text = ''
    length = len(num)
    if length == 6:
        text = hundred(num[3:])
        pref = hundred(num[:3])
    if length == 5:
        text = hundred(num[2:])
        pref = ten(num[:2])
    if length == 4:
        text = hundred(num[1:])
        word = one[int(num[0])]
    if num[0] != '0' or num[1] != '0' or num[2] != '0':
        word = word + " Thousand "
    word = word + text
    if length == 6 or length == 5:
        word = pref + word
    word = word.strip()
    return word


def million(num):
    word = ''
    pref = ''
    text = ''
    length = len(num)
    if length == 9:
        text = thousand(num[3:])
        pref = hundred(num[:3])
    if length == 8:
        text = thousand(num[2:])
        pref = ten(num[:2])
    if length == 7:
        text = thousand(num[1:])
        word = one[int(num[0])]
    if num[0] != '0' or num[1] != '0' or num[2] != '0' :
        word = word + " Million "
    word = word + text
    if length == 9 or length == 8:
        word = pref + word
    word = word.strip()
    return word


def billion(num):
    word = ''
    pref = ''
    text = ''
    length = len(num)
    if length == 12:
        text = million(num[3:])
        pref = hundred(num[:3])
    if length == 11:
        text = million(num[2:])
        pref = ten(num[:2])
    if length == 10:
        text = million(num[1:])
        word = one[int(num[0])]
    if num[0] != '0':
        word = word + " Billion "
    word = word + text
    if length == 12 or length == 11:
        word = pref + word
    word = word.strip()
    return word


# 104382426112 One Hundred Four Billion Three Hundred Eighty Two Million Four Hundred Twenty Six Thousand One HUndred Twelve

test = int(input())
a = str(test)
leng = len(a)
if leng == 1:
    if a == '0':
        num = 'Zero'
    else:
        num = once(a)
if leng == 2:
    num = ten(a)
if leng == 3:
    num = hundred(a)
if leng > 3 and leng < 7:
    num = thousand(a)
if leng > 6 and leng < 10:
    num = million(a)
if leng > 9 and leng < 13:
    num = billion(a)
print(num)

If you found it useful or if you are in need of it you can use it for any purpose. You can it extend to use for Trillion and so on.....

Define a class to represent a bank account. Include the following members:
  1. Data Members:
    1. Name of the account holder
    2. Account number
    3. Balance Amount in account
  2. Member Function:
    1. Open an account
    2. Deposit and Withdraw Fund
    3. Display account information
Write a program to test this class for 10 customers.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
110
#include<iostream>
#include<stdio.h>
using namespace std;
class Bank
{
    char name[30];
    double accountno;
	double balance;
    public:
        Bank():balance(0){};
        void create_account(int a);
        void deposit();
        void withdraw();
        void display();
};
void Bank::create_account(int a)
{
    accountno=a;
    cout<<"* Enter Name:- ";
    cin>>name;
    cout<<"***********Account Successfully Created*******"<<endl;
    cout<<"* You Account no is:- "<<a<<endl;

}
void Bank::deposit()
{
	double add;
	cout<<"* Enter Deposite Value:- ";
    cin>>add;
    balance=add+balance;
    cout<<"***********Balance Successfully Deposited*******"<<endl;
}
void Bank::withdraw()
{
	double add;
	cout<<"* Enter Withdraw Value:- ";
    cin>>add;
    if(add<balance){
        cout<<"***********Balance Successfully Withdraw*******"<<endl;
        balance=balance-add;
    }else
        cout<<"***********Problem on Balance Withdraw (Balance Insufficent)*******"<<endl;
}

void Bank::display()
{
	cout<<"* Name:- "<<name<<endl;
    cout<<"* Account no.:- "<<accountno<<endl;
    cout<<"* Current Balance:- "<<balance<<endl;
}

int main()
{
	Bank A[10];
    int a,account,cnum=0;
    int b;
    cout<<"* * * * * * * * * * * * * * * * * * *"<<endl;
    do{
        cout<<"*\tSelect"<<endl<<"*\t1:- To Create Account"<<endl<<"*\t2:- To Deposite"<<endl<<"*\t3:- To Withdraw"<<endl<<"*\t4:- To View Details"<<endl<<"*\t5:- Exit the Program"<<endl<<"* ";
        cin>>a;
    switch(a){
        case 1:
      	{
      		cnum++;
            A[cnum].create_account(cnum);
            cout<<"* Do you want to Process again? (Enter 1 for Yes)";
            cin>>b;
            break;
     	 }
     	 case 2:
     	 {
            cout<<"* Enter Account no:- ";
            cin>>cnum;
            A[cnum].deposit();
            cout<<"* Do you want to Process again? (Yes=1 / NO=2)";
            cin>>b;
            break;
     	 }
     	 case 3:
      	{
      		cout<<"* Enter Account no:- ";
            cin>>cnum;
            A[cnum].withdraw();
            cout<<"* Do you want to Process again? (Yes=1 / NO=2)";
            cin>>b;
            break;
     	 }
     	 case 4:
      	{
            cout<<"* Enter Account no:- ";
            cin>>cnum;
            A[cnum].display();
            cout<<"* Do you want to Process again? (Yes=1 / NO=2)";
            cin>>b;
            break;
     	 }
     	 case 5:
      	{
      		cout<<"* Thanks For Using this Program";
            b = 2;
            break;
     	 }
     	 default:
     	 {
            cout<<"* Please Enter the Selected Option";
            b = 1;
     	 }
   	}
    }while(b == 1);
   return 0;
}

Here is the Output:-

Hello here is a short program to Pass pointer to array as an argument to a function and print the content of the function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<stdio.h>
void display (int *a)
{
 int i;
 for(i=0;i<10;i++)
 {
  printf("%d\n",*(a+i));
 }
}
void main()
{
 int data[10]={1,3,5,7,9,2,4,6,8,0};
 display(data);
}

Thats all!
Hello Here is a C program to Arrange Elements in an array Using Dynamic Memory allocation. Pointer.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<stdio.h>
#include<stdlib.h>
main()
{
    int *p,n,j,i,tmp;
    printf("Enter the total no of Element to Arrange in:- ");
    scanf("%d",&n);
    p=(int *) malloc(sizeof(int)*n);
    printf("Enter the Emements:- \n");
    for (i=0;i<n;i++)
    {
        scanf("%d",(p+i));
    }
    for (i=0;i<(n-1);i++)
    {
        for(j=0;j<(n-i-1);j++)
        {
            if(*(p+j)>*(p+j+1))
            {
                tmp=*(p+j);
                *(p+j)=*(p+j+1);
                *(p+j+1)=tmp;
            }
        }
    }
    printf("Finally after arranged in Accesending Order:- \n");
    for (i=0;i<n;i++)
    {
        printf("%d \n",*(p+i));
    }
}

Have a good day!
Hello Here is a C Program to Find the Smallest Element among Array element. Here we use Dynamic Memory Allocation to Set the size of Array. And all other are as usual.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<stdio.h>
#include<stdlib.h>
void main()
{
    int *p,n,i,min;
    printf("Enter the total number of elements:- ");
    scanf("%d",&n);
    p = (int *) malloc(sizeof(int) * n);
    printf("Enter the Elements of the Array:- \n");
    for(i=0;i<n;i++)
    {
        scanf("%d",(p+i));
    }
    min=*p;
    for(i=0;i<n;i++)
    {
        if(min>*(p+i))
        {
            min=*(p+i);
        }
    }
    printf("The Minimum ammong the Elements is %d",min);
}

p = (int *) malloc(sizeof(int) * n);
Here memory are allocated and the first memory is assigned to the first element.
Hello Here is C program to check If the year entered by user is century Year or not. First we check if the year is Century then check if it is leap or not. And for other check Leap year.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
main()
{
    int year;
    printf("Enter the Year you want to check:- ");
    scanf("%d",&year);
    if(year % 100 ==0)
    {
        if (year % 400 == 0)
        printf("Century Leap Year");
        else
        printf("Not a leap year");
    }
    else
    {
        if(year % 4 == 0)
        printf("Leap Year");
        else
        printf("Not a leap year");

    }
}

And I think you understand this code.
Hello here is a C program to Calculate the factorial and the square of the give number using Call by reference function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<stdio.h>
int ffact(int *);
int sqr(int *);

void main()
{
    int a,fact;
    printf("Enter the number:- ");
    scanf("%d",&a);
    fact=ffact(&a);
    printf("Factorial of the given number is %d\n",fact);
    fact=sqr(&a);
    printf("Square of that number is %d",fact);
}
int ffact(int *p)
{
    int i,fact=1;
    if(*p == 0)
        return 1;
    else
    for (i=1;i<=*p;i++)
    {
        fact=i*fact;
    }
    return (fact);
}
int sqr(int *p)
{
    int a;
    a = *p * *p;
    return (a);
}

And after code here is nothing I think I need to describe about.
Hello Here is a C program to Swap Two integer variable using call by reference.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include<stdio.h>
void swap (int *o, int *p)
{
    int tmp;
    tmp = *o;
    *o = *p;
    *p = tmp;
}
main ()
{
    int a,b;
    printf("Enter the value of A:- ");
    scanf("%d",&a);
    printf("Enter the value of B:- ");
    scanf("%d",&b);
    printf("\nBefore Swap:-\nA = %d\nB = %d",a,b);
    printf("\nAfter Swap:-");
    swap(&a, &b);
    printf("\nA = %d\nB = %d",a,b);
}


Hello Here is a C program to Print address and values at variables
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<stdio.h>
void main()
{
    int a, *b;
    b = &a;
    printf("Enter the value of A:- ");
    scanf("%d",b);
    printf("\n(Indirect) Address of A = %u.\n", b);
    printf("(Direct) Address of A = %u.\n", &a);
    printf("(Pointer) Value of A = %d.\n", *b);
    printf("(Direct) Value of A = %d.\n", a);
    printf("(address operator) Value of A = %u.\n", *(&a));
    printf("Address of B = %u.\n", &b);
    printf("Value of B = %u.\n", b);
    printf("Value of B = %u.\n", *(&b));
}

Run the Program and check the code.
Hello Here is C Program to Find the Location (Place) of a Character That one Lies at Last.
Example: In Apple find P. Answer is 2. In Sagar Find a. Answer is 3. Else Not Found print no found.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<stdio.h>
#include<conio.h>
void main()
 {
   char a,name[10];
   int i,the=0;
   printf("Enter String:- ");
   gets(name);
   printf("Enter Char:- ");
   scanf("%c",&a);
   for(i=0;name[i]!='\0';i++)
   the=the+1;
   for(i=the;i>=0;i--)
   {
    if(a==name[i])
    {
      printf("%d",i);
      break;
      }
   }
   if(i<0)
   printf("Not Found Sorry");
   getche();
   }

And First we find the total character and run the loop from Back and find the the character if found break the loop. else Display not found.
Hello Here is a C program to Swipe a Two Variables With out the use of other verifiable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<stdio.h>
void main()
    {
    int a,b;
    printf ("Enter the value of A:- ");
    scanf ("%d",&a);
    printf ("Enter the value of B:- ");
    scanf ("%d",&b);
    printf("%d is A and %d is B\n",a,b);
    a=a+b;
    b=a-b;
    a=a-b;
    printf("%d is A and %d is B\n",a,b);
    }

Let 4(a) 6(b)
4(a) + 6(b) = 10(a New)
10(a New) - 6(b) = 4(b New)
10(a New) - 4(b New) = 6(a New)

I expect you understand the code above.
Hello Here i a c Program for matrix multiplication of User defined size. Here we create different function to Read data add the data and display them.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
52
#include<stdio.h>
void read(int,int,int [][20]);
void add(int,int,int [][20],int [][20],int [][20]);
void display(int,int,int [][20]);
void main()
    {
    int r,c,mat[20][20],sem[20][20],sum[20][20];
    printf("Enter the Value of Row and Column:- \n");
    scanf("%d %d",&r, &c);
    printf("Enter the First Matrix:- \n");
    read(r,c,mat);
    printf("Enter the Second Matrix:- \n");
    read(r,c,sem);
    add(r,c,mat,sem,sum);
    printf("The Sum matrix is:- \n");
    display(r,c,sum);
    }
void read(int x,int y,int ma[20][20])
    {
    int i,j;
    for (i=0;i<x;i++)
        {
        for(j=0;j<y;j++)
            {
            scanf("%d",&ma[i][j]);
            }
        }
    }
void add(int x, int y,int right[20][20],int left[20][20],int ans[20][20])
    {
    int i,j;
    for (i=0;i<x;i++)
        {
        for(j=0;j<y;j++)
            {
            ans[i][j]=right[i][j]+left[i][j];
            }
        }
    }
void display(int x,int y, int ma[20][20])
    {
    int i,j;
    for (i=0;i<x;i++)
        {
        for(j=0;j<y;j++)
            {
            printf("%d\t",ma[i][j]);
            }
        printf("\n");
        }
    }

The Process is Quite simple in add function we pass 3 matrix so that can store the sum in one of the matrix and display it.
Hello Write some things here
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<stdio.h>
void read(int, int []);
void display(int, int []);
void sort(int, int []);
void main()
    {
    int num, data[50];
    printf("Enter Total no of value to be sorted in Accessending Order:- ");
    scanf("%d",&num);
    read(num, data);
    sort(num, data);
    printf("After SUcessful Arangement in Accessending Order:- \n");
    display(num,data);
    }
void read(int x, int thedata[50])
    {
    int i;
    printf("Enter the values to be inserted in the array:-\n");
    for(i=0;i<x;i++)
        {
        scanf("%d",&thedata[i]);
        }
    }
void sort(int x, int thedata[50])
    {
    int i,j,tmp;
    for(i=0;i<x-1;i++)
        {
        for (j=0;j<x-1;j++)
            {
            if(thedata[j]>thedata[j+1])
                {
                tmp=thedata[j];
                thedata[j]=thedata[j+1];
                thedata[j+1]=tmp;
                }
            }
        }
    }
void display(int x, int thedata[50])
    {
    int i;
    for(i=0;i<x;i++)
        {
        printf("%d\t",thedata[i]);
        }
    }

Here we Use a function to read another to sort and another to display. As passing array is call by reference we need not to return individual value.
Hello Read a String from Users and Print It in Multi line using new line after every words. Read a String "my name is sagar Devkota" and Print it as:-
My
Name
Is
Sagar
Devkota

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<stdio.h>
void nline(char []);
void main()
    {
    char asent[100];
    int i;
    printf("Enter a line of string:- \n");
    gets(asent);
    nline(asent);
    puts(asent);

    }
void nline(char thesent[100])
    {
    int i;
    for (i=0;thesent[i]!='\0';i++)
        {
        if (thesent[0]>='a' && thesent[0]<='z')
            thesent[0]=thesent[0]-32;
        if(thesent[i]==' ')
            {
                thesent[i]='\n';
                if(thesent[i+1]>='a' && thesent[i+1]<='z')
                    thesent[i+1]=thesent[i+1]-32;
            }
        }
    }

Here we Check the case of First and make it capital if it was small. Then check every space and replace it with Newline "\n". and Make Capital all after that space.
Hello Here is a program to count the UPPERCASE lowercase and Total Characters in a String.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include<stdio.h>
#define MAX 100
int ucase(char asent[]);
int lcase(char asent[]);
int total(char asent[]);
void main()
    {
    int u,l,t;
    char asent[MAX];
    printf("Enter a Sentence:-\n");
    gets(asent);
    u=ucase(asent);
    l=lcase(asent);
    t=total(asent);
    printf("In the Sentence ");
    puts(asent);
    printf("Total Letters are %d. Among them %d are UPPERCASE and %d are lowercase",t,u,l);
    }
int ucase(char thesent[MAX])
    {
    int i,count=0;
    for (i=0;thesent[i]!='\0';i++)
        {
        if(thesent[i]>='A' && thesent[i]<='Z')
        count++;
        }
    return (count);
    }
int lcase(char thesent[MAX])
    {
    int i,count=0;
    for (i=0;thesent[i]!='\0';i++)
        {
        if(thesent[i]>='a' && thesent[i]<='z')
        count++;
        }
    return (count);
    }
int total(char thesent[MAX])
    {
    int i,count=0;
    for (i=0;thesent[i]!='\0';i++)
        {
        count++;
        }
    return (count);
    }

We pass the string and Check their case and increment if they are with in the boundary.