Class-8th
Subject – Computer
L-7 Introduction to C
A. Choose the Correct Answer.
1. C language was designed and written by.
1. Dennis Ritchie 2.
Ritchie
2. Ken Thompson 4.
Martin Richard
2. C is a well structured high level programming language
developed by
1. AT&T 2. AT&T bell laboratories
3. Cambridge university 4.
AT&T bell lab
3. Assignment Operators in C language.
1. = 2.
%
3. / 4.
&
4. These are supports to increment & decrement the
value of identifiers of variables by.
1. 2 2.
0
3. 1 4.
++
5. Symbol of AND operators in c language.
1. && 2.
||
3. ! 4.
%
B. Fill in the blanks:-
1. C stands between HLL and
LLL.
2. C is a well-structured
high level programming
language.
3. C developed by AT
& T bell Laboratories of USA during 1972 years.
4. CPL developed by Cambridge
University .
5. if ( ) statement the logical condition is tested which
results in either TRUE orFALSE .
C. Answer questions:-
1. What is a C?
Ans: C is a well- structured
high level programming language (HLL) developed by AT&T bell
Laboratories
of USA during 1972's. This language was designed and written by
Dennis
Ritchie, in the late seventy. C language replaced the most of the familiar HLL,
like PL/1, ALGOL etc.
2. Write any characteristics of a C language?
Ans: Characteristics/
advantages of C
The
following characteristics of 'C' made this language more powerful &
popular.
a. C is
a structured programming language.
b. C is
a general Purpose Programming language.
c. C has
rich and powerful set of operators.
d. C
provides more compact representatives for all types of expressions.
e. It
supports a rich set of data declaration and data type.
f. C has
very less number of reserved words.
g. C
allows manipulation of internal process registers.
h. C has
ability to extend itself by adding more functions to its library.
i. It has powerful ability to perform pointer arithmetic and
pointer manipulation.
3. Explain the difference between while loop and do loop?
Ans: While
( ) loop…………………………………..
While( )
statement perform the loop in desired number of time. It is conditional looping
depending
on the conditions it performs. It repeats the statements till given condition
is
True.
Once the given condition is fails it automatically terminate the loop.( it is
Test do
process.)
SYNTAX:-
While(<condn>)
{
<set
of statemtn in loop;>
}
do- while…………………………………………..
It is do
test process. It performs the set of loop statements first, then it will check
the
condition.
It repeats the set of statements till given condition is true.
SYNTAX:
do
{
<set
of statement in loop;>initialize}
while(<condition>);
Example
int i=0;
do
{
I= i+1;
Printf(“%d”,i);
}
While(i<=100);
4. The difference between Arithmetic operators and Assignment
operators.
Ans: Arithmetic operators
support the manipulation of digits
(integers
and floating numbers)
Assignment
operator= (equal) evaluates the expression on the right hand side &
assigns
the resulting values to the variables on the left hand side, ss.
Example:- Sum= 0
I=j+1;
X=a*b*c;
Note L
difference between = and == sign.
= this
sign act as Assignment Operator
Example:
A= 100 [ Value 100 assigned to A]
= = This
sign act as Relational Operator [ Which allows to compare]
Example: if (A==B) [ it means to check the A equal to B]
5. Write a note on.
1. Print statement
Ans: Print
Statement
Printf() is a function which is used
to display any value or constants or variable or
any
expression on the screen.
Syntax:-
Printf (“
< format String>”, <list of variables>);
<format
string> are as follows:
%f = it
is used for printing real values
%d = it
is used for integer value
%c = =
it is used for character value
%s = it is used for string value
2. Scan statement
Ans: Scanf
() : the function of scanf ( ) is to accept the value from
the user through keyboard,
after
execute the statement and assign to its corresponding variable name.
Syntax:-
Scanf(“<format string>”. <list of variables>);
6. Write a program to calculate the simple interest.
1. Ans: #include<stdio.h>
2. int main()
3. {
4. float P , R , T , SI ;
5. P =34000; R =30; T = 5;
6. SI = (P*R*T)/100;
7. printf("\n\n Simple Interest is : %f", SI);
8. return (0);
9. }
7. Write a program to calculate the even or odd.
1. Ans:
#include <stdio.h>
2.
3. void main()
4. {
5. int i, num, odd_sum = 0, even_sum = 0;
6.
7. printf("Enter the
value of num\n");
8. scanf("%d", &num);
9. for (i = 1; i <= num; i++)
10.
{
11. if (i % 2 == 0)
12. even_sum = even_sum + i;
13. else
14. odd_sum = odd_sum + i;
15.
}
16.
printf("Sum of all odd numbers = %d\n", odd_sum);
17.
printf("Sum of all even numbers = %d\n", even_sum);
18.}
8. Write a program the sum of 10 digits by while loop.
Ans: /* C Program to Find Sum of Digits of a Number using While Loop */
#include <stdio.h>
int main()
{
int Number, Reminder, Sum=0;
printf("\n Please Enter any
number\n");
scanf("%d",
&Number);
while(Number > 0)
{
Reminder = Number % 10;
Sum = Sum+ Reminder;
Number = Number / 10;
}
printf("\n Sum of the
digits of Given Number = %d", Sum);
return 0;
}
No comments:
Post a Comment