Wednesday, 30 November 2011

largest of 3 numbers

//largest of 3 nos'
#include<stdio.h>
#include<conio.h>
int max(int a,int b,int c)
{
 int larg;
 larg=a;
 if(b>larg)
  larg=b;
 if(c>larg)
  larg=c;
  return(larg);
}
int main()
{
 int max(int a,int b,int c);
 int x,y,z;
 printf("enter any 3 nos\n");
 scanf("%d%d%d",&x,&y,&z);
 printf("largest no=%d\n",max(x,y,z));
 getch();
 return 0;
}

Wednesday, 23 November 2011

IT & C previous question papers for POLYTECHNIC DIPLOMA


C-09-CM-401
474
BOARD DIPLOMA EXAMINATION, (C-05)
OCTOBER/NOVEMBER-2011
DEEE IV SEMESTER EXAMINATION
INFORMATION TECHNOLOGY & C LANGUAGE
Time : 3 Hours]                                                               [Total Marks: 80
PART-A    3*10=30
Instructions: (1) Answer all questions and each question caries three marks. (2) Answers should be brief and straight to t the point and shall not exceed five simple sentences.
1.     How to protect a word document?
2.     Define the following terms: (a) database (b) table (c) record (d) field
3.     What is a keyword? List any four keywords.
4.     What are the important features of C language?
5.     Write a c program to find whether the given year is leap or not.
6.     Write any four differences between for and do-while loop.
7.     What is the difference between a simple variable and array?
8.     Write the differences between address operator and dereferencing operator.
9.     Define Union. Explain with an example.
10. Write a c program to find maximum of three numbers using functions.

PART-B                                              10*5=50
Instructions: (1) Answer any five questions and each question caries ten marks. (2) The Answers should be comprehensive and criteria for valuation is the Content but not the length of the answer.

11. (a) explain the mail merge feature in word processing package. (b) what is a formula and write the steps to enter and edit the formula in excel worksheet?
12. (a) list the different views in ms power point. (b) create a table using design view in ms-access.
13. Explain the structure of c program.
14. (a) explain the switch statement in c with an example. (b) write a program to check whether the given number is polidrome or not.
15. (a) write a c program to print the following output.
1
         2 2
         3 3 3
         4 4 4 4
         5 5 5 5 5
     (b) write a c program to print fibonnacci series using recursion.
16.  (a) writ ea c program to find the sum of two matrices. (b) explain the following string functions. (i) strlen() (ii)stremp() (iii)strupr()
17.  Write a program in c to sort 10 numbers using bubble sort.
18. (a) what is a structure ? explain briefly with an example. (b) what are the various storage classes in c ? explain.

1231

Tuesday, 1 November 2011

storage classes


In C language each variable has a Storage class specifiers inform the compiler how to store the variable;
Storage Class which decides scope, visibility and lifetime of that variable.
1.    Automatic variables
2.    External variables
3.    Static variables
4.    Register variables


auto:
auto means Automatic Variable.
A variable which is declared in side the function is called automatic variable or local variable. Compiler assigns garbage value by default.
Scope of the variable is within the function. It can not be accessed out side of the function 

void main()
{
 auto int a;
 //or  int a; //both are same
}

External or Global variableA variable that is declared outside any function is a Global variable. Global variables remain available throughout the entire program. One important thing to remember about global variable is that their values can be changed by any function in the program.
int number;
void main()
{
 number=10;
}
fun1()
{
 number=20;
}
fun2()
{
 number=30;
}
Here the global variable number is available to all three functions.

extern:

The extern keyword is used before a variable to inform the compiler that this variable is declared somewhere else. The extern declaration does not allocate storage for variables.


//extern keyword
#include<stdio.h>
#include<conio.h>
extern int b=12;
void main()
{
 int b=4;//
 // extern int c;
 void ex();
 clrscr();
 printf("%d\n",b);
 ex();
 getch();
}
void ex()
{
 int b=50;
 int c;
 printf("%d",c);
 printf("%d\n",b);
}


static:

Static is initialized only once and remains into existence till the end of program. A static variable can either be internal or external depending upon the place of declaration. Scope of internal static variable remains inside the function in which it is defined. External static variables remain restricted to scope of file in each they are declared.
Example
main()
{
void ex();   //Function declaration
ex();
ex();
ex();
}
void ex()
{
 static int a = 0;        //Static variable
 a++;
 printf("%d\t",a);
}
output :
1    2    3


//static
#include<stdio.h>
#include<conio.h>
void main()
{
 int i;
 void fun();
 clrscr();
 for(i=0;i<=3;i++)
 {
   fun();
 }
 getch();
}
//fun() definition
void fun()
{
 static int a=0;
// int a=0;
 printf("%d\n",a);
 a++;
}

register:

Register variable inform the compiler to store the variable in register instead of memory. Register variable has faster access than normal variable. Frequently used variables are kept in register. Only few variables can be placed inside register.

NOTE : It is not possible to get the address of register variable