Tuesday, 10 July 2012

Program to subtract two numbers in C++


Code -



/* Program to subtract two numbers in C++ */

//__ "\n" is used for new line and "\t" for a tab (spaces) ___

//__ cin is to take the input and cout is used to dispaly the output ___

#include<iostream>

//___ Header file in C++ where the standard input/output functions are defined ___

#include<conio.h>

using namespace std;

int main()
{
int first_number = 0, second_number = 0, subtract = 0;

cout << "\n\t\t __ Program to subtract two numbers in C++ ___";

cout << "\n\n  Enter the First number  - ";

cin >> first_number;

cout << "\n\n  Enter the Second number - ";

cin >> second_number;

subtract  = first_number - second_number;

cout << "\n\n\t\t    ___  Subtraction of " << first_number;

        cout <<  " and " << second_number << " is " << subtract << " ____";


getch();

return 0;

/*____ return 0 tells the compiler that program

has executed successfully without any error ____ */

}

Program to add two numbers in C++


Code -


/* Program to add two numbers in C++ */

//__ "\n" is used for new line and "\t" for a tab (spaces) ___

//__ cin is to take the input and cout is used to dispaly the output ___

#include<iostream>

//___ Header file in C++ where the standard input/output functions are defined ___

#include<conio.h>

using namespace std;

int main()
{
int first_number = 0, second_number = 0, sum = 0;

cout << "\n\t\t __ Program to add two numbers in C++ ___";

cout << "\n\n  Enter the First number  - ";

cin >> first_number;

cout << "\n\n  Enter the Second number - ";

cin >> second_number;

sum  = first_number + second_number;

cout << "\n\n\t\t    ___  Sum of " << first_number << " and " << second_number << " is " << sum << " ____";

getch();

}

How to write Hello World in C++


Code -

/* There are two ways to print a statement on console in C++
1. To use the namespace name just before cout.
2. Write the "using namespace" keyword at the top and the namespace name
*/

#include<iostream>

#include<conio.h>

using namespace std;

void main()
{
cout << "\n\n\t\t\t ___Hello World in C++___";

getch();
}

Monday, 9 July 2012

Program to check the number for being Palindrome in C


Code -



/* Program to check a number for being Palindrome */

/* A Palindrome number is a number that such that if we will reverse the number, it will not change */

//___ Including header files as known as preprocessor directives _____

#include<stdio.h>

#include<conio.h> //____ Mainly included for the getch() function ____

int main() //____ Function from where the program execution starts _____
{
int number = 0, reverse_number = 0, temp_number = 0, remainder = 0;

//____ Variable declaration and initialization _____

printf("\n\t __ Program to check a number for being Palindrome ___");

printf("\n\n   Enter the Number - ");

scanf("%d",&number);

temp_number = number;

while(temp_number != 0) //___ Reversing the digit using while loop ___
{
remainder = temp_number % 10;

//____ Extracting the digits one by one till temp_number becomes 0 ___

temp_number = temp_number / 10;

reverse_number = reverse_number * 10 + remainder;

//___ Constructing the number ____

}

printf("\n\n   Reverse number of %d is %d ", number, reverse_number);

if (reverse_number == number)

/* Checking whether the reversed number is equal to the original number */

{
printf("\n\n\n\t\t ___%d is a Palindrome number___", number);
}
else
{
printf("\n\n\n\t\t ___%d is not a Palindrome number___", number);
}

getch(); //___ Holding the screent to display output ____

return 0;

/* return 0 tells the compiler that program has executed successfully

 without any error____*/
}

Follow Us on Facebook - Assignment Hub

Sum of the digits of 5 digit number in C


Code - 



/* Program to find the sum of the digits of a 5 digit number */

#include<stdio.h>

#include<conio.h>

#include<stdlib.h> //____ Header file included for system("cls") _____

int check_five(int number);

int main()
{
int number = 0, sum = 0, remainder = 0, temp = 0, check = 0;

while(check != 1)
{
system("cls");

printf("\n    __ Program to calculate the sum of the digits of 5 digit number ___");

printf("\n\n\n  Enter the Number - ");

scanf("%d",&number);

check = check_five(number);

if (check == 0)
{
//__ Error Message____

printf("\n\n\t\t____ 5 digit number is required ____");

printf("\n\n\n  Press Enter to Continue....");

while(getch() != 13)
{
}
}
}

temp = number;

while(temp != 0)
{
remainder = temp % 10;

temp = temp / 10;

sum = sum + remainder;

//___ finding the sum of the digits ____

}

printf("\n\n  The sum of the digits of number %d is %d", number, sum);

getch();

return 0;

}

int check_five(int number)
{
int remainder = 0, counter = 0;

while(number != 0)
{
remainder = number % 10;

number = number / 10;

counter++;
}

if (counter == 5)

/*___ Change 5 to make this program for any digit number, but do check the value of

 integer before doing that */
{
return 1;
}
else
{
return 0;
}
}

Follow Us on Facebook  - Assignment Hub

Sunday, 8 July 2012

Program to print Fibonacci series in C


Code -



/* ___ Program to print the Fibonnaci series _____ */

/* Program will take a number as an input and print that much numbers of the fibonacci series */

/* Logic - Fibonacci series starts from 0 and the second number is 1. The third number can be

calculated by adding the previous two numbers */

#include<stdio.h>

#include<conio.h>

int main()
{
int first_number = 0, second_number = 0, third_number = 0, series_length = 0, temp = 0;

printf("\n\t ______ Program to print Fibonacci Series ______");

printf("\n\n  Enter the Length of the Series - ");

scanf("%d", &series_length);

//__ Prompting the user to input the total numbers to be printed in the fibonacci series ____

first_number = 0;

second_number = 1;

printf("\n\n  Fibonacci Series -\n\n  \t%d, %d", first_number, second_number);

for(temp = 3; temp <= series_length; temp++)
{
third_number = first_number + second_number;

printf(", %d", third_number);

//______ Assigning new value to the variables first_number and second_number _______

first_number = second_number;

second_number = third_number;

}

getch(); //____ Holding the Output ____

return 0;

/*______ Return 0 tells the compiler that program has executed successfully without any

error_______*/


}

Friday, 6 July 2012

Credit Cards - “Filling pockets or making bankrupt”




Credit Cards -

        Many of us might have heard about credit cards and now a days people also consider this as a status symbol. Look I have a gold credit card, I have premium. But when asked many of them are not able to differentiate between those credit cards. Many people even don't the difference between a credit card and a debit card. 


A Credit Card is like a loan you borrow something by agreeing that you would pay for it in the future along with some interest (extra money) whereas a Debit Card means you have something in your bank account and you are using it. 

A Credit Card offers various features such as an Alternative to Cash, Record keeping of all transactions, Gifts and other Coupons,  a credit limit etc. Every customer has different financial needs and based on those financial needs there is a different credit card. Credit cards can be divided into 5 broad categories - Standard cards, Premium cards, Secured cards, Charge cards, Prepaid cards. Credit card offer various benefits such as refund on the loss, stolen of goods purchased through credit cards. 

Conclusion - Credit card is very convenient financial short-term lending facility available to a credit cardholder.


Follow Us on Facebook - Assignment Hub

Wednesday, 4 July 2012

Logic for implementing data encryption and decryption


Suppose there is one message and the user enters a number/key (3 digit number). Now the data need to be encrypted in a form that is unreadable and if the number is entered again then data need to be decrypted again back to the readable form. 

Logic - 

                Extract the first and last digit of the number. For example, the first digit is 3 and last digit is 4 replace the character at 3rd position with 4th and 4th position with the 3rd position. Then multiply the first digit and last digit with 2 and continue the same operation of replacing the characters until any value whether its first or last exceeds the message length. 

Note - This process can be continued as  many times, the more the times the steps are repeated more difficult it will be to get the original message. 

After doing this all the spaces can be replaces with a special character. 

The decryption process is totally reverse. First replace all the special character with the spaces (the special character which was used to replace the space before). Scan the number/key again because until the same number/key will be entered, the message need not to be decrypted. After that extract the first and last digit multiply it with 2 until the value of any digit whether first number and last number is greater than the message length and the previous value of first and last digit before multiplying it with 2 must be stored (previous value means that if corresponding value of first and last digit are (4.2),(8,4),(16,8) so for (16,8) (8,4) must be kept). and now replace the characters at those particular positions (at previous value that was kept where the value exceeded the message length) and then divide the values(first and last digit) by 2 (during encryption we multiplied them with 2) and continue the process until the value of first and last digit is not same as the first and last digit of the number being scanned. You again got the decrypted data.

Note - The message length should be even, if it is not convert it to even first by adding a space at the last position.

 For any query do comment..and we can be reached as Assignment Hub on Facebook.


Swapping of numbers without using a temporary variable in C


Code - 


//_________Swap 2 Numbers without using a temporary variable _________

//________________Include Header Files_____________

#include<stdio.h>

#include<conio.h>

//_Header field included mainly for the getch() function__

int main()

//_______Function from where program execution starts_________________

{
int first_number = 0, second_number = 0;

printf("\n\n\t\t   ______Program will Swap 2 Numbers_______");

printf("\n\n\n Enter the First Number  - ");

//_________Prompting the user to enter First Number_________

scanf("%d",&first_number);

//___Reading the user_input and storing input in variable first_number__

printf("\n Enter the Second Number - ");

//_________Prompting the user to enter Second Number_________

scanf("%d",&second_number);

//_________Reading the user_input and storing input in variable second_number________

//______________Displaying the user input once again________________

printf("\n\n\t Numbers before swapping :- \n\n\t\t First  - %d \n\n\t\t Second - %d", first_number, second_number);

//____________Swapping of two numbers________________

/* logic changes here instead of taking a temporary variable add the numbers and assign the value to the first variable */

first_number = first_number + second_number;

/* from the new number subtract the second number and assign it to second number as

the second number is still the same as entered by the user */

second_number = first_number - second_number;

/* Repear the same step for first number subtract second number from first as now the second number has been changed */

first_number = first_number - second_number;


//__________Displaying the numbers after swapping____________

printf("\n\n\t Numbers after swapping :- \n\n\t\t First  - %d \n\n\t\t Second - %d", first_number, second_number);

printf("\n\n________________________________________________________________________________");

getch();

return 0;

//__return 0 tells the compiler that program has executed succesfully without any error__


}


Tuesday, 3 July 2012

Program to display a pattern in form of reverse stairs in C


Code - 


//_________Program to display a pattern in form of reverse stairs________________

/*_________Sample Pattern_______________________

pattern -
4444
333
22
1

1, 2, 3, 4 represent the coloumn number in a row.....Number of rows will be inputted by the user___*/

//___________________Import Header Files__________________

#include<stdio.h>

#include<conio.h>

int main()

  //__________Main Function from where the program execution starts____________

{
int row = 0, coloumn = 0, user_input;

//____Variable declaration and initialization________


printf("\n\n\t     _________Program will display the pattern_________");

printf("\n\n Enter the total number of coloumns required - ");

//________Prompting the user to enter the total number of rows______

scanf("%d", &user_input);

//____Reading the user input and storing it in variable user_input___

printf("\n\n Pattern - \n\n");

for(coloumn = user_input; coloumn >= 1 ; coloumn--)

       //_____Looping construct from user_input to 1____
{
printf("\t"); //_______Display 5 spaces_____

for(row = 1; row <= coloumn; row++)
{
printf(" %d",coloumn);

//_____Display the coloumn number (total coloumns in a row)________

                }
printf("\n");


//_____Taking the cursor to the next line_______

}


getch();

return 0;
}

Follow Us on Facebook - Assignment Hub

Remove spaces between substrings of string in C


Code - 


/*__Program to remove two consecutive spaces between various substrings of a string___*/

//___________Inlcuding header files___________

#include<stdio.h>

#include<conio.h> //_________Mainly included for the getch function_____________

#include<string.h> //_________Mainly included for gets() function used to scan a string___________

int main()
{
char original_string[20];

int i = 0, j = 0;

printf("\n\n  __ Program to remove consecutive spaces between sub-strings of a string __");

printf("\n\n\n\n\t   Enter the String - ");

gets(original_string);

for(i = 0; original_string[i] != '\0'; i++)
{
if (original_string[i] == 32)
{
if (original_string[i+1] == 32)
{
for (j = i; original_string[j] != '\0'; j++ )
{
original_string[j] = original_string[j+1];
}

i = i - 1;
}
}

}

printf("\n\n\t       Final String - ");

puts(original_string);

getch();
}

Follow Us on Facebook - Assignment Hub

Uppercase to lowercase in C


Code -


//__________Program to know the ASCII value of a character____________

/* To convert a character into lowercase 32 must be added to its ASCII value */

//__________Including header files___________

#include<stdio.h>

#include<conio.h>

//__________Mainly included for the getch() function________

#include<string.h>


//__________Mainly included for the gets() function to read the string_______

int main()
{
char input_string[25], original_string[25];

int counter = 0;

printf("\n\n\t\t__ Program to convert a string into lowercase __");

printf("\n\n\n\tEnter the String - ");

gets(input_string);

strcpy(original_string,input_string);

//______ strcpy(string1, string2) function is used to copy string2 in string1 ______

for(counter = 0 ; input_string[counter]; counter ++)
{
if ((input_string[counter] >= 65) && (input_string[counter] <= 91))
{
input_string[counter] = input_string[counter] + 32;
}
}

printf("\n\n\t\t   Original String         -   ");

puts(original_string);

printf("\n\t\t   String in Lowercase     -   ");

puts(input_string);



getch();

return 0;
}

Display the ASCII value of a character in C



Code -


//__________Program to know the ASCII value of a character____________

//__________Including header files___________

#include<stdio.h>

#include<conio.h> //__________Mainly included for the getch() function________

int main()
{
char input_character;

printf("\n\n\t__ Program to display the ASCII value of a character ___");

printf("\n\n\n  Enter Character - ");

input_character = getche();

printf("\n\n\t\t   __ ASCII value for %c is %d __ ",input_character, input_character);

getch();

return 0;

}

Follow Us on Facebook -  Assignment Hub

Delete an element from an array in C


Code - 


//____Program to delete an element from an array at a particular position____

//______Including Header Files___

#include<stdio.h>

#include<conio.h>

#include<stdlib.h>

int main()
{
int elements[9], position = 0, element = 0, counter = 0;

printf("\n\t______ Delete an element from an array at a particular position ______");

printf("\n\n   Emter the elements :- ");

for(counter = 0 ; counter <= 8; counter ++)
{
printf("\n\n\t%d element - ", counter + 1);

scanf("%d", &elements[counter]);
}

system("cls");

printf("\n\t______ Delete an element from an array at a particular position ______");

printf("\n\n  Elements entered in array :-  \n\n");

for(counter = 0; counter <= 8; counter ++)
{
if (counter % 3 == 0)
{
printf("\n\n");
}
printf("  '%d' Position - %d        ", counter + 1, elements[counter]);
}

printf("\n\n\t Enter the position to delete an element :- ");

scanf("%d", & position);

element = elements[position - 1];

for(counter = position - 1; counter <= 7; counter ++)
{


elements[counter] = elements[counter + 1];
}

printf("\n\n  Elements entered in new array :-  \n\n");

for(counter = 0; counter <= 7; counter ++)
{
if (counter % 3 == 0)
{
printf("\n\n");
}
printf("  '%d' Position - %d        ", counter + 1, elements[counter]);
}

printf("\n\n  Element deleted - %d at position %d ", element, position);

getch();


}

Follow Us on Facebook - Assignment Hub

Convert Decimal Number into Binary Number in C ( Version 1 )


Code -


//__Program to convert Decimal number into Binary number Version 1___

/* Best works for number less than 999 */

//___________Including header files_____________

#include<stdio.h>

#include<conio.h>

int main()
{
int decimal_number = 0, remainder = 0, temp_number = 0, binary_number = 0, counter = 1;

printf("\n\n\t__ Program to convert Decimal number into Binary number __ ");

printf("\n\n\n  Enter the Decimal Number - ");

scanf("%d",&decimal_number);

temp_number = decimal_number;

while(temp_number != 0)
{
remainder = temp_number % 2;

temp_number = temp_number / 2;

binary_number = binary_number  + remainder * counter ;

counter = counter * 10;
}

printf("\n\n\t   Binary equivalent of Decimal number - %d is %d",decimal_number, binary_number);

getch();

return 0;
}

Follow Us on Facebook - Assignment Hub

Swapping of numbers in C


Code -


//_________Swap 2 Numbers inputted by the user_________

//________________Include Header Files_____________

#include<stdio.h>

#include<conio.h>

//_______Header field included mainly for the gecth() function________

int main()

//_______Function from where program execution starts_________________

{
int first_number = 0, second_number = 0, temp_number = 0;

printf("\n\n\t\t   ______Program will Swap 2 Numbers_______");

printf("\n\n\n Enter the First Number  - ");

//___Prompting the user to enter First Number_____

scanf("%d",&first_number);

//___Reading the user_input and storing input in variable first_number___

printf("\n Enter the Second Number - ");

//__Prompting the user to enter Second Number___

scanf("%d",&second_number);

//___Reading the user_input and storing input in variable second_number___

//__Displaying the user input once again____

printf("\n\n\t Numbers before swapping :- \n\n\t\t First  - %d \n\n\t\t Second - %d", first_number, second_number);

//____________Swapping of two numbers________________

temp_number = second_number;

//__Assigning the value of second_number in a temp_number__

second_number = first_number;

//__Assigning the value of first_number to second_number___

first_number = temp_number;

//__Assigning the value in temp_nhumber to first_number___

//__Displaying the numbers after swapping___

printf("\n\n\t Numbers after swapping :- \n\n\t\t First  - %d \n\n\t\t Second - %d", first_number, second_number);

printf("\n\n________________________________________________________________________________");

getch();

return 0;

}

Follow Us on Facebook - Assignment Hub

Reverse a digit using array in C ( 5 Digit number )



Code - 

//___Program to reverse a 5 digit number___

/* There are 2 ways for reversing a number....1 is implemented below and for other

   check Reversing a number Version 2

   Logic - The first way is to extract the digits one by one and store them in an array and print the array

   Disadvantage of using this type of method is that it is space consuming i.e. requires memory

   of 5 variable */

//_________Including Header Files____________

#include<stdio.h>

#include<conio.h>

//________Included mainly for the getch() function____________

int main()
{
int number, number_digits[5], counter = 0, remainder = 0, temp_number = 0, i = 0;

//_________Variable declaration_________

printf("\n\n\t\t   _______ Reverse the 5 digit number _________\n\n\n");

printf("  Enter a 5 digit number - ");

//___Prompting the user to enter a 5 digit number____

scanf("%d", &number);

//____Reading the user inputr and storing it in variable number of type integer___

temp_number = number;

while(number != 0)

/*__Looping Construct which will keep on executing till number does not become 0 when divided by

10__ */
{
remainder = number % 10;

/*_Extracting the digit using modulus operator by gettning the remainder after dividing the

number by 10__ */

number = number / 10;

/*_Changing the value of number by assigning it the quotient obtain after dividing it by 10__ */

number_digits[counter] = remainder;

//___Assigning the digits one by one to the array elements____

counter++;
/*__Counter variable is used to count the number of digits in the original number inputted ___ */

}

if (counter != 5)

//_________Checking whether the total number of digits were 5 or not____________
{
printf("\n\n\t  ___ 5 Digit number was required ___");
}

printf("\n\n\t\t  Reverse of %d number %d entered is  - ", counter, temp_number);

for (i = 0; i <= counter - 1; i++)

//__________Looping construct to display the elements of the array___________

{
printf("%d", number_digits[i]);

}

getch();

return 0;

/*_return 0 tells the compiler that program has executed successfully without any error__ */

}

Follow Us on Facebook -  Assignment Hub

Real roots of a Quadratic Equation in C


Code -


//___________Real roots of quadratic equation...(Function Example)________

/* Quadratic equations has roots if and only if the Discriminent of a quadratic equation is greater than or equal to 0

D = b * b - 4 a * c

The formula given above is used to check whether real roots exist or not before calculation */


//____________Inlcude Header Files____________

#include<stdio.h>

#include<conio.h>

//_________Inlcuded mainly for getch() function_________

#include<math.h>

//Included mainly for the sqrt() function______

int check_roots(int a, int b, int c);


//__________Function prototype to check whether real roots exist or not_________

void roots(double discriminent, int a, int b, int c);

//_________Function prototype to find out the roots of quadratic equation____________

int main()

//_________Function from where the program execution starts_____________

{
int xsq_coefficient = 0, x_coefficient = 0, constant = 0, discriminent = 0;

printf("\n\n      _______Program will calculate the roots of a Quadratic Equation______");

printf("\n\n Quadratic Equation is in form of :- \n\n\t A (x * x) + B (x) + C = 0, where C is a constant"); //_______Message for User________

printf("\n\n\t Enter the value for A - ");

//__Prompting the user to enter the value for coefficient of X square i.e. x * x__

scanf("%d", &xsq_coefficient);

//__Reading the user input and storing it in variable xsq_coefficient______

printf("\n\t Enter the value for B - ");

//__Prompting the user to enter the value for coefficient of X ___

scanf("%d", &x_coefficient);

//_Reading the user input and storing it in variable x_coefficient__

printf("\n\t Enter the value for C - ");

//_Prompting the user to enter the value of C__

scanf("%d", &constant);

//_Reading the user input and storing it in variable constant____

discriminent = check_roots (xsq_coefficient, x_coefficient, constant);

//_____Calling the check_roots function to get the value for discriminent______

if (discriminent >= 0)

//___Checking if discriminent if +ive and greater than equal to 0, roost exist____
{
roots((double)discriminent, xsq_coefficient, x_coefficient, constant);

/*___Calling the roots function to find out and display the roots for the quadratic equation__*/
}
else
{
printf("\n\n\t\t ________Roots are not real________");
//__________If roots dont exist, message gets displayed_______________

}

printf("\n\n_______________________________________________________________________________");

getch();

return 0;
/*_Return 0 tells the compiler that this program has executed successfully without any error___*/

}

int check_roots(int a, int b, int c)
{
int discriminent = 0;

discriminent = b * b - 4 * a * c;

//_Calculating discriminent using the given formula_

return discriminent;
}

void roots(double discriminent, int a, int b, int c)
{
double x1 = 0, x2 = 0;

//__Finding the first root_____

x1 = x1 + sqrt(discriminent);

x1 = x1 - b;

x1 = x1 / (2 * a);

//___Finding the second root___

if (discriminent == 0.00)
{
x2 = x1; //___If discriminent is 0, then roots are equal_
}
else
{
x2= x2 - sqrt(discriminent);

x2 = x2 - b;

x2 = x2 / (2 * a);

}

printf("\n\n  Roots for the Quadratic Equation :- %lf, %lf",x1,x2);

//____________Displaying the value for the roots______________

}

Monday, 2 July 2012

Prime number between 1 to 300 in C


Code -


//__Program to print all prime numbers from 1 to 300._

/* A number is said to be a prime number if it is greater than 1 and has exactly 2 divisors,
one is the number itself and other is 1 For Example - Among 1 to 6, 
2-4-5 are prime numbers */

//_________Including Header Files in the program__________

#include<stdio.h>

#include<conio.h>

//__________Mainly imported for getch() Function______________

int main()

 //__________Main Function from where the program execution starts____________

{
int number = 0, counter = 0,temp_counter = 0, temp = 0, display_newline = 0;

       //__________Variable Declaration and Initialization_____

printf("\n\n\t  ___ Program will display prime number between 1 to 300 ___");

printf("\n\n\n\tPrime Numbers -  ");

for(counter = 2; counter <= 300 ; counter ++)

//________Looping construct will run from 2 to 300__________

{
number = counter;

         //____Copying the value of counter to variable named number________

temp = 0;

for (temp_counter = 1 ; temp_counter < counter ; temp_counter++)
{

/* This looping construct will work one less time the number and will
check whether the given number is divisible by any number less than the original number,
 if it is divisible a variable named as temp will be incremented by 1.
*/

if ((number % temp_counter) == 0)
{
temp++;
}
}

if (temp == 1)
/*______As mentioned at the starting the number is a prime number if it is
 divisible by 1 and number itself and in the above for loop, it is checked
 whether the number is divisible by any number between 1 and (number - 1),
 so if temp is equal to 1 then it is a prime number */

{
printf("%d, ", number);
}

}

getch();

return 0;

//__return 0 tells the compiler that program has executed successfully without any error_

}

Follow Us on Facebook - Assignment Hub

Find minimum number in an array in C


Code - 


//_Program reads 5 numbers and find the minimum out of them .... (Array Example)__

//__________Include Header Files___________

#include<stdio.h>

#include<conio.h>

//____________Mainly used for the getch() function______________

int main()

//_____This is the function from where the program execution starts____

{
int number[5], temp = 0, minimum = 0;

//_________Array index starts from 0 and runs till (Size - 1)_______________

printf("\n\n\t\t________Finding the minimum out of 5 numbers_________\n\n");

for(temp = 0; temp < 5 ; temp++)

//__________Looping construct from 0 to 4 i.e. 5 times___________

{
printf("\n  Enter the %d number - ",temp + 1);

//___________Prompting the user to enter the numbers____________

scanf("%d", &number[temp]);

//_____________Reading the numbers and adding them to array__________
}

minimum = number[0];

//__________Assuming the first number is the minimum number____________

for (temp = 1; temp < 5; temp++)
{
if (number[temp] < minimum)

//______ Checking if the other elements in the array is less than the minimun set______
{
minimum = number[temp];
}
}

printf("\n\n________________________________________________________________________________");

printf("\n\n\t\tMinimum Number :- %d", minimum);

//___________Displaying the lowest number____________

getch();

return 0;

//__Return 0 tells the compiler that program execution has been done without any errors_

}


Follow Us on Facebook -  Assignment Hub