Sei sulla pagina 1di 14

PART-A

1. List some important hardware and software technologies of fifth generation computers.
Super Large Scale Integrated Chips(SLSI)
Parallel Technologies
Dual Core Processor
Artificial Intelligence, Natural Language Processing.
2. Write two characteristics of pseudocode.
Composed of a sequence of statements or steps
Statements are often numbered sequentially.
Statements are written in simple English
Each statement is written on a separate line
Keywords and indentation are used to signify control structures or blocks of repetition
There is no fixed syntax.
Clarity of expression is essence of pseudocode.
3. What are various types of C operators.
Arithmetic Operator
Relational Operator
Logical Operator
Bitwise Operator
Assignment Operator
4. Write a for loop statement to print numbers from 10 to 1.
for(count = 10; count >0; count--)
printf("%d ", count);
5. Define array
Array is a datastructure that is used for storage of homogeneous data , i.e. the data of same type.
6. Name any two library functions used for string handling functions.
strlen
strcmp
strcpy
strrev
strcat
strstr
7. What is the need for functions?

8.

Reduction in code redundancy


Enabling code reuse
Better readability
Information Hiding
What is the use of pointers?
Pointers increase the execution speed
A pointers enable us to access a variable that is defined outside the function
Pointers are more efficient in handling the data tables
Pointers reduce the length and complexity of a program

9. Write any two preprocessor directives in C.


# include<stdio.h>
#include<conio.h>
#include<string.h>
10. Differentiate between structures and union.
Structure

Union

'struct' keyword is used to declare structure.


Memory is allocated for all variables.
struct struct_name
{
structure element 1;
structure element 2;
------------------structure element n;
}struct_var_nm;
struct item_mst
{
int rno;
char nm[50];
}it;

'union' keyword is used to declare union.


Allocates memory for variable which
variable require more memory.
union union_name
{
union element 1;
union element 2;
------------------union element n;
}union_var_nm;
union item_mst
{
int rno;
char nm[50];
}it;

PART-B
11.a)write in detail about the evolution and the various generations of computer. (16).
Evolution of computers
ABACUS:
NAPIER BONES and SLIDE RULE:
PASCALINE-1642:
STEPPED RECKONER-1694:
DIFFERENCE ENGINE-1822:
1889: ->Jacquared loom concept to computing.
1944: ->Invention of Mark-I, built in partnership between Harvard Aiken and IBM.
1946: ->developed ENIAC-Electronic Numerical Integrator and Calculator.
1949: ->EDSAC-Electronic Delay Storage Automatic Calculator.
1951: ->UNIVAC- Universal Automatic Computer.
1960->LARC was invented.
1970: ->Invention of microprocessors, processors on IC chip.

1980: ->VLSI-Very Large Scale Integration.


Then, invention of PCs microprocessors equipped with ROM.
First generation (1940-56) (vacuum tubes)
vacuum tubes/thermionic valve based machines.
vacuum tubes for circuitry and magnetic drums for memory.
Input-> punched cards and paper tape.
Output-> printouts.
Language->machine language
Lack of versatility
Characteristics:
Lot of space for installation
Non portable
Large expensive
Frequent hardware failure
Assembled manually
Second generation (1956-63)(transistors)
The second generation computer used transistors,.
Used semiconductor material->germanium and silicon.
Primary memory->magnetic cores
Secondary memory->magnetic disks
Input->punched card.
Output->printouts
Assembly language->mnemonic code.
Ex: ADD for addition. MULT for multiplication
Ex: PDP-8, IBM 1401, IBM 7090.
Characteristics:
The computation time is milliseconds.
more reliable and less hardware failure.
portable and generated less amount of heat.
Assembly language was used to program computers
It is also need air conditioning.
Manual assembly of individual components
Third generation (1964-1970s) (Integrated Circuits)
integrated circuit(IC).
It consists of single chip with many components ->transistors and resistors fabricated on it.

This development made computers smaller in size, reliable and efficient.


Input->keyboards

Output->monitor

Interface->Operating system

This allowed the device to run many different applications at one time.
Ex: NCR 395, B6500
Characteristics:

These computers based on integrated circuit technology.


The computational time is nanoseconds.
portable and more reliable than the second generation.
These devices consumed less power and generated less heat. In some cases, air conditioning was still
required.
The size of these computers was smaller
Since hardware rarely failed, the maintenance cost was quite low.
Extensive use of high-level language became possible.
Manual assembling of individual components was not required,
Commercial production became easier and cheaper.

Fourth generation (1970s- Till date) (microprocessors)


Large Scale Integration (LSI) and Very Large Scale Integration (VLSI) technology , Ultra- Large Scale
Integration (ULSI) used in this generation.
This computers become smaller and cheaper the ever before.
Fourth generation computers became more powerful, compact, reliable and affordable.
The significant of this computer it could be linked together to form network.
Ex: Apple II, Altair 8800, CRAY-1.
Characteristics:

These computers are microprocessor based system.


computers are very small.
cheapest among all the other generation.
portable and quite reliable.
These machines generate negligible amount of heat,
Hardware failure is negligible.
The production cost is very low.
GUI and pointing devices enable users to learn to use the computer quickly.
Interconnection of computer leads to better communication and resource sharing.

Fifth generation (present and beyond) (Artificial Intelligence)


expert system concept is already in use.
Three characteristics can be identified with the fifth generation,
Mega chips:
Parallel processing:
Artificial Intelligence:

11.b)Explain the basic computer organization using a neat diagram. (16)


A computer is an information processing machine - converts data into information.
hardware of the computer.
data is entered - input devices.
data is processed - central processing unit
processed data displayed to the user - output devices.
Central Processing Unit

Registers

Input Unit

Output Unit

Control
Unit

Arithmetic /
logic Unit

Data flow
Instruction flow

Input Devices:
Input devices -electro mechanical devices - feed information into the computer for analysis, storage and
to give commands to the central processing unit (CPU).
Computer can accept input in two ways.
-> Manual Ex. Keyboard and Mouse.
-> Direct - fed into the computer automatically from a source document
Input device are, KeyboardMouseJoystickScanners.
Central Processing Unit:
The central processing unit -brain of a computer. - converts data into meaningful information.controls all internal and external devices,- - controls the usage of main memory to store data and
instruction ,and control the sequence of operations
three main subsystems,
Arithmetic/logic unit (ALU) --Control Unit (CU)--Registers.
Arithmetic/logic unit (ALU)
-executes all the arithmetic and logical operations on the data.
-contains two units, Arithmetic unit - Logic Unit
Arithmetic Unit
-performs actual computing - arithmetic calculation

Logic Unit:
- perform logical operations based on the instructions provide it.
- Logical operations of logic unit can test for three conditions.
->equal to condition -> Less than condition -> Greater than condition
Control Unit:
- checks the correctness of sequence of operations.-- controls the input/output devices - directs the overall
functioning of the other units of the computer.
Registers:
- special purpose, high speed temporary memory units -- hold various types of information such as data,
instructions, addresses, and the intermediate results of calculation.-- holds the information that the CPU is
currently working on.
Output devices:
Computer communicate with human beings using output devices.
The physical form of output is known as hard copy.
The electronic version of an output- known as soft copy.
Output devices: Monitor.-Printer.-Plotters.-Audio response.
Memory:
Computer requires memory to process data and store output. Memory refers to the electronic holding
place for instruction and data.
Classify the memory into two categories,
Primary memory-> to handle the data- known as main memory, store data and instructions for processingclassified into Random Access Memory (RAM) and Read Only Memory (ROM).
Secondary memory-> to store the output. - known as auxiliary memory or external memory - for storing
instruction and data - data stored are permanent in nature - larger storage capacity than primary memory.
12.a) write about the need and types of looping statements in c language and discuss with examples(16).
NEED:
do the same thing many times.
There are three basic types of loops which are:
for loop
syntax with program.
while loop
syntax with program.
do while loop
syntax with program.
12.b) write about the need and types of branching statements in c language and discuss with examples
(16).
Many times it is required to alter the flow of sequence of instructions.
Branching Statement are of following categories:
1. If Statement

syntax with program.


2. The If else Statement
syntax with program.
3. Nested if Statement
syntax with program.
4. Switch Statement
syntax with program.
13.a)(i) write a c program to reverse a string.(8)
#include<stdio.h>
#include<string.h>
int main(){
char str[50];
char *rev;
printf("Enter any string : ");
scanf("%s",str);
rev = strrev(str);
printf("Reverse string is : %s",rev);
return 0;
}
(ii) write a c program to print the Fibonacci series of a given number.(8)
#include<stdio.h>
int main()
{
int n,i,num1=-1,num2=1,num3;
printf("Enter the number range:");
scanf("%d",&n);
printf("FIBONACCI SERIES: ");
for(i=0;i<n;i++)
{
num3=num1+num2;
num1=num2;
num2=num3;
printf(" %d",num3);
}
}
13. b) To find sum of two matrices16)
#include<stdio.h>
int main()
{
int a[3][3],b[3][3],c[3][3],i,j;
printf("Enter the First matrix->");
for(i=0;i<3;i++)

for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
printf("\nEnter the Second matrix->");
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&b[i][j]);
printf("\nThe First matrix is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
printf("%d\t",a[i][j]);
}
printf("\nThe Second matrix is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
printf("%d\t",b[i][j]);
}
for(i=0;i<3;i++)
for(j=0;j<3;j++)
c[i][j]=a[i][j]+b[i][j];
printf("\nThe Addition of two matrix is\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
printf("%d\t",c[i][j]);
}
return 0;
}
14. a) i) Function Declaration. (8).
A function in C can perform a particular task, and supports the concept of modular programming design
techniques.
Function Declaration
returntype function-name(Parameters);
Example:
int square(int, int);
Program example:
#include<stdio.h>
#include<conio.h> void main()

{
int n; long int i;
long int fibo(int n); clrscr();
printf("Enter the limit:\n");
scanf("%d",&n);
i=fibo(n);
printf("\nThe %dth Fibonacci number is %ld",n,i); getch();
}
long int fibo(int n)
{
int old_no,currnt_no,sum,i; i=1;
old_no=0; currnt_no=1; while(i<=n)
{
sum=old_no+currnt_no; old_no=currnt_no; currnt_no=sum;
i++;
printf("\n%d",sum);
}
return(sum);
}
ii) Call by reference, call by value: (8)
(i) CALL BY VALUE:
When the value is passed directly to the function it is called call by value. In call by value only a copy of the
variable is only passed so any changes made to the variable does not reflects in the calling function.
Example:
#include<stdio.h>
#include<conio.h>
swap(int,int); void main()
{
int x,y;
printf("Enter two nos"); scanf("%d %d",&x,&y);
printf("\nBefore swapping : x=%d y=%d",x,y);
swap(x,y);
getch();
}
swap(int a,int b)
{
int t;
t=a;
a=b;
b=t;
printf("\nAfter swapping :x=%d y=%d",a,b);
}

(ii)Call by Reference:
#include <stdio.h>
#include <conio.h>
void swap(int*,int*);
int main()
{
int x,y;
printf("Enter the value of x and y \n"); scanf("%d%d",&x,&y);
printf("Before swapping\nx = %d\ny = %d\n",x,y);
swap(&x,&y);
printf("After swapping\nx = %d\ny = %d",x,y); getch();
return 0;
}
void swap (int *a, int *b)
{
int temp;
temp=*a;
*a=*b;
*b=temp;
}
14. b) i) Function with and without arguments with example for each: (10)
Explain any one of the given below:
Function with argument with return type:

Function with argument without return


type:
#include<stdio.h>
void add(int a,int b);
void main()
{
.add(num1,num2);
..
}
void add(int a,int b)
{int sum;
.
printf(sum);
}

Explain any one of the given below:


Function without argument with return type:

Function without argument with return


type:
#include<stdio.h>
void add();
void main()
{
.add();
..
}
void add()
{int a,b,sum;
.
printf(sum);
}

ii) Recursion: (6)


This is where a function repeatedly calls itself to perform calculations. Typical applications are games and
Sorting trees and lists.
Consider the calculation of 6! ( 6 factorial )
ie 6! = 6 * 5 * 4 * 3 * 2 * 1 6! = 6 * 5!
6! = 6 * ( 6 - 1 )! n! = n * ( n - 1 )!
Example:
/* example for demonstrating recursion */
#include <stdio.h>
long int factorial( int ); /* function prototype */
long int factorial( int n )
{
long int result;
if( n == 0 )
result = 1;
else
result = n * factorial( n - 1 );
return ( result );
}
main()
{
int j,n;
printf(Enter the value of N:);
scanf(%d,&n)
for( j = 0; j < =n; j++ )
printf("%2d! = %ld\n", factorial( j) );
}

15. a) i) Storage classes? List and explain with example. (8)


A storage class defines the scope (visibility) and life time of variables and/or functions within a C Program.
There are following storage classes which can be used in a C Program
auto
register static extern
auto - Storage Class
auto is the default storage class for all local variables.
{
int Count; auto int Month;
}
The example above defines two variables with the same storage class. auto can only be used within functions,
i.e. local variables.
register - Storage Class
register is used to define local variables that should be stored in a register instead of RAM. This means that the
variable has a maximum size equal to the register size (usually one word) and cant have the unary '&' operator
applied to it (as it does not have a memory location).
{
register int Miles;
}
Register should only be used for variables that require quick access - such as counters. It should also be noted
that defining 'register' goes not mean that the variable will be stored in a register. It means that it MIGHT be
stored in a register - depending on hardware and implementation restrictions.

static - Storage Class


static is the default storage class for global variables. The two variables below (count and road) both have a
static storage class.
static int Count; int Road;
{
printf("%d\n", Road);
}
static variables can be 'seen' within all functions in this source file. At link time, the static variables defined here
will not be seen by the object modules that are brought in.
static can also be defined within a function. If this is done the variable is initialized at run time but is not
reinitialized when the function is called. This inside a function static variable retains its value during various
calls.
ii) Structure to store date, day, month and year: (8)
#include<stdio.h>
struct date{
int day;
int month;
int year;
};

struct student {
char name [50];
int roll;
char address[50];
struct date dob;
};
main()
{
int i,j,n;
struct student a[50];
{
printf("How many data you want to input?");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter your name ");
scanf("%s",&a[i].name);
printf("Enter your roll");
scanf("%d",&a[i].roll);
printf("Enter your address ");
scanf("%s",&a[i].address);
printf("Enter your Date of Birth (dd/mm/yy)");
scanf("%d%d%d",&a[i].dob.day,&a[i].dob.month,&a[i].dob.year);
}
printf("\n");
for(j=0;j<n;j++)
{
printf("Name :- %s \n ",a[j].name);
printf("Roll Number :- %d\n",a[j].roll);
printf("Address :- %s \n ",a[j].address);
printf("Date of Birth(dd/mm/yy) :- %d/%d/%d\n",a[j].dob.day,a[j].dob.month,a[j].dob.year );
printf("\n");
}
}
}
15. b) C program to create mark sheet for students using structure: (16)
#include
#include
struct marks
{
char n[10];
int m[5];

float avg[3];
int tot[3];
};
struct marks stu[3];
void main()
{
int i,j,n;
printf("Enter the number of students\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter the name of the students-%d\n",i+1);
scanf("%s",stu[i].n);
stu[i].tot[i]=0;
for(j=0;j<5;j++)
{
printf("Enter the marks%d\n",j+1);
scanf("%d",&stu[i].m[j]);
stu[i].tot[i]+=stu[i].m[j]);
}
stu[i].avg[i]=(float)(stu[i].tot[i]/5);
}
printf("NAME\tMARK1\tMARK2\tMARK3\tMARK4\tMARK5\tTOTAL\tAVERAGE\tRESULT\tCLASS\n")
;
for(i=0;i<n;i++)
{
printf("%s\t%d\t%d\t%d\t%d\t%d\t%d\t%5.2f",stu[i].n,stu[i].m[0],stu[i].m[1],stu[i].m[2],stu[i].m[3],
stu[i].m[4],stu[i].tot[i],stu[i].avg[i]);
if(stu[i].m[0]>34&&stu[i].m[1]>34&&stu[i].m[2]>34&&stu[i].m[3]>34 && stu[i].m[4]>34)
{
printf("\tPass");
if(stu[i].avg[i]>59)
printf("\tFirst");
if(stu[i].avg[i]<60&&stu[i].avg[i]>50)
printf("\tSecond\n");
if(stu[i].avg[i]<50)
printf("\tThird\n");
}
else
printf("Fail");
}
getch();
}

Potrebbero piacerti anche