Online Examination System for all learner!!! coming soon..

Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

C : Program to Implement Queue Using Array

Code:

/*
 * C Program to Implement a Queue using an Array
 */
#include <stdio.h>
 
#define MAX 50
int queue_array[MAX];
int rear = - 1;
int front = - 1;
main()
{
    int choice;
    while (1)
    {
        printf("1.Insert element to queue \n");
        printf("2.Delete element from queue \n");
        printf("3.Display all elements of queue \n");
        printf("4.Quit \n");
        printf("Enter your choice : ");
        scanf("%d", &choice);
        switch (choice)
        {
            case 1:
            insert();
            break;
            case 2:
            delete();
            break;
            case 3:
            display();
            break;
            case 4:
            exit(1);
            default:
            printf("Wrong choice \n");
        } /*End of switch*/
    } /*End of while*/
} /*End of main()*/
insert()
{
    int add_item;
    if (rear == MAX - 1)
    printf("Queue Overflow \n");
    else
    {
        if (front == - 1)
        /*If queue is initially empty */
        front = 0;
        printf("Inset the element in queue : ");
        scanf("%d", &add_item);
        rear = rear + 1;
        queue_array[rear] = add_item;
    }
} /*End of insert()*/
 
delete()
{
    if (front == - 1 || front > rear)
    {
        printf("Queue Underflow \n");
        return ;
    }
    else
    {
        printf("Element deleted from queue is : %d\n", queue_array[front]);
        front = front + 1;
    }
} /*End of delete() */
display()
{
    int i;
    if (front == - 1)
        printf("Queue is empty \n");
    else
    {
        printf("Queue is : \n");
        for (i = front; i <= rear; i++)
            printf("%d ", queue_array[i]);
        printf("\n");
    }
} /*End of display() */

Output:

Related Links:

  • http://www.sanfoundry.com/c-program-queue-using-array/


Code Master Software

Download Soon Free !!! Free !!! Free !!!
Code Master  is a windows software, which is your one-step solution to learn all the top programming codes - anywhere, anytime!
 Created using research, Code Master offers a perfect path to learn programming. You will not only acquire new skills, but also enjoy it like a game. It's easy, it's fast and it's fun!
    With a huge collection of programs(code examples)  for practice, all your programming needs are bundled in a single app for your daily practice.
https://1drv.ms/u/s!AkQFe4tOtBf9ij596OlLtmnhfID8

What all programming languages you can learn?

  •  C Programming: C programming is a powerful general-purpose language.If you are new to programming then C Programming is the best language to start your programming journey.In practical C programming is used in Embedded stuff, Systems programming.
  •  C++: C++ is used nearly everywhere for everything from systems programming,numerical and scientific computing,web development,writing compilers, console games, desktop applications and so on.
  •  Visual Basic 6.0:
  •  Shell Programming: Coming soon...
  • Java:

 What features do we have?

  • EXAMPLES: over 3300+ programs in 4 languages and counting, Code Master has one of the largest collection of pre-compiled programs with output for practice and learning. We update the program repository regularly based on user's feedback. 
  • COURSES: We provide online course. To make your learning more interesting and less boring, our experts have created bite-sized and interactive courses which will help you learn programming in a better way. It's the best place to understand concepts and start coding using the compiler.

Other Features to improve your learning experience includes:

  1. Concept based illustrations.
  2.  Interactive learning experience.
  3. Quick Search for programs.
  4. Categorized View for programs.
  5. No Harmful Permissions required.
  6. Periodic Updates with new programming examples and course content.
  7. Feedback and support. 
You can contact us at mgcodemaster@gmail.com
To know more about us visit www.programtube01.blogspot.com
https://1drv.ms/u/s!AkQFe4tOtBf9ij596OlLtmnhfID8

Additional Informations: 

Updated : 01-01-2018
Current Version : v3.00.01.9
Required OS : Windows
Size : 5.12mb
Devloper :Maheswar Sahoo And Mr. Gobind Prasad Tripathy
Price : Free!!!

Screenshots:






It also provide a browser for online study

https://1drv.ms/u/s!AkQFe4tOtBf9ij596OlLtmnhfID8



C++: Program to calculate age in years, months and days.

Input the date of birth of a person and find his age in terms of year, month and days. using class.

Age Calculator of a Person

Code:

//for more program please visit www.programtubenotes.blogspot.in 
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#define WELCOME "WELCOME TO AGE CALCULATOR"

using namespace std;


class Age
{
    private:
        int day,month,year;
    public:
        void getdata();   //input date
        friend void show(Age t, Age b, Age a);//calculate age
};
void Age::getdata()
{
    cin>>day>>month>>year;
}
void show(Age t, Age b, Age a)
{
    if(t.day<b.day)
    {
        t.month--;
        t.day+=30;
    }
    a.day=t.day-b.day;
    if(t.month<b.month)
    {
        t.year--;
        t.month+=12;
    }
    a.month=t.month-b.month;
    a.year=t.year-b.year;
    cout<<"\nYour Age is  "<<a.year<<" year "<<a.month<<" month "<<a.day<<" day ";
   
    cout<<"\n\n\nCreated By:- Mr. Maheswar Sahoo\nFor more application please contact:-maheswarsahoo47@gmail.com";
    cout<<"\nThank You...\n\n\n";
}
int main()
{
    system("COLOR 4C");  //for background color
    Age birth;
    Age today,age;
    cout<<"\t\t\t\t"<<WELCOME;
    cout<<"\n\n\nEnter date of today (dd mm yyyy) : ";
    today.getdata();
    system("COLOR 1C");   //change background color
    cout<<"\nEnter date of birth (dd mm yyyy) : ";
    birth.getdata();
    show(today,birth,age);
    return 0;
}



We suggest this video to watch:




Related word:
Class



Popular codes:

C Programming Online Test 1

Following quiz provides Multiple Choice Questions (MCQs) related to C Programming Framework. You will have to read all the given answ...