-->

Wednesday, April 8, 2015

Unstructured technique of programming in C language

Definition : An approach of designing a program simply using series of statements is called unstructured programming.
In such programming technique every task is solved using series of simple statements only. Branching and repetitions are achieved through a 'goto; statement. Jumping to and out of a block of statements is achieved through 'goto' statement. So, a technique using 'goto' statement is called unstructured technique of programming.

Example:
Problem: Design a program to find factorial of a number
The program required is to find n!=1*2*3*4.....*(n-1)*n. If negative number is entered a proper message is to be displayed. So, the repetition and branching is achieved in unstructured programming technique using 'goto' statement. The statement 'goto' in C is used to take the control from one point to another irrespective of the location of transfer. It takes control to the specified label.

#include<stdio.h>
main( )
{
int n;
unsigned long int fact =1;
ReadAgain:     /* first label to transfer the control */
printf("Enter a number:");
scanf("%d", &n);
if(n<0)
{
printf("Negative number \n");
goto ReadAgain;    /* Control transferred */
}

Repeat:      /* second label to transfer the control  */
fact = fact*n;
n--;
if(n>=1) goto Repeat;  /* Control transferred to label Repeat */
printf(" The factorial is %lu", fact);
}

Features of unstructured technique

  • Simple statements are used to solve a task.
  • The statements used are basic and understandable.
  • This type of programming is called liner programming.
  • The approach is straight forward.
  • To branch from one point to other only a simple 'goto' statement is used.
  • Even to repeat a part of the program 'goto' statement is used.
  • Every logic of the program is developed using only 'goto' statement.
Merits of unstructured technique 
The unstructured technique of programming although having some merits is not at all entertained to design the programs. The merits to just list are:
  • The program designed is simple.
  • The logic is simple and straight forward.
  • Only one statement 'goto' is used for branching as well as looping.
Demerits of unstructured technique
The unstructured technique of programming is very rarely used. It is never entertained because of its demerits. The demerits of the unstructured technique are:
  • To follow the logic of the program is very difficult.
  • There may be abrupt transfer from one point to another.
  • This technique can be applied only to small-scale programs.
  • Difficult to keep track the logic of the program.
  • Excessive use of 'goto' statements causes confusion in program flow.
  • The quality of the program decreases as the number of 'goto' statements increases.
  • Program designed using this technique is not clear for the others and also at times to the designer of the program.
  • It is difficult for the programmer to understand the logic at the later stage.
  • Because of excessive use of 'goto' statements tracing the error is very difficult.
  • Testing of program consumes lots of time.
  • Redesigning a program is much more difficult.
  • Unstructured programs consist of statements that are not grouped for specific tasks.
  • The logic of such programs is messy with details and therefore difficult to follow.

How to change style, theme of page in windows store

If you want to change your page theme, use RequestTheme property  in App.Xaml file. Basically theme is designed for better look. Bydefault, our windows store app uses dark theme. The System resource also included a light theme.

In Solution Explorer, double click App.xaml to open it.
In the opening Application tag, add the RequestedTheme property with its value set to Light.

App.xaml file 

<Application
    x:Class="App4.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App4" RequestedTheme="Light">

</Application>

Lets see after set the property

How to change style, theme of page in windows store
Your background theme will be changed after set property.

How to modify the start page in windows store app

In this tutorial, you learn how to

  • Before you start
  • Create a new project.

Before you start...

Create a new project in Visual Studio

Step-1 : Launch Visual Studio 2013.
Step-2 : Select File > New Project.
Step-3 : In the left pane, expand Installed > Templates, then expand Visual Basic or Visual C# and pick the Windows Store template type.
Step-4 : In the center pane, select the Blank App template.
Step-5 : In the Name text box, according name you enter.
Step-6 : Click OK to create the project.
Step-7 : Remove MainPage.xam file from the solution explorer
Step-8 : Add basic page to solution explorer and assign name to Page as "MainPage.xaml" instead of BasicPage1
Step-9 : Click ok

modify the start page

Step-1 : Double-click MainPage.xaml in Solution Explorer to open it
Step-2 : For change the page title, select the "My Application" text near the top of the page in the XAML designer.
How to modify the start page in windows store app

Use of CheckBox Control in windows store app

Desing Page


<Page
    x:Class="App1.checkBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">



    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

        <CheckBox x:Name="check1" Content="MVC" HorizontalAlignment="Left" Margin="263,152,0,0" VerticalAlignment="Top" Height="45" Width="256" Checked="check1_Checked" />

        <CheckBox x:Name="check2" Content="ASP.NET" HorizontalAlignment="Left" Margin="263,81,0,0" VerticalAlignment="Top" Height="45" Width="256" Checked="check2_Checked_1" />
        <Button Content="Check " HorizontalAlignment="Left" Margin="242,287,0,0" VerticalAlignment="Top" Width="137" Click="Button_Click"/>

        <TextBlock  FontSize="20" x:Name="Label1" HorizontalAlignment="Left" Margin="387,84,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Height="113" Width="223"/>

    </Grid>
</Page>

// Code behind file


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace App1
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class checkBox : Page
    {
        public checkBox()
        {
            this.InitializeComponent();
         
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (check1.IsChecked == true)
            {
                Label1.Text += check2.Content+"\n";
            }
            if (check2.IsChecked == true)
            {
                Label1.Text += check1.Content;
            }  
        }


        private void check2_Checked_1(object sender, RoutedEventArgs e)
        {

        }

        private void check1_Checked(object sender, RoutedEventArgs e)
        {

        }
    }
}

Code Generate the following output

Use of CheckBox Control in windows store app

Tuesday, April 7, 2015

Bind Image in code file, Windows Store App

Design Page

<Page
    x:Class="App1.ImageCode"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Image x:Name="image1" HorizontalAlignment="Left" Height="246" Margin="113,131,0,0" VerticalAlignment="Top" Width="296"/>

    </Grid>
</Page>

// Code behind file


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace App1
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class ImageCode : Page
    {
        public ImageCode()
        {
            this.InitializeComponent();
            BitmapImage bi = new BitmapImage();
            bi.UriSource = new Uri(this.BaseUri, "joli.jpg");
            image1.Source = bi;


        }
    }
}

Code Generate the following output

Bind Image in code file, Windows Store App

Use Of Image Control in windows Store App

<Page
    x:Class="App1.imagecontro"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">



    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">


        <Image Source="joli.jpg" HorizontalAlignment="Left" Height="279" Margin="240,138,0,0" VerticalAlignment="Top" Width="399"/>

    


    </Grid>
</Page>

Code Generate the following output

Use Of Image Control in windows Store App

Combobox Selected_Index Changed event example in Windows Store

The Design 

<Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <ComboBox x:Name="combo1" HorizontalAlignment="Left" Margin="128,130,0,0" VerticalAlignment="Top" Width="272" SelectionChanged="combo1_SelectionChanged"/>
        <TextBlock HorizontalAlignment="Left" Margin="115,57,0,0" TextWrapping="Wrap" Text="Select Your Items" FontSize="20" VerticalAlignment="Top" Height="35" Width="285"/>
        <TextBlock x:Name="Label2" HorizontalAlignment="Left" Margin="115,203,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="29" Width="178"/>

    </Grid>
</Page>

// Code behind code


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace App1
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            combo1.Items.Add("Button Control");
            combo1.Items.Add("Label Control");
            combo1.Items.Add("Media control");

        }

        private void combo1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Label2.Text = combo1.SelectedItem.ToString ();

        }
    }
}
Combobox Selected_Index Changed event example in Windows Store

© Copyright 2013 Computer Programming | All Right Reserved