Professional Documents
Culture Documents
Unit I
Unit I
Syllabus
Algorithms,Flowcharts
| Start |
---------
|
|
----------
/ Read M1 /
----------
|
----------
/ Read M2 /
----------
|
----------
/ Read M3 /
----------
|
----------------
| Tot=M1+M2+M3 |
----------------
|
|
----------------
| |
| avg=tot/3 |
| |
----------------
|
|
/\
/ \
/ \
/ \ NO
/if avg<80\_______
\ / |
\ / |
\ / |
\ / ----------
\/ / /
| / Print /
Yes| / Reject /
| ----------
| |
---------- |
/ / |
/ Print / |
/ Call / |
/ / |
---------- |
| |
| |
------------
|
|
---------
| Stop |
---------
Basics (I/O)
2.
a.Distinguish between get char and scanf functions for reading strings
Type
Size
a. What is the difference between signed integer and unsigned integer in terms of
memory and range [Answer Tip]
3.
a. What are the general characteristics of C? [Answer Tip]
b. Give and Explain the structure of a C program? [Answer Tip]
c. Write a C program to print the Pascal’s triangle. [Answer Tip]
[4+4+8]
4. Write about space requirements for variables of different data types.[Answer Tip]. [16]
5.
a. What is the difference between signed integer and unsigned integer in terms of
memory and range [Answer Tip].
b. List the entire data types in C. What is the size of each of these data types [Answer
Tip]. [8+8]
6.
a. What is a string constant? How do string constants differ from character constants?
Do string constants represent numerical Values?
b. Summarize the standard escape sequences in C. Describe them. [Answer Tip]
c. What is a variable? How can variables be characterized? Give the rules for variable
declaration.
d. What is the purpose of type declarations? What are the components of type
declaration? [Answer Tip][4+4+4+4]
7.
a. What are different types of integer constants? What are long integer con- stants? How
do these constants differ from ordinary integer constants? How can they be written
and identified? [Answer Tip]
b. Describe two different ways that floating-point constants can be written in C. What
special rules apply in each case?[Answer Tip]
c. What is a character constant? How do character constants differ from numeric type
constants? Do character constants represent numerical values? [Answer Tip][6+4+6]
Operators
8.
a. What is meant by operator precedence? What are the relative precedence of the
arithmetic operators? [Answer Tip]
b. What is the associatively of the arithmetic operators?[Answer Tip]
c. How can the value of an expression be converted to a different data types? What is
this called?[Answer Tip]
d. What are unary operators? Explain example for each. [Answer Tip][4+4+4+4]
9.
a. Explain the following & illustrate it with an example each.
i. Increment & Decrement operator.[Answer Tip]
ii. Conditional operator. [Answer Tip]
iii. Bitwise operator. [Answer Tip]
iv. Assignment operator. [Answer Tip]
b. State the rules that applied while evaluating expression in automatic type conversion.
[Answer Tip][12+4]
Loops
10.
a. What is the purpose of break statement? [Answer Tip]
b. Suppose a break statement is included within the innermost of several nested control
statements. What happens when break statement is executed?
for(i=0;i<n;i++)
{
------
---
--
for(j=0;j<n;j++)
{
------
---
for(k=0;k<n;k++)
{
---
----
if(condition)
break;
---
-----
}
}
}
whenever the if condition is satisfied the control immediately exit from
the k for loop,now the control will be present in j for loop [Answer Tip]
#include<stdio.h>
void main()
{
int i,n;
printf("\n enter n value");
scanf("%d",&n);
printf("\n MULTIPLICATION TABLE FOR %d IS",n);
for(i=1;i<=20;i++)
printf("\n %d X %d = %d",n,i,(n*i));
}
OUTPUT
enter n value 2
MULTIPLICATION TABLE FOR 2 IS
2X1=2
2X2=4
2X3=6
2X4=8
-----
--------
------
2 X 18 = 36
2 X 19 = 38
2 X 20 = 40
c. [Answer Tip][4+6+6]
Programs
11.a)Write a program to determine and print the sum of the following harmonic series for a given
value of n: 1+1/2+1/3+.....+1/n.
#include<stdio.h>
void main()
{
int i,n;
float sum=0.0;
printf("\n enter n value");
scanf("%d",&n);
for(i=1;i<=n;i++)
sum=sum+(1.0/i);
printf("\n Sum= %f",sum);
}
OUTPUT
enter n value 5
Sum=2.2833333333333333333333333333333
b).What are the logical operators used in C and illustrate with examples. [Answer Tip][8+8]
12.write a C program to print the lower triangular of a given square matrix. [Answer Tip][16]
for(i=1;i<=m;i++)
for(j=1;j<=m;j++)
if (i<=j)
printf("%d",i);
else
printf("%d",0);