Wednesday, July 6, 2016

Electronic Telephone Exchange / Stored Program Control / Digital Telephone Exchange:

Electronic Telephone Exchange / Stored Program Control / Digital Telephone Exchange:




Switching Network:
The switching Network provides means of connection for telephone lines and trunk lines under directions provided by CPU with stored program in it’s semi-permanent memory.

Memory:
Temporary Memory
Semi- Permanent Memory
CPU stores information regarding calls in operation from scanner to temporary memory.
It consists of Operating Program and application program along with fixed data relating to telephone lines and trunk.

CPU:
It is the interface between software and hardware. It operates hardware according to instructions given by programs stored in semi-permanent memory.

Scanner:
CPU gets to know status of telephone lines and trunk by continuously scanning once in 100ms carried out by scanner.
CPU writes information about lines after each scan in temporary memory.
Each line and trunk is equipped with sensing device.

Distributer:
Signaling over lines and trunks are provided by the distributer under direction from CPU.
CPU tells distributer when to start and stop signaling.

Operator Console:
It is used by operating personal to control and observe overall process.
The operating personal can also write or erase data related to lines and trunk in semi-permanent memory.
Operator Console are used for:
 1. Alarm
 2. Line and trunk task facility            
 3. Display      
 4. Maintenance

  ⓒNotoriousGarage http://notoriousgarage.blogspot.com

  https://www.youtube.com/channel/UCyEHyFZjtwWxyPrxkUgJyeQ


Saturday, July 2, 2016

How does structure differ from array ? Q.no 9 2068 shrawan IOE

Q. How does structure differ from array ?

Array:
- Array is collection of similar data types.
- Each array element is accessed by array name followed by index with square brackets [] as:
    array_name[index];
- Array is declared with fixed size which it allocates some space in memory.
example:

#include<stdio.h>
int main() {
int a[10],i;
printf("\nEnter array Elements: ");
for (i=0;i<10;i++)
{
scanf("%d",&a[i];
}
printf("\nArray elements are : ");

for(i=0;i<10;i++){
printf("\n%d",a[i];
}
return 0;
}

Structure:
-Structure is collection of similar and dissimilar data types.
- Each structure element is accessed by using a dot operator(.) as :
  structure_name.structure_element
- Before declaring a structure we have to define a structure data type along with its elements to inform compiler about it.
example:

struct students {
char name [20];
int roll;
};
void main (){

struct students s;
printf("Enter name and roll number of student:");
scanf("%s%d",s.name,&s.roll);
printf("\n Name: %s \t Roll no : %d",s.name,s.roll);
}

C- Programming IOE 2067 Ashadh Q.No:7

Q 7 : WAP according to the display below :
Open a file named RECORD.txt for 'n' number of data where cost, service charge 5%, VAT 15% and total cost must be calculated by the program itself. [10 Marks]






Code Here :

// This code has been tested in Xcode 7.3 
//  main.c
//  resturentBilling
//
//  Created by Notorious MAC on 7/2/16.
//  Copyright © 2016 NotoriousMAC. All rights reserved.
//

//WAP to open a file named Record.txt for n number of data where cost, service charge 5%, VAT 15% and total cost must be calculated by program itself.

#include <stdio.h>
#include <stdlib.h> // includes standard library

// structure define here
struct record {
    char icode[10];
    char des [20];
    float rate ;
    int qty;
    float cost ;
    
}r;

int main(int argc, const char * argv[]) {
    // insert code here...
    FILE *fp;
    int n,i;
    float vat, schar, tcost, t=0;
    
    // open file in write mode
    
    fp=fopen("RECORD.txt", "w");
    
    // check for error here
    
    if (fp == NULL) {
        printf("\nFile cannot be opened");
        exit(1);
    }
    
    printf("\nEnter number of records ");
    scanf("%d",&n);
    
    for (i=0; i<n; i++) {
        printf("\nEnter itemCode, description, rate and quantity");
        scanf("%s%s%f%d",r.icode,r.des,&r.rate,&r.qty);
        r.cost = r.rate * r.qty;
        fwrite(&r, sizeof(r), 1, fp);
    }
    fclose(fp);
    
    
    // open file in read mode
    fp = fopen("RECORD.txt", "r");
    
    // check for error here
    
    if (fp == NULL) {
        printf("\nFile cannot be opened");
        exit(1);
    }
    
    printf("\n Item Code \t Description \t Rate \t Quantity \t cost");
    while (fread(&r, sizeof(r), 1, fp)==1) {
        t=t+r.cost;
    
    
    printf("\n%s \t\t\t %s \t\t\t %f \t %d \t %f",r.icode,r.des,r.rate,r.qty,r.cost);
}
    
    vat = 0.15*t;
    schar = 0.05*t;
    tcost = t+vat+schar;
    printf("\nVAT = %f",vat);
    printf("\Service Charge = %f",schar);
    printf("\nTotal cost = %f",tcost);
    fclose(fp);
    

    
    return 0;

}

Output :

Enter number of records 2

Enter itemCode, description, rate and quantitya
as
3.3
4

Enter itemCode, description, rate and quantityb
bs
4.4
5

 Item Code  Description  Rate  Quantity  cost
as  3.300000  13.200000
bs  4.400000  22.000000
VAT = 5.280000Service Charge = 1.760000
Total cost = 42.239998Program ended with exit code: 0