Sunday 30 March 2014

how to send videos via bluetooth in nokia lumia 520 or 525

You can send Videos via Bluetooth in Lumia 520. Do the following steps.


1. Connect the phone via usb to pc.

2. In Phone memory or SD Card, create a folder inside *Saved Pictures Named "Videos".

3. Paste your videos inside that folder.

4. Switch on your bluetooth.

5. Go to that folder, tap and hold the video you want to share, Choose share>bluetooth. 


*Saved Pictures might be located inside a folder named "Picture" or "Photos".

C Program for Count chars, spaces, tabs and newlines in a file

/* Count chars, spaces, tabs and newlines in a file */
# include "stdio.h"
main( )
{
FILE  *fp ;
char  ch ;
int  nol = 0, not = 0, nob = 0, noc = 0 ;
fp = fopen ( "PR1.C", "r" ) ;
while ( 1 )
{
ch = fgetc ( fp ) ;
if ( ch == EOF )
break ;
noc++ ;
if ( ch == '  ' )
nob++ ;
if ( ch == '\n' )
nol++ ;
if ( ch == '\t' )
not++ ;
}
fclose ( fp ) ;
printf ( "\nNumber of characters = %d", noc ) ;
printf ( "\nNumber of blanks = %d", nob ) ;
printf ( "\nNumber of tabs = %d", not ) ;
printf ( "\nNumber of lines = %d", nol ) ;
}

Thursday 27 March 2014

Write a Program to convert Decimal to Binary in C#.NET

Program 
using System;
class myclass
{
    static void Main()
    {
        int num;
        Console.Write("Enter a Number : ");
        num = int.Parse(Console.ReadLine());
        int quot;
        string rem = "";
        while (num >= 1)
        {
            quot = num / 2;
            rem += (num % 2).ToString();
            num = quot;
        }
        // Reversing the  value
        string bin = "";
        for (int i = rem.Length - 1; i >= 0; i--)
        {
            bin = bin + rem[i];
        }
        Console.WriteLine("The Binary format for given number is {0}",bin);

        Console.Read();
    }
}


Output

Enter a Number : 100
The Binary format for given number is 1100100

Friday 21 March 2014

Download Anna University Question Paper for C# and .Net Frame Work



C# and .NET FRAMEWORK 

PART-B

UNIT-I

1. Explain the looping constructs in c# with syntax and      example?
2. Discuss on enumeration.
3. Compare the features of c# with java?
4. Write a program to implement the stack data structure and perform the operations push and pop.
5. Describe the characteristics of .NET architecture?
6. Discuss about indexer in detail.
7. List out the various value and reference types supported in c#.
8. What is jagged array? Explain its use with simple example
9. Explain the execution model of the .NET framework.
10. Describe the components of the .NET framework and explain the features of each component.

UNIT-II

1. Describe in detail with architecture of ASP.NET.
2. Describe in detail the steps involved in writing a simple web service.
3. Explain windows forms.
4. Explain polymorphism and demonstrate polymorphic behaviour using an example.
5. Explain creating and using delegates with example.
6. Discuss about inheritance and polymorphism in detail.
7. List out the exception handling statements supported in c# and explain with an example.
8. What is the use of ‘is’ operator in interfaces? Explain.
9. Consider a class distance which stores a distance value sing kilometre and meter. Overload the           +operator to add two distance objects.
10. What is a delegate? Explain with an example?

UNIT III

1. Briefly discuss the common language runtime and its components
2. Explain inserting a row of data into an existing database
3. Describe the properties and methods of any two controls for window forms. Write a simple window application program using these controls
4. Write a program using ADO.NET to connect to the northwind database and read the names of the 5. employees. The employee table has 2 field namely first name and last name
5. Implement the following in datasets.
i)Adding a row
ii)Adding a new data column
iii)Deleting a row
iv)Updating a row
6. List out the categories of controls supported in window based application and explain the importance of each.
7. Explain the process of creating a window based calculator with your own UI
8. Compare ASP with ASP.NET.
9. Write a database application to display the details of student table details in a data grid control

UNIT IV

1. Explain the concept of interfaces using an example
2. Explain how to create, discover and deploy web services in the .NET environment
3. Describe in detail the lifecycle of web form
4. Explain any one data bound control in a program
5. Explain the creation of calculator web-service. Test this using client program
6. Compare ASP with ASP.NET
7. Write a database application to implement a ticket status checking system
8. Explain the web service architecture. What are the steps involved in the creation and consumption of web services. Explain with an example
 UNIT V

1. Write a note on marshaling and reflection with example?
2. Explain building a server with example?
3. Describe about assembler in detail?
4. What is reflection? Explain with example?
5. Write a remoting application which returns the maximum and minimum
6. Temperature of a given city?
7. Explain the feature of CLR?


8. What is remoting? Explain the steps involved in the process of create a Remoting Application?

C Program for Demonstration of nested loops


/* Demonstration of nested loops */
main( )
{
int   r, c, sum ;
for ( r = 1 ; r <= 3 ; r++ )  /* outer loop */
{
for ( c = 1 ; c <= 2 ; c++ )  /* inner loop */
{
sum = r + c ;
printf ( "r = %d c = %d sum = %d\n", r, c, sum ) ;
}
}
}

Wednesday 19 March 2014

C Program for Comparison of two pointer variables

/* Comparison of two pointer variables */
main( )
{
int  arr[ ] = { 10, 20, 36, 72, 45, 36 } ;
int  *j, *k ;
j = &arr [ 4 ] ;
k = ( arr + 4 ) ;
if ( j == k )
printf ( "The two pointers point to the same location" ) ;
else
printf ( "The two pointers do not point to the same location" ) ;
}

C Program to interchange string3 with string4

/* Program to interchange string3 with string4 */
main( )
{
char  *names[ ] = {
"akshay",
"parag",
"raman",
"srinivas",
"gopal",
"rajesh"
                                    } ;
char  *temp ;
printf ( "Original: %s %s", names[2], names[3] ) ;
temp = names[2] ;
names[2] = names[3] ;
names[3] = temp ;
printf ( "\nNew: %s %s", names[2], names[3] ) ;
}

C Program for Use of strcmp() function

/* Use of strcmp() function */
main( )
{
char  string1[ ] = "Jerry" ;
char  string2[ ] = "Ferry" ;
int  i, j, k ;
i = strcmp ( string1, "Jerry" ) ;
j = strcmp ( string1, string2 ) ;
k = strcmp ( string1, "Jerry boy" ) ;
printf ( "\n%d %d %d", i, j, k ) ;
}

C Program for Demo of union at work

/* Demo of union at work */
main( )
{
union a
{
int  i ;
char  ch[2] ;
} ;
union a  key ;
key.i = 512 ;
printf ( "\nkey.i = %d", key.i ) ;
printf ( "\nkey.ch[0] = %d", key.ch[0] ) ;
printf ( "\nkey.ch[1] = %d", key.ch[1] ) ;
}

C Program for Two dimensional array

/* Two dimensional array */
main( )
{
int  stud[4][2] ;
int  i, j ;
for ( i = 0 ; i <= 3 ; i++ )
{
printf ( "\n Enter roll no. and marks" ) ;
scanf ( "%d %d", &stud[i][0], &stud[i][1] ) ;
}
for ( i = 0 ; i <= 3 ; i++ )
printf ( "\n%d %d", stud[i][0], stud[i][1] ) ;
}

C Program for Reads records from binary file and displays them on VDU


/* Reads records from binary file and displays them on VDU */
#include "stdio.h"
main( )
{
FILE  *fp ;
struct emp
{
char  name[40] ;
int  age ;
float  bs ; } ;
struct emp  e ;
fp = fopen ( "EMP.DAT", "rb" ) ;
if ( fp == NULL )
{
puts ( "Cannot open file" ) ;
exit( ) ;
}
while ( fread ( &e, sizeof ( e ), 1, fp ) == 1 )
printf ( "\n%s %d %f", e.name, e.age, e.bs ) ;
fclose ( fp ) ;
}

C Program for Demonstration of passing an entire array to a function

/* Demonstration of passing an entire array to a function */
main( )
{
int  num[ ] = { 24, 34, 12, 44, 56, 17 } ;
dislpay ( &num[0], 6 ) ;
}
display ( int  *j, int  n )
{
int  i ;
for ( i = 0 ; i <= n - 1 ; i++ )
{
printf ( "\nelement = %d", *j ) ;
j++ ;  /* increment pointer to point to next element */
}
}

C Program for Use of const keyword

/* Use of const keyword */
main( )
{
float r, a ;
const float pi = 3.14 ;
printf ( "\nEnter radius of circle " ) ;
scanf  ( "%f", &r ) ;
a = pi * r * r ;
printf ( "\nArea of circle = %f", a ) ;
}

C Program for Passing address of a structure variable

/* Passing address of a structure variable */
struct book
{
char  name[25] ;
char  author[25] ;
int  callno ;
} ;
main( )
{
struct book  b1 = { "Let us C", "YPK", 101 } ;
display ( &b1 ) ;
}
display ( struct book  *b )
{
printf ( "\n%s %s %d", b->name, b->author, b->callno ) ;
}

C Program for Use of #pragma

/* Use of #pragma */
/* Program to change execution of functions */
void fun1( ) ;
void fun2( ) ;
#pragma startup fun1
#pragma exit fun2
main( )
{
printf ( "\nInside maim" ) ;
}
void fun1( )
{
printf ( "\nInside fun1" ) ;
}
void fun2( )
{
printf ( "\nInside fun2" ) ;
}

C Program for Use of stringcopy function

/* Use of stringcopy function */
main( )
{
char  source[ ] = "Sayonara" ;
char  target[20] ;
strcpy ( target, source ) ;
printf ( "\nsource string = %s", source ) ;
printf ( "\ntarget string = %s", target ) ;
}

C Program for Insurance of driver - without using logical operators

/* Insurance of driver - without using logical operators */
main( )
{
char   sex, ms ;
int   age ;
printf ( "Enter age, sex, marital status " ) ;
scanf ( "%d %c %c", &age, &sex, &ms ) ;
if ( ms == 'M' )
printf ( "Driver is insured" ) ;
else
{
if ( sex == 'M' )
{
if ( age > 30 )
printf ( "Driver is insured" ) ;
else
printf ( "Driver is not insured" ) ;
}
else
{
if ( age > 25 )
printf ( "Driver is insured" ) ;
else
printf ( "Driver is not insured" ) ;
}
}
}

C Program for Invoking a function using a pointer to a function

/* Invoking a function using a pointer to a function */
main( )
{
int  display( ) ;
int  ( *func_ptr )( ) ;
func_ptr = display ;  /* assign address of function */
printf ( "\nAddress of function display is %u", func_ptr ) ;
( *func_ptr )( ) ;  /* invokes the function display( ) */
}
int  display( )
{
puts ( "\nLong live viruses!!" ) ;
}

C Program for Use of break keyword in while loop

/* Use of break keyword in while loop */
main( )
{
int  i = 1 , j = 1 ;
while ( i++ <= 100 )
{
while ( j++ <= 200 )
{
if ( j == 150 )
break ;
else
printf ( "%d %d\n", i, j ) ;
}
}
}

C Prgram for Writes records to a file using structure

/* Writes records to a file using structure */
#include <stdio.h>
main( )
{
FILE  *fp ;
char  another = 'Y' ;
struct emp
{
char  name[40] ;
int  age ;
float  bs ;
} ;
struct emp  e ;
fp = fopen ( "EMPLOYEE.DAT", "w" ) ;
if ( fp == NULL ) {
puts ( "Cannot open file" ) ;
exit( ) ;
}
while ( another == 'Y' )
{
printf ( "\nEnter name, age and basic salary: " ) ;
scanf ( "%s %d %f", e.name, &e.age, &e.bs ) ;
fprintf ( fp, "%s %d %f\n", e.name, e.age, e.bs ) ;
printf ( "Add another record (Y/N) " ) ;
fflush ( stdin ) ;
another = getche( ) ;
}
fclose ( fp ) ;
}

C Program for A look-alike of the function strlen( )

/* A look-alike of the function strlen( ) */
main( )
{
char  arr[ ] = "Bamboozled" ;
int  len1, len2 ;
len1 = xstrlen ( arr ) ;
len2 = xstrlen ( "Humpty Dumpty" ) ;
printf ( "\nstring = %s length = %d", arr, len1 ) ;
printf ( "\nstring = %s length = %d", "Humpty Dumpty", len2 ) ;
}
xstrlen ( char  *s )
{
int  length = 0 ;
while ( *s != '\0' )
{
length++ ;
s++ ;
}
return ( length ) ;

C Program for Passing individual structure elements

/* Passing individual structure elements */
main( )
{
struct book
{
char  name[25] ;
char  author[25] ;
int  callno ;
} ;
struct book b1 = { "Let us C", "YPK", 101 } ;

display ( b1.name, b1.author, b1.callno ) ;
}

display ( char  *s, char  *t, int  n )
{
printf ( "\n%s %s %d", s, t, n ) ;
}

C Program for Comparison of two pointer variables

/* Comparison of two pointer variables */
main( )
{
int  arr[ ] = { 10, 20, 36, 72, 45, 36 } ;
int  *j, *k ;
j = &arr [ 4 ] ;
k = ( arr + 4 ) ;
if ( j == k )
printf ( "The two pointers point to the same location" ) ;
else
printf ( "The two pointers do not point to the same location" ) ;
}

C Program for Macros with arguments

/* Macros with arguments */
/* Program to test whether entered character is digit */
#define ISDIGIT(y) ( y >= 48 && y <= 57 )
main( )
{
char  ch ;
printf ( "Enter any digit " ) ;
scanf ( "%c", &ch ) ;
if ( ISDIGIT ( ch ) )
printf ( "\nYou entered a digit" ) ;
else
printf ( "\nIllegal input" ) ;

C Program for Program to calculate prime number

/* Program to calculate prime number */
main( )
{
int   num, i ;
printf ( "Enter a number " ) ;
scanf ( "%d", &num ) ;
i = 2 ;
while ( i <= num - 1 )
{
if ( num % i == 0 )
{
printf ( "Not a prime number" ) ;
break ;
}
i++ ;
}
if ( i == num )
printf ( "Prime number" ) ;
}

C Program for Program to find length of string using strlen() function

/* Program to find length of string using strlen() function */
main( )
{
char  arr[ ] = "Bamboozled" ;
int  len1, len2 ;
len1 = strlen ( arr ) ;
len2 = strlen ( "Humpty Dumpty" ) ;
printf ( "\nstring = %s length = %d", arr, len1 ) ;
printf ( "\nstring = %s length = %d", "Humpty Dumpty", len2 ) ;
}

Program for To test whether a bit in a number is ON or OFF

/* To test whether a bit in a number is ON or OFF */
main( )
{
int  i = 65, j ;
printf ( "\nvalue of i = %d", i ) ;
j = i & 32 ;
if ( j == 0 )
printf ( "\nand its fifth bit is off" ) ;
else
printf ( "\nand its fifth bit is on" ) ;
j = i & 64 ;
if ( j == 0 )
printf ( "\nwhereas its sixth bit is off" ) ;
else
printf ( "\nwhereas its sixth bit is on" ) ;

C Program for Macros with arguments

/* Macros with arguments */
#define AREA(x) ( 3.14 * x * x )
main( )
{
float  r1 = 6.25, r2 = 2.5, a ;
a = AREA ( r1 ) ;
printf ( "\nArea of circle = %f", a ) ;
a = AREA ( r2 ) ;
printf ( "\nArea of circle = %f", a ) ;
}

C Program for Subtraction of one pointer from another

/* Subtraction of one pointer from another */
main( )
{
int  arr[ ] = { 10, 20, 30, 45, 67, 56, 74 } ;
int  *i, *j ;
i = &arr[1] ;
j = &arr[5] ;
printf ( "%d %d", j - i, *j - *i ) ;
}

C Program for Decoding date field in directory entry using bitwise operators


/* Decoding date field in directory entry using bitwise operators */
main( )
{
unsigned int  d = 9, m = 3, y = 1990, year, month, day, date ;
date = ( y - 1980 ) * 512 + m * 32 + d ;
printf ( "\nDate = %u", date ) ;
year = 1980 + ( date >> 9 ) ;
month = ( (date << 7 ) >> 12 ) ;
day = ( (date << 11 ) >> 11 ) ;
printf ( "\nYear = %u ", year ) ;
printf ( "Month = %u ", month ) ;
printf ( "Day = %u", day ) ;
}

C Program for Formatting strings with printf( )

/* Formatting strings with printf( ) */
main( )
{
char  firstname1[ ] = "Sandy" ;
char  surname1[ ] = "Malya" ;
char  firstname2[ ] = "AjayKumar" ;
char  surname2[ ] = "Gurubaxani" ;
printf ( "\n%20s%20s", firstname1, surname1 ) ;
printf ( "\n%20s%20s", firstname2, surname2 ) ;
}

C Program for Receives strings from keyboard and writes them to file

/* Receives strings from keyboard and writes them to file */
#include <stdio.h>
main( )
{
FILE  *fp ;
char  s[80] ;
fp = fopen ( "POEM.TXT", "w" ) ;
if ( fp == NULL )
{
puts ( "Cannot open file" ) ;
exit( ) ;
}
printf ( "\nEnter a few lines of text:\n" ) ;
while ( strlen ( gets ( s ) ) > 0 )
{
fputs ( s, fp ) ;
fputs ( "\n", fp ) ;
}
fclose ( fp ) ;
}

C Program for Introducing pointers

/* Introducing pointers */
main( )
{
int  i = 3, *x ;
float  j = 1.5, *y ;
char  k = 'c', *z ;
printf ( "\nValue of i = %d", i ) ;
printf ( "\nValue of j = %f", j ) ;
printf ( "\nValue of k = %c", k ) ;
x = &i ;
y = &j ;
z = &k ;
printf ( "\nOriginal address in x = %u", x ) ;
printf ( "\nOriginal address in y = %u", y ) ;
printf ( "\nOriginal address in z = %u", z ) ;
x++ ;
y++ ;
z++ ;
printf ( "\nNew address in x = %u", x ) ;
printf ( "\nNew address in y = %u", y ) ;
printf ( "\nNew address in z = %u", z ) ;
}

C Program for Input of strings containing spaces

/* Input of strings containing spaces */
main( )
{
char  name[25] ;
printf ( "Enter your full name " ) ;
gets ( name ) ;
puts ( "Hello!" ) ;
puts ( name ) ;
}

C Program for # define statement used to replace entire C statement

/* # define statement used to replace entire C statement */
#define FOUND printf ( "The Yankee Doodle Virus" ) ;
main( )
{
char  signature ;
if ( signature == 'Y' )
FOUND
else
printf ( "Safe... as yet !" ) ;
}

C Program for A quick demo of nested if-else

/* A quick demo of nested if-else */
main( )
{
int   i ;
printf ( "Enter either 1 or 2 " ) ;
scanf ( "%d", &i ) ;
if ( i == 1 )
printf ( "You would go to heaven !" ) ;
else
{
if ( i == 2 )
printf ( "Hell was created with you in mind" ) ;
else
printf ( "How about mother earth !" ) ;
}
}

C Program for odd loop using a for loop

/* odd loop using a for loop */
main( )
{
char  another = 'y' ;
int  num ;
for ( ; another == 'y' ; )
{
printf ( "Enter a number " ) ;
scanf ( "%d", &num ) ;
printf ( "square of %d is %d", num, num * num ) ;
printf ( "\nWant to enter another number y/n " ) ;
scanf ( " %c", &another ) ;
}
}

C Program Usage of an array of structures


/* Usage of an array of structures */
main( )
{
struct book
{
char  name ;
float  price ;
int  pages ;
} ;
struct book  b[100] ;
int  i ;
for ( i = 0 ; i <= 99 ; i++ )
{
printf ( "\nEnter name, price and pages " ) ;
scanf ( "%c %f %d", &b[i].name, &b[i].price, &b[i].pages ) ;
}
for ( i = 0 ; i <= 99 ; i++ )
printf ( "\n%c %f %d", b[i].name, b[i].price, b[i].pages ) ;
}
linkfloat( )
{
      float a = 0, *b ;
b = &a ;  /* cause emulator to be linked */
      a = *b ;    /* suppress the warning - variable not used */
}

C Program for Program to pass an array to a function by address

/* Program to pass an array to a function by address */doc
main( )
{
int  i ;
int  marks[ ] = { 55, 65, 75, 56, 78, 78, 90 } ;
for ( i = 0 ; i <= 6 ; i++ )
disp ( &marks[i] ) ;
}
disp ( int  *n )
{
show ( &n ) ;
}
show ( int  *m )
{
printf("%d  ",*m)
}

C Program for Program to input & print a string

/* Program to input & print a string */
main( )
{
char  name[25] ;
printf ( "Enter your name " ) ;
scanf ( "%s", name ) ;
printf ( "Hello %s!", name ) ;
}

C Program for Count chars, spaces, tabs and newlines in a file

/* Count chars, spaces, tabs and newlines in a file */
# include "stdio.h"
main( )
{
FILE  *fp ;
char  ch ;
int  nol = 0, not = 0, nob = 0, noc = 0 ;
fp = fopen ( "PR1.C", "r" ) ;
while ( 1 )
{
ch = fgetc ( fp ) ;
if ( ch == EOF )
break ;
noc++ ;
if ( ch == '  ' )
nob++ ;
if ( ch == '\n' )
nol++ ;
if ( ch == '\t' )
not++ ;
}
fclose ( fp ) ;
printf ( "\nNumber of characters = %d", noc ) ;
printf ( "\nNumber of blanks = %d", nob ) ;
printf ( "\nNumber of tabs = %d", not ) ;
printf ( "\nNumber of lines = %d", nol ) ;
}

C Program Execution of a loop an unknown number of times

/* Execution of a loop an unknown number of times */
main( )
{
char  another ;
int  num ;
do
{
printf ( "Enter a number " ) ;
scanf ( "%d", &num ) ;
printf ( "square of %d is %d", num, num * num ) ;
printf ( "\nWant to enter another number y/n " ) ;
scanf ( " %c", &another ) ;
} while ( another == 'y' ) ;
}

C Program Nested macros

/* Nested macros */
#define AND &&
#define ARANGE ( a > 25 AND a < 50 )
main( )
{
int  a = 30 ;
if ( ARANGE )
printf ( "within range" ) ;
else
printf ( "out of range" ) ;
}

C Program for Prints file contents on printer

/* Prints file contents on printer */
#include "stdio.h"
main( )
{
FILE  *fp ;
char  ch ;

fp = fopen ( "poem.txt", "r" ) ;

if ( fp == NULL )
{
printf ( "Cannot open file" ) ;
exit( ) ;
}

while ( ( ch = fgetc ( fp ) ) != EOF )
fputc ( ch, stdprn ) ;

fclose ( fp ) ;
}

C Program for Calculation of gross salary

/* Calculation of gross salary */
main( )
{
float   bs, gs, da, hra ;
printf ( "Enter basic salary " ) ;
scanf ( "%f", &bs ) ;
if ( bs < 1500 )
{
hra = bs * 10 / 100 ;
da = bs * 90 / 100 ;
}
else
{
hra = 500 ;
da = bs * 98 / 100 ;
}
gs = bs + hra + da ;
printf ( "gross salary = Rs. %f", gs ) ;

C Program for Count chars, spaces, tabs and newlines in a file

/* Count chars, spaces, tabs and newlines in a file */
# include "stdio.h"
main( )
{
FILE  *fp ;
char  ch ;
int  nol = 0, not = 0, nob = 0, noc = 0 ;
fp = fopen ( "PR1.C", "r" ) ;
while ( 1 )
{
ch = fgetc ( fp ) ;
if ( ch == EOF )
break ;
noc++ ;
if ( ch == '  ' )
nob++ ;
if ( ch == '\n' )
nol++ ;
if ( ch == '\t' )
not++ ;
}
fclose ( fp ) ;
printf ( "\nNumber of characters = %d", noc ) ;
printf ( "\nNumber of blanks = %d", nob ) ;
printf ( "\nNumber of tabs = %d", not ) ;
printf ( "\nNumber of lines = %d", nol ) ;
}

C Program for Using pointer to access array elements

/* Using pointer to access array elements */
main( )
{
char  name[ ] = "Klinsman" ;
char  *ptr ;
ptr = name ;  /* store base address of string */
while ( *ptr != `\0' )
{
printf ( "%c", *ptr ) ;
ptr++ ;
}
}

C Program for Memory map of structure elements


/* Memory map of structure elements */
main( )
{
struct book
{ char  name ;
float  price ;
int  pages ;
} ;
struct book  b1 = { 'B', 130.00, 550 } ;
printf ( "\nAddress of name = %u", &b1.name ) ;
printf ( "\nAddress of price = %u", &b1.price ) ;
printf ( "\nAddress of pages = %u", &b1.pages ) ;
}

C Program for Demonstration of call by reference

/* Demonstration of call by reference */
main( )
{
int  i ;
int  marks[ ] = { 55, 65, 75, 56, 78, 78, 90 } ;
for ( i = 0 ; i <= 6 ; i++ )
disp ( &marks[i] ) ;
}
disp ( int  *n )
{
printf ( "%d ", *n ) ;
}

C Program for Macro expansion

/* Macro expansion */
#define AND &&
#define OR  ||
main( )
{
int  f = 1, x = 4, y = 90 ;
if ( ( f < 5 ) AND ( x <= 20 OR y <= 45 ) )
printf ( "\nYour PC will always work fine..." ) ;
else
printf ( "\nIn front of the maintenance man" ) ;
}

Saturday 15 March 2014

C Program Calculation of bonus

/* Calculation of bonus */
main( )
{
int   bonus, cy, yoj, yr_of_ser ;
printf ( "Enter current year and year of joining " ) ;
scanf ( "%d %d", &cy, &yoj ) ;
yr_of_ser = cy - yoj ;
if ( yr_of_ser > 3 )
{
bonus = 2500 ;
printf ( "Bonus = Rs. %d", bonus ) ;
}
}

C Program for File encryption utility

/* File encryption utility */
#include "stdio.h"
main( )
{
encrypt( ) ;
}
encrypt( )
{
FILE  *fs, *ft ;
char   ch ;
fs = fopen ( "SOURCE.C", "r" ) ;  /* normal file */
ft = fopen ( "TARGET.C”, "w" ) ;  /* encrypted file */
if ( fs == NULL || ft == NULL )
{
printf ( "\nFile opening error!" ) ;
exit ( 1 ) ;
}
while ( ( ch = getc ( fs ) ) != EOF )
  putc ( ~ch, ft ) ;
fclose ( fs ) ;
fclose ( ft ) ;
}

C Program Demonstration of call by value

/* Demonstration of call by value */
main( )
{
int  i ;
int  marks[ ] = { 55, 65, 75, 56, 78, 78, 90 } ;
for ( i = 0 ; i <= 6 ; i++ )
display ( marks[i] ) ;
}
display ( int  m )
{
printf ( "%d ", m ) ;
}

C Program Calculation of total expenses

/* Calculation of total expenses */
main( )
{
int   qty, dis = 0 ;
float   rate, tot ;
printf ( "Enter quantity and rate " ) ;
scanf ( "%d %f", &qty, &rate) ;
if ( qty > 1000 )
dis = 10 ;
tot = ( qty * rate ) - ( qty * rate * dis / 100 ) ;
printf ( "Total expenses = Rs. %f", tot ) ;
}

C Program Display contents of a file on screen.I

#include <stdio.h>
main ( int  argc, char  *argv[ ] )
{
FILE  *fs, *ft ;
char  ch ;
if ( argc != 3 )
{
puts ( "Improper number of arguments" ) ;
exit( ) ;
}
fs = fopen ( argv[1], "r" ) ;
if ( fs == NULL )
{
puts ( "Cannot open source file" ) ;
exit( ) ;
}
ft = fopen ( argv[2], "w" ) ;
if ( ft == NULL )
{
puts ( "Cannot open target file" ) ;
fclose ( fs ) ;
exit( ) ;
}
while ( 1 )
{
ch = fgetc ( fs ) ;
if ( ch == EOF )
break ;
else
fputc ( ch, ft ) ;
}
fclose ( fs ) ;
fclose ( ft ) ;
}

C Program Display contents of a file on screen.

/* Display contents of a file on screen. */
# include "stdio.h"
main( )
{
FILE  *fp ;
char  ch ;
fp = fopen ( "PR1.C", "r" ) ;
while ( 1 )
{
ch = fgetc ( fp ) ;
if ( ch == EOF )
break ;
printf ( "%c", ch ) ;
}
fclose ( fp ) ;
}

Friday 14 March 2014

C Program to calculate average marks of 30 students using array

/* Use of array */
/* Program to calculate average marks of 30 students */
main( )
{
int  avg, sum = 0 ;
int  i ;
int  marks[30] ;  /* array declaration */
for ( i = 0 ; i <= 29 ; i++ )
{
printf ( "\nEnter marks " ) ;
scanf ( "%d", &marks[i] ) ;  /* store data in array */
}
for ( i = 0 ; i <= 29 ; i++ )
sum = sum + marks[i] ;  /* read data from an array*/
avg = sum / 30 ;
printf ( "\nAverage marks = %d", avg ) ;
}

C Program to demonstrate printing of a string

/* Program to demonstrate printing of a string */
main( )
{
char  name[ ] = "Klinsman" ;
int  i = 0 ;
while ( i <= 7 )
{
printf ( "%c", name[i] ) ;
i++ ;
}
}

C Program Use of macro expansion

/* Use of macro expansion */
#define UPPER 25
main( )
{
int  i ;
for ( i = 1 ; i <= UPPER ; i++ )
printf ( "\n%d", i ) ;
}

C Program Demonstration of if statement

/* Demonstration of if statement */
main( )
{
int   num ;
printf ( "Enter a number less than 10 " ) ;
scanf ( "%d", &num ) ;
if ( num <= 10 )
printf ( "What an obedient servant you are !" ) ;
}

C program Calculation of simple interest

/* Calculation of simple interest */
/* Author gekay  Date: 25/05/2004 */
main( )
{
int   p, n ;
float   r, si ;
p = 1000 ;
n = 3 ;
r = 8.5 ;
/* formula for simple interest */
si = p * n * r / 100 ;
printf ( "%f" , si ) ;