SlideShare a Scribd company logo
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
(A)Which of these variables are valid and which are not? Why?
BASICSALARY-valid
_basic-valid
basic-hra-no special symbol except a underscore is allowed
#MEANno -special symbol except a underscore is allowed
group. -no special symbol except a underscore is allowed
422-a variable cannot start with a number
population in 2006-a variable cannot have spaces
over time-a variable cannot have spaces
mindovermatter-valid
FLOAT-a variable cannot be a key word
hELLO -valid
queue.-no special symbol except a underscore is allowed
team’svictory- no special symbol except a underscore is allowed
Plot # 3-no special symbol except a underscore is allowed
2015_Dday-a variable cannot start with a number
(B) Point out any errors in the following C statements. If any:
(a) int = 314.562 * 150 ;-no error
(b) name = ‘Ajay’ ;-no error
(c) varchar = ‘3’ ; - no inverted commas are required
(d) 3.14 * r * r * h = vol_of_cyl ;-no error
(e) k = ( a * b ) ( c + ( 2.5a + b ) ( d + e ) ; - a * should be added between two brackets
(f) m_inst = rate of interest * amount in rs ;-no error
(g) si = principal * rateofinterest * numberofyears / 100 ;-no error
(h) area = 3.14 * r ** 2 ; - there is no arithmetic operator such as **
(i) volume = 3.14 * r ^ 2 * h ; - there is no arithmetic opertor such as ^
(j) k = ( (a * b ) + c ) ( 2.5 * a + b ) ; - a * should be added between two brackets
(k) a = b = 3 = 4 ; - 3 and 4 are not equal
(l) count = count + 1 ;-no error
(m) date = '2 Mar 04' ; -no error
(C) Evaluate the following expressions and show their hierarchy.
(a) g = big / 2 + big * 4 / big - big + abc / 3 ;
(abc = 2.5, big = 2, assume g to be a float)
Ans) g = 2/2 + 2*4/2 - 2 + 2.5/3
g = 1 + 4/2 - 2 + 2.5/3 (DIVISION)
g = 1 + 2 - 2 + 2.5/3 (MULTIPLICATION)
g = 1 + 2 - 2 + 0.83 (DIVISION)
g = 3 - 2 + 0.83 (ADDITION)
g = 1 + 0.83 (SUBTRACTION)
g = 1.83 (ADDITION)
(b) on = ink * act / 2 + 3 / 2 * act + 2 + tig ;
(ink = 4, act = 1, tig = 3.2, assume on to be an int)
Ans) on = 4*1/2 + 3/2*1 + 2 + 3.2
on = 4/2 + 3/2*1 + 2 + 3.2 (MULTIPLICATION)
on = 2 + 3/2*1 + 2 + 3.2 (DIVISION)
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
on = 2 + 1*1 + 2 + 3.2 (DIVISION)
on = 2 + 1 + 2 + 3.2 (MULTIPLICATION)
on = 3 + 2 + 3.2 (ADDITION)
on = 5 + 3.2 (ADDITION)
on = 8 (ADDITION)
(c) s = qui * add / 4 - 6 / 2 + 2 / 3 * 6 / god ;
(qui = 4, add = 2, god = 2, assume s to be an int)
Ans) s = 4/2*2/4 - 6/2 + 2/3*6/2
s = 2*2/4 - 6/2 + 2/3*6/2 (DIVISION)
s = 4/4 - 6/2 + 2/3*6/2 (MULTIPLICATION)
s = 1 - 6/2 + 2/3*6/2 (DIVISION)
s = 1 - 3 + 2/3*6/2 (DIVISION)
s = 1 - 3 + 0*6/2 (DIVISION)
s = 1 - 3 + 0/2 (MULTIPLICATION)
s = 1 - 3 + 0 (DIVISION)
s = -2 + 0 (SUBTRACTION)
s = -2 (ADDITION)
(d) s = 1 / 3 * a / 4 - 6 / 2 + 2 / 3 * 6 / g ;
(a = 4, g = 3, assume s to be an int)
Ans) s = 1/3*4/4 - 6/3 + 2/3*6/3
s = 0*4/4 - 6/3 + 2/3 *6/3 (DIVISION)
s = 0/4 - 6/3 + 2/3*6/3 (MULTIPLICATION)
s = 0 - 6/3 + 2/3*6/3 (DIVISION)
s = 0 - 2 + 2/3*6/3 (DIVISION)
s = 0 - 2 + 0*6/3 (DIVISION)
s = 0 - 2 + 0/3 (MULTIPLICATION)
s = 0 - 2 + 0 (DIVISION)
s = -2 + 0 (SUBTRACTION)
s = -2 (ADDITION)
[D] Fill the following table for the expressions given below and then evaluate the result. A sample
entry has been filled in the table for expression.
Expression Operator Left Right Remark
(a) g = 10 / 5 /2 / 1
;
= a 1 or 10/5/2/1 Left operand is
unambiguous, and right
side is not
(b) b = 3 / 2 + 5 * 4
/ 3 ;
= b 7 or 3/2 + 5*4/3 Left operand is
unambiguous, and right
side is not
(c) a = b = c = 3 + 4
;
= c or a=b=c 7 or 3 + 4 Both the sides are not
unambiguous
[E] Convert the following equations into corresponding C statements
(a) Z = 8.8(a + b)2/c - 0.5 + 2a/(q + r)
(a + b) * (l/m)
Ans) Z = (8.8*(a + b)*2/c - 0.5 + (2*a)/(q + r))/((a + b)*(l/m)
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
(b) X = -b + (b*b) + 2 4ac
2a
Ans) X = (-b + (b*b) + 2*4*a*c)/(2*a)
(c) R = 2v + 6.22(c + d)
g + v
Ans) R = (2*v + 6(c+d))/(g + v)
(d) A = (7.7b (xy + a)/c - 0.8 + 2b
(x+y) (1/y)
Ans) A = (7.7*b*(x*y + a)/c - 0.8 + 2*b)/((x + y)*(1/y))
[F] What would be the output of the following programs:
(a) main( )
{
int i = 2, j = 3, k, l ;
float a, b ;
k = i / j * j ;
l = j / i * i ;
a = i / j * j ;
b = j / i * i ;
printf( "%d %d %f %f", k, l, a, b ) ;
}
Ans) 0 2 0.000000 2.000000
(b) main( )
{
int a, b ;
a = -3 - - 3 ;
b = -3 - - ( - 3 ) ;
printf ( "a = %d b = %d", a, b ) ;
}
Ans) a = 0 b = -6
(c) main( )
{
float a = 5, b = 2 ;
int c ;
c = a % b ;
printf ( "%d", c ) ;
}
Ans) error: invalid operands to binary % (have ‘float’ and ‘float’)
c = a % b ;
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
(d) main( )
{
printf ( "nn nn nnn" ) ;
printf ( "nn /n/n nn/n" ) ;
}
Ans) nn
nn nn/n/n nn/n
(e) main( )
{
int a, b ;
printf ( "Enter values of a and b" ) ;
scanf ( " %d %d ", &a, &b ) ;
printf ( "a = %d b = %d", a, b ) ;
}
Ans) Enter the values of a and b: 1 and 2
a = 1 b = 2
(f) main( )
{
int p, q ;
printf ( "Enter values of p and q" ) ;
scanf ( " %d %d ", p, q ) ;
printf ( "p = %d q =%d", p, q ) ;
}
Ans) Enter the values of p and q
Segmentation fault (Core dumped)
[G] Pick up the correct alternative for each of the following questions (Highlighted are the correct
answers):
(a) C language has been developed by
(1) Ken Thompson
(2) Dennis Ritchie
(3) Peter Norton
(4) Martin Richards
(b) C can be used on
(1) Only MS-DOS operating system
(2) Only Linux operating system
(3) Only Windows operating system
(4) All the above
(c) C programs are converted into machine language with the help of
(1) An Editor
(2) A compiler
(3) An operating system
(4) None of the above
(d) The real constant in C can be expressed in which of the following forms
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
(1) Fractional form only
(2) Exponential form only
(3) ASCII form only
(4) Both fractional and exponential forms
(e) A character variable can at a time store
(1) 1 character
(2) 8 characters
(3) 254 characters
(4) None of the above
(f) The statement char ch = ‘Z’ would store in ch
(1) The character Z
(2) ASCII value of Z
(3) Z along with the single inverted commas
(4) Both (1) and (2)
(g) Which of the following is NOT a character constant
(1) ‘Thank You’
(2) ‘Enter values of P, N, R’
(3) ‘23.56E-03’
(4) All the above
(h) The maximum value that an integer constant can have is
(1) -32767
(2) 32767
(3) 1.7014e+38
(4) –1.7014e+38
(i) A C variable cannot start with
(1) An alphabet
(2) A number
(3) A special symbol other than underscore
(4) Both (2) & (3) above
(j) Which of the following statement is wrong
(1) mes = 123.56 ;
(2) con = 'T' * 'A' ;
(3) this = 'T' * 20 ;
(4) 3 + a = b ;
(k) Which of the following shows the correct hierarchy of arithmetic operators in C
(1) **, * or /, + or -
(2) **, *, /, +, -
(3) **, /, *, +, -
(4) / or *, - or +
(l) In b = 6.6 / a + 2 * n ; which operation will be performed first?
(1) 6.6 / a
(2) a + 2
(3) 2 * n
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
(4) Depends upon compiler
(m) Which of the following is allowed in a C Arithmetic instruction
(1) [ ]
(2) { }
(3) ( )
(4) None of the above
(n) Which of the following statements is false
(1) Each new C instruction has to be written on a separate line
(2) Usually all C statements are entered in small case letters
(3) Blank spaces may be inserted between two words in a C statement
(4) Blank spaces cannot be inserted within a variable name
(o) If a is an integer variable, a = 5 / 2 ; will return a value
(1) 2.5
(2) 3
(3) 2
(4) 0
(p) The expression, a = 7 / 22 * ( 3.14 + 2 ) * 3 / 5 ; evaluates to
(1) 8.28
(2) 6.28
(3) 3.14
(4) 0
(q) The expression, a = 30 * 1000 + 2768 ; evaluates to
(1) 32768
(2) -32768
(3) 113040
(4) 0
(r) The expression x = 4 + 2 % - 8 evaluates to
(1) -6
(2) 6
(3) 4
(4) None of the above
(s) Hierarchy decides which operator
(1) is most important
(2) is used first
(3) is fastest
(4) operates on largest numbers
(t) An integer constant in C must have:
(1) At least one digit
(2) Atleast one decimal point
(3) A comma along with digits
(4) Digits separated by commas
(u) A character variable can never store more than
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
(1) 32 characters
(2) 8 characters
(3) 254 characters
(4) 1 character
(v) In C a variable cannot contain
(1) Blank spaces
(2) Hyphen
(3) Decimal point
(4) All the above
(w) Which of the following is FALSE in C
(1) Keywords can be used as variable names
(2) Variable names can contain a digit
(3) Variable names do not contain a blank space
(4) Capital letters can be used in variable names
(x) In C, Arithmetic instruction cannot contain
(1) variables
(2) constants
(3) variable names on right side of =
(4) constants on left side of =
(y) Which of the following shows the correct hierarchy of arithmetic operations in C
(1) / + * -
(2) * - / +
(3) + - / *
(4) * / + -
(z) What will be the value of d if d is a float after the operation d = 2 / 7.0?
(1) 0
(2) 0.2857
(3) Cannot be determined
(4) None of the above
[H] Write C programs for the following:
(a) Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic
salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.
#include <stdio.h>
int main()
{
float basic_sal = 0;
printf("Enter the basic salary:");
scanf("%f",&basic_sal);
float DA = 0;
DA = basic_sal*40/100;
float HRA = 0;
HRA = basic_sal*20/100;
float gross_sal = 0;
gross_sal = basic_sal + DA + HRA;
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
printf("The gross salary is:%f+%f+%f=%f",basic_sal,DA,HRA,gross_sal);
return 0;
}
(b) The distance between two cities (in km.) is input through the keyboard. Write a program to
convert and print this distance in meters, feet, inches and centimeters.
#include <stdio.h>
int main()
{
float dis_in_km = 0;
printf("Enter the distance in kms:");
scanf("%f",&dis_in_km);
float dis_in_cm = 0;
dis_in_cm = dis_in_km*100000;
float dis_in_m = 0;
dis_in_m = dis_in_km*1000;
float dis_in_foot = 0;
dis_in_foot = dis_in_km*3281;
float dis_in_inches = 0;
dis_in_inches = dis_in_km*39370;
printf("The distance in centimeteres = %fn",dis_in_cm);
printf("The distance in meteres = %fn",dis_in_m);
printf("The distance in inches = %fn",dis_in_inches);
printf("The distance in feet = %fn",dis_in_foot);
return 0;
}
(c) If the marks obtained by a student in five different subjects are input through the keyboard, find
out the aggregate marks and percentage marks obtained by the student. Assume that the maximum
marks that can be obtained by a student in each subject is 100.
#include <stdio.h>
int main()
{
float mark1,mark2,mark3,mark4,mark5;
printf("Enter the marks of the 5 subjects:");
scanf("%f,%f,%f,%f,%f",&mark1,&mark2,&mark3,&mark4,&mark5);
float average_of_marks;
average_of_marks = (mark1+mark2+mark3+mark4+mark5)/5;
float per_of_marks;
per_of_marks = (mark1+mark2+mark3+mark4+mark5)/500*100;
printf("The average of marks is:%fn",average_of_marks);
printf("The percentage of marks is%fn",per_of_marks);
}
(d) Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to
convert this temperature into Centigrade degrees.
#include <stdio.h>
int main()
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
{
float temp_in_far;
printf("Enter the temperature in farenheit:");
scanf("%f",&temp_in_far);
float temp_in_cel1;
temp_in_cel1 = temp_in_far-32;
float temp_in_cel2;
temp_in_cel2 = temp_in_cel1/9;
float temp_in_cel3;
temp_in_cel3 = temp_in_cel2*5;
printf("The temperature in celsius is: %f",temp_in_cel3);
}
(e) The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a
program to calculate the area & perimeter of the rectangle, and the area & circumference of the
circle.
#include <stdio.h>
int main()
{
float length,breadth,radius;
printf("Enter the length of the rectangle:");
scanf("%f",&length);
printf("Enter the breadth of the rectangle:");
scanf("%f",&breadth);
printf("Enter the radius of the circle:");
scanf("%f",&radius);
float area_of_rect,peri_of_rect,area_of_circle,circum_of_circle;
area_of_rect = length*breadth;
peri_of_rect = 2*(length + breadth);
area_of_circle = 22*radius*radius/7;
circum_of_circle = 2*22*radius/7;
printf("The area of the rectangle = %fn",area_of_rect);
printf("The perimeter of the rectangle = %fn",peri_of_rect);
printf("The circumference of the circle = %fn",circum_of_circle);
printf("The area of the circle = %fn",area_of_circle);
return 0;
}
(f) Two numbers are input through the keyboard into two locations C and D. Write a program to
interchange the contents of C and D.
#include <stdio.h>
int main()
{
int c,d;
printf("Enter the value of c:");
scanf("%d",&c);
printf("Enter the value of d:");
scanf("%d",&d);
c = c+d;
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
d = c-d;
c = c-d;
printf("After interchanging the values of c and d we have c = %d and d = %d",c,d);
return 0;
}
(g) If a five-digit number is input through the keyboard, write a program to calculate the sum of its
digits.
(Hint: Use the modulus operator ‘%’)
#include <stdio.h>
int main()
{
int num,sum,a,b,c,d,e,d1,d2,d3,d4,d5;
printf("Enter any five digit number: ");
scanf("%d",&num);
a = num/10;
d5 = num%10;
b = a/10;
d4 = a%10;
c = b/10;
d3 = b%10;
d = c/10;
d2 = c%10;
e = d/10;
d1 = d%10;
sum = d1 + d2 + d3 + d4 + d5;
printf("The sum of the digits of the five-digit number you had entered is: %d",sum);
return 0;
}
(h) If a five-digit number is input through the keyboard, write a program to reverse the number.
#include <stdio.h>
int main()
{
int num,reversed_num,a,b,c,d,e,d1,d2,d3,d4,d5;
printf("Enter any five digit number: ");
scanf("%d",&num);
a = num/10;
d5 = num%10;
b = a/10;
d4 = a%10;
c = b/10;
d3 = b%10;
d = c/10;
d2 = c%10;
e = d/10;
d1 = d%10;
reversed_num = (d5*10000) + (d4*1000) + (d3*100) + (d2*10) + (d1*1);
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
printf("The sum of the reversed digits of the five-digit number you had entered is:
%d",reversed_num);
return 0;
}
(i) If a four-digit number is input through the keyboard, write a program to obtain the sum of the
first and last digit of this number.
#include <stdio.h>
int main()
{
int num,sum,a,b,c,d,d1,d2,d3,d4;
printf("Enter any five digit number: ");
scanf("%d",&num);
a = num/10;
d4 = num%10;
b = a/10;
d3 = a%10;
c = b/10;
d2 = b%10;
d = c/10;
d1 = c%10;
sum = d4 + d1;
printf("The sum of the first and last digits of the four-digit number you had entered is: %d",sum);
return 0;
}
(j) In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage
of literate men is 35 of the total population, write a program to find the total number
of illiterate men and women if the population of the town is 80,000.
#include <stdio.h>
int main()
{
int
total_pop,illiterate_men,illiterate_women,literate_men,literate_women,per_of_men,total_literacy,
women;
printf("Enter the total population of the area:");
scanf("%d",&total_pop);
printf("Enter the percentage of men:");
scanf("%d",&per_of_men);
printf("Enter the percentage of total literacy:");
scanf("%d",&total_literacy);
printf("Enter the percentage of literate men:");
scanf("%d",&literate_men);
illiterate_men = per_of_men-literate_men;
illiterate_men = total_pop*illiterate_men/100;
literate_women = total_literacy - literate_men;
women = 100 - per_of_men;
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
illiterate_women = women - literate_women;
illiterate_women = total_pop*illiterate_women/100;
printf("The number of illiterate men = %d ",illiterate_men);
printf("The number of illiterate women = %d ",illiterate_women);
return 0;
}
(k) A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is
input through the keyboard in hundreds, find the total number of currency notes of each
denomination the cashier will have to give to the withdrawer.
#include <stdio.h>
int main()
{
int amount;
printf("Please enter the amount to be withdrawen:");
scanf("%d",&amount);
int notes_100,notes_50,notes_10,notes_left;
notes_100 = amount / 100;
notes_50 = (amount % 100) / 50;
notes_10 = ((amount % 100) % 50) / 10;
notes_left = (((amount % 100) % 50) % 10);
printf("The number of rupee 100 notes to be withdrawen are: %dn",notes_100);
printf("The number of rupee 50 notes to be withdrawen are: %dn",notes_50);
printf("The number of rupee 10 notes to be withdrawen are: %dn",notes_10);
printf("The value of money left is: %dn",notes_left);
return 0;
}
(l) If the total selling price of 15 items and the total profit earned on them is input through the
keyboard, write a program to find the cost price of one item.
#include <stdio.h>
int main()
{
float sp,gain,cp;
printf("Enter the sp of 15 items:");
scanf("%f",&sp);
printf("Enter the gain :");
scanf("%f",&gain);
cp = (sp-gain)/15;
printf("The cp of the 15 items = %f",cp);
return 0;
}
(m) If a five-digit number is input through the keyboard, write a program to print a new number by
adding one to each of its digits. For example if the number that is input is 12391 then the output
should be displayed as 23402
#include <stdio.h>
int main()
LET US C (5th
EDITION) QUESTIONS AND ANSWERS
BY-KAVYA SHARMA
{
int a,b,c,d,e,f,n,sum;
printf("Enter a five digit numbern");
scanf("%d",&n);
a=((n%10)+1)%10;
f=n/10;
b=((f%10)+1)%10;
f=f/10;
c=((f%10)+1)%10;
f=f/10;
d=((f%10)+1)%10;
f=f/10;
e=((f%10)+1)%10;
f=f/10;
sum = (e*10000) + (d*1000) + (c*100) + (b*10) + (a*1);
printf("Result is %d",sum);
return 0;
}

More Related Content

What's hot

Chapter 2 : Balagurusamy_ Programming ANsI in C
Chapter 2 :  Balagurusamy_ Programming ANsI in CChapter 2 :  Balagurusamy_ Programming ANsI in C
Chapter 2 : Balagurusamy_ Programming ANsI in C
BUBT
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
BUBT
 
Chapter 1 : Balagurusamy_ Programming ANsI in C
Chapter 1  :  Balagurusamy_ Programming ANsI in C Chapter 1  :  Balagurusamy_ Programming ANsI in C
Chapter 1 : Balagurusamy_ Programming ANsI in C
BUBT
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in c
BUBT
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.
Hazrat Bilal
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
Shariful Haque Robin
 
Chapter 6 Balagurusamy Programming ANSI in c
Chapter 6  Balagurusamy Programming ANSI  in cChapter 6  Balagurusamy Programming ANSI  in c
Chapter 6 Balagurusamy Programming ANSI in c
BUBT
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
Prof. Dr. K. Adisesha
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C
BUBT
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
choconyeuquy
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
RAJWANT KAUR
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semesterDOSONKA Group
 
CDAC CCAT examination important question
CDAC CCAT examination important questionCDAC CCAT examination important question
CDAC CCAT examination important questionprabhatjon
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
Rahul Chugh
 
Clean code
Clean codeClean code
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
Neil Mathew
 
C and data structure
C and data structureC and data structure
C and data structure
prabhatjon
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
Bilal Mirza
 
String c
String cString c

What's hot (20)

Chapter 2 : Balagurusamy_ Programming ANsI in C
Chapter 2 :  Balagurusamy_ Programming ANsI in CChapter 2 :  Balagurusamy_ Programming ANsI in C
Chapter 2 : Balagurusamy_ Programming ANsI in C
 
Chapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in CChapter 4 : Balagurusamy Programming ANSI in C
Chapter 4 : Balagurusamy Programming ANSI in C
 
Chapter 1 : Balagurusamy_ Programming ANsI in C
Chapter 1  :  Balagurusamy_ Programming ANsI in C Chapter 1  :  Balagurusamy_ Programming ANsI in C
Chapter 1 : Balagurusamy_ Programming ANsI in C
 
Chapter 5 Balagurusamy Programming ANSI in c
Chapter 5 Balagurusamy Programming ANSI  in cChapter 5 Balagurusamy Programming ANSI  in c
Chapter 5 Balagurusamy Programming ANSI in c
 
Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.Printing different pyramid patterns of numbers,alphabets and stars using C.
Printing different pyramid patterns of numbers,alphabets and stars using C.
 
The solution manual of programming in ansi by Robin
The solution manual of programming in ansi by RobinThe solution manual of programming in ansi by Robin
The solution manual of programming in ansi by Robin
 
Chapter 6 Balagurusamy Programming ANSI in c
Chapter 6  Balagurusamy Programming ANSI  in cChapter 6  Balagurusamy Programming ANSI  in c
Chapter 6 Balagurusamy Programming ANSI in c
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C Chapter 3 : Balagurusamy Programming ANSI in C
Chapter 3 : Balagurusamy Programming ANSI in C
 
C multiple choice questions and answers pdf
C multiple choice questions and answers pdfC multiple choice questions and answers pdf
C multiple choice questions and answers pdf
 
Practical File of C Language
Practical File of C LanguagePractical File of C Language
Practical File of C Language
 
Network lap pgms 7th semester
Network lap pgms 7th semesterNetwork lap pgms 7th semester
Network lap pgms 7th semester
 
CDAC CCAT examination important question
CDAC CCAT examination important questionCDAC CCAT examination important question
CDAC CCAT examination important question
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
Clean code
Clean codeClean code
Clean code
 
Programming in C Lab
Programming in C LabProgramming in C Lab
Programming in C Lab
 
C and data structure
C and data structureC and data structure
C and data structure
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
String c
String cString c
String c
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 

Similar to LET US C (5th EDITION) CHAPTER 1 ANSWERS

Ramco Sample Paper 2003
Ramco  Sample  Paper 2003Ramco  Sample  Paper 2003
Ramco Sample Paper 2003
ncct
 
Junaid program assignment
Junaid program assignmentJunaid program assignment
Junaid program assignment
Junaid Ahmed
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2Pamidimukkala Sivani
 
9th class maths MCQs by Ustani G.docx
9th class maths MCQs by Ustani G.docx9th class maths MCQs by Ustani G.docx
9th class maths MCQs by Ustani G.docx
Waseem798409
 
Qp cdsi18-math
Qp cdsi18-mathQp cdsi18-math
Qp cdsi18-math
PRASANTH RAKOTI
 
Maths (2)
Maths (2)Maths (2)
CS_PQMS.pdf
CS_PQMS.pdfCS_PQMS.pdf
CS_PQMS.pdf
justforwatching72
 
Assignment
AssignmentAssignment
Assignment
MrunalMehta4
 
Cpl
CplCpl
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
Vedant Gavhane
 
10 std objective test-1
10  std objective test-110  std objective test-1
10 std objective test-1
Kamarat Kumanukit
 
What is the distance between the points B and C Experience Tradition/tutorial...
What is the distance between the points B and C Experience Tradition/tutorial...What is the distance between the points B and C Experience Tradition/tutorial...
What is the distance between the points B and C Experience Tradition/tutorial...
pinck3124
 
Ramco Q P And C Question Paper 2003
Ramco  Q P And  C  Question  Paper 2003Ramco  Q P And  C  Question  Paper 2003
Ramco Q P And C Question Paper 2003
ncct
 
Add math may june 2016 p1
Add math may june 2016 p1Add math may june 2016 p1
Add math may june 2016 p1
Don Cunningham
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
SumitSingh813090
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdf
ahmed8651
 
Metodologia de la programación - expresiones
Metodologia de la programación - expresionesMetodologia de la programación - expresiones
Metodologia de la programación - expresionesMar_Angeles
 

Similar to LET US C (5th EDITION) CHAPTER 1 ANSWERS (20)

Ramco Sample Paper 2003
Ramco  Sample  Paper 2003Ramco  Sample  Paper 2003
Ramco Sample Paper 2003
 
Junaid program assignment
Junaid program assignmentJunaid program assignment
Junaid program assignment
 
(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2(Www.entrance exam.net)-tcs placement sample paper 2
(Www.entrance exam.net)-tcs placement sample paper 2
 
9th class maths MCQs by Ustani G.docx
9th class maths MCQs by Ustani G.docx9th class maths MCQs by Ustani G.docx
9th class maths MCQs by Ustani G.docx
 
Revision1 C programming
Revision1 C programmingRevision1 C programming
Revision1 C programming
 
Revision1schema C programming
Revision1schema C programmingRevision1schema C programming
Revision1schema C programming
 
Qp cdsi18-math
Qp cdsi18-mathQp cdsi18-math
Qp cdsi18-math
 
Maths (2)
Maths (2)Maths (2)
Maths (2)
 
CS_PQMS.pdf
CS_PQMS.pdfCS_PQMS.pdf
CS_PQMS.pdf
 
Assignment
AssignmentAssignment
Assignment
 
Cpl
CplCpl
Cpl
 
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdfLDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
LDCQ paper Dec21 with answer key_62cb2996afc60f6aedeb248c1d9283e5.pdf
 
10 std objective test-1
10  std objective test-110  std objective test-1
10 std objective test-1
 
What is the distance between the points B and C Experience Tradition/tutorial...
What is the distance between the points B and C Experience Tradition/tutorial...What is the distance between the points B and C Experience Tradition/tutorial...
What is the distance between the points B and C Experience Tradition/tutorial...
 
Ramco Q P And C Question Paper 2003
Ramco  Q P And  C  Question  Paper 2003Ramco  Q P And  C  Question  Paper 2003
Ramco Q P And C Question Paper 2003
 
Add math may june 2016 p1
Add math may june 2016 p1Add math may june 2016 p1
Add math may june 2016 p1
 
pointers 1
pointers 1pointers 1
pointers 1
 
C++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdfC++ in 10 Hours.pdf.pdf
C++ in 10 Hours.pdf.pdf
 
MATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdfMATLAB Questions and Answers.pdf
MATLAB Questions and Answers.pdf
 
Metodologia de la programación - expresiones
Metodologia de la programación - expresionesMetodologia de la programación - expresiones
Metodologia de la programación - expresiones
 

Recently uploaded

Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
AG2 Design
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 

Recently uploaded (20)

Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Delivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and TrainingDelivering Micro-Credentials in Technical and Vocational Education and Training
Delivering Micro-Credentials in Technical and Vocational Education and Training
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 

LET US C (5th EDITION) CHAPTER 1 ANSWERS

  • 1. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA (A)Which of these variables are valid and which are not? Why? BASICSALARY-valid _basic-valid basic-hra-no special symbol except a underscore is allowed #MEANno -special symbol except a underscore is allowed group. -no special symbol except a underscore is allowed 422-a variable cannot start with a number population in 2006-a variable cannot have spaces over time-a variable cannot have spaces mindovermatter-valid FLOAT-a variable cannot be a key word hELLO -valid queue.-no special symbol except a underscore is allowed team’svictory- no special symbol except a underscore is allowed Plot # 3-no special symbol except a underscore is allowed 2015_Dday-a variable cannot start with a number (B) Point out any errors in the following C statements. If any: (a) int = 314.562 * 150 ;-no error (b) name = ‘Ajay’ ;-no error (c) varchar = ‘3’ ; - no inverted commas are required (d) 3.14 * r * r * h = vol_of_cyl ;-no error (e) k = ( a * b ) ( c + ( 2.5a + b ) ( d + e ) ; - a * should be added between two brackets (f) m_inst = rate of interest * amount in rs ;-no error (g) si = principal * rateofinterest * numberofyears / 100 ;-no error (h) area = 3.14 * r ** 2 ; - there is no arithmetic operator such as ** (i) volume = 3.14 * r ^ 2 * h ; - there is no arithmetic opertor such as ^ (j) k = ( (a * b ) + c ) ( 2.5 * a + b ) ; - a * should be added between two brackets (k) a = b = 3 = 4 ; - 3 and 4 are not equal (l) count = count + 1 ;-no error (m) date = '2 Mar 04' ; -no error (C) Evaluate the following expressions and show their hierarchy. (a) g = big / 2 + big * 4 / big - big + abc / 3 ; (abc = 2.5, big = 2, assume g to be a float) Ans) g = 2/2 + 2*4/2 - 2 + 2.5/3 g = 1 + 4/2 - 2 + 2.5/3 (DIVISION) g = 1 + 2 - 2 + 2.5/3 (MULTIPLICATION) g = 1 + 2 - 2 + 0.83 (DIVISION) g = 3 - 2 + 0.83 (ADDITION) g = 1 + 0.83 (SUBTRACTION) g = 1.83 (ADDITION) (b) on = ink * act / 2 + 3 / 2 * act + 2 + tig ; (ink = 4, act = 1, tig = 3.2, assume on to be an int) Ans) on = 4*1/2 + 3/2*1 + 2 + 3.2 on = 4/2 + 3/2*1 + 2 + 3.2 (MULTIPLICATION) on = 2 + 3/2*1 + 2 + 3.2 (DIVISION)
  • 2. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA on = 2 + 1*1 + 2 + 3.2 (DIVISION) on = 2 + 1 + 2 + 3.2 (MULTIPLICATION) on = 3 + 2 + 3.2 (ADDITION) on = 5 + 3.2 (ADDITION) on = 8 (ADDITION) (c) s = qui * add / 4 - 6 / 2 + 2 / 3 * 6 / god ; (qui = 4, add = 2, god = 2, assume s to be an int) Ans) s = 4/2*2/4 - 6/2 + 2/3*6/2 s = 2*2/4 - 6/2 + 2/3*6/2 (DIVISION) s = 4/4 - 6/2 + 2/3*6/2 (MULTIPLICATION) s = 1 - 6/2 + 2/3*6/2 (DIVISION) s = 1 - 3 + 2/3*6/2 (DIVISION) s = 1 - 3 + 0*6/2 (DIVISION) s = 1 - 3 + 0/2 (MULTIPLICATION) s = 1 - 3 + 0 (DIVISION) s = -2 + 0 (SUBTRACTION) s = -2 (ADDITION) (d) s = 1 / 3 * a / 4 - 6 / 2 + 2 / 3 * 6 / g ; (a = 4, g = 3, assume s to be an int) Ans) s = 1/3*4/4 - 6/3 + 2/3*6/3 s = 0*4/4 - 6/3 + 2/3 *6/3 (DIVISION) s = 0/4 - 6/3 + 2/3*6/3 (MULTIPLICATION) s = 0 - 6/3 + 2/3*6/3 (DIVISION) s = 0 - 2 + 2/3*6/3 (DIVISION) s = 0 - 2 + 0*6/3 (DIVISION) s = 0 - 2 + 0/3 (MULTIPLICATION) s = 0 - 2 + 0 (DIVISION) s = -2 + 0 (SUBTRACTION) s = -2 (ADDITION) [D] Fill the following table for the expressions given below and then evaluate the result. A sample entry has been filled in the table for expression. Expression Operator Left Right Remark (a) g = 10 / 5 /2 / 1 ; = a 1 or 10/5/2/1 Left operand is unambiguous, and right side is not (b) b = 3 / 2 + 5 * 4 / 3 ; = b 7 or 3/2 + 5*4/3 Left operand is unambiguous, and right side is not (c) a = b = c = 3 + 4 ; = c or a=b=c 7 or 3 + 4 Both the sides are not unambiguous [E] Convert the following equations into corresponding C statements (a) Z = 8.8(a + b)2/c - 0.5 + 2a/(q + r) (a + b) * (l/m) Ans) Z = (8.8*(a + b)*2/c - 0.5 + (2*a)/(q + r))/((a + b)*(l/m)
  • 3. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA (b) X = -b + (b*b) + 2 4ac 2a Ans) X = (-b + (b*b) + 2*4*a*c)/(2*a) (c) R = 2v + 6.22(c + d) g + v Ans) R = (2*v + 6(c+d))/(g + v) (d) A = (7.7b (xy + a)/c - 0.8 + 2b (x+y) (1/y) Ans) A = (7.7*b*(x*y + a)/c - 0.8 + 2*b)/((x + y)*(1/y)) [F] What would be the output of the following programs: (a) main( ) { int i = 2, j = 3, k, l ; float a, b ; k = i / j * j ; l = j / i * i ; a = i / j * j ; b = j / i * i ; printf( "%d %d %f %f", k, l, a, b ) ; } Ans) 0 2 0.000000 2.000000 (b) main( ) { int a, b ; a = -3 - - 3 ; b = -3 - - ( - 3 ) ; printf ( "a = %d b = %d", a, b ) ; } Ans) a = 0 b = -6 (c) main( ) { float a = 5, b = 2 ; int c ; c = a % b ; printf ( "%d", c ) ; } Ans) error: invalid operands to binary % (have ‘float’ and ‘float’) c = a % b ;
  • 4. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA (d) main( ) { printf ( "nn nn nnn" ) ; printf ( "nn /n/n nn/n" ) ; } Ans) nn nn nn/n/n nn/n (e) main( ) { int a, b ; printf ( "Enter values of a and b" ) ; scanf ( " %d %d ", &a, &b ) ; printf ( "a = %d b = %d", a, b ) ; } Ans) Enter the values of a and b: 1 and 2 a = 1 b = 2 (f) main( ) { int p, q ; printf ( "Enter values of p and q" ) ; scanf ( " %d %d ", p, q ) ; printf ( "p = %d q =%d", p, q ) ; } Ans) Enter the values of p and q Segmentation fault (Core dumped) [G] Pick up the correct alternative for each of the following questions (Highlighted are the correct answers): (a) C language has been developed by (1) Ken Thompson (2) Dennis Ritchie (3) Peter Norton (4) Martin Richards (b) C can be used on (1) Only MS-DOS operating system (2) Only Linux operating system (3) Only Windows operating system (4) All the above (c) C programs are converted into machine language with the help of (1) An Editor (2) A compiler (3) An operating system (4) None of the above (d) The real constant in C can be expressed in which of the following forms
  • 5. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA (1) Fractional form only (2) Exponential form only (3) ASCII form only (4) Both fractional and exponential forms (e) A character variable can at a time store (1) 1 character (2) 8 characters (3) 254 characters (4) None of the above (f) The statement char ch = ‘Z’ would store in ch (1) The character Z (2) ASCII value of Z (3) Z along with the single inverted commas (4) Both (1) and (2) (g) Which of the following is NOT a character constant (1) ‘Thank You’ (2) ‘Enter values of P, N, R’ (3) ‘23.56E-03’ (4) All the above (h) The maximum value that an integer constant can have is (1) -32767 (2) 32767 (3) 1.7014e+38 (4) –1.7014e+38 (i) A C variable cannot start with (1) An alphabet (2) A number (3) A special symbol other than underscore (4) Both (2) & (3) above (j) Which of the following statement is wrong (1) mes = 123.56 ; (2) con = 'T' * 'A' ; (3) this = 'T' * 20 ; (4) 3 + a = b ; (k) Which of the following shows the correct hierarchy of arithmetic operators in C (1) **, * or /, + or - (2) **, *, /, +, - (3) **, /, *, +, - (4) / or *, - or + (l) In b = 6.6 / a + 2 * n ; which operation will be performed first? (1) 6.6 / a (2) a + 2 (3) 2 * n
  • 6. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA (4) Depends upon compiler (m) Which of the following is allowed in a C Arithmetic instruction (1) [ ] (2) { } (3) ( ) (4) None of the above (n) Which of the following statements is false (1) Each new C instruction has to be written on a separate line (2) Usually all C statements are entered in small case letters (3) Blank spaces may be inserted between two words in a C statement (4) Blank spaces cannot be inserted within a variable name (o) If a is an integer variable, a = 5 / 2 ; will return a value (1) 2.5 (2) 3 (3) 2 (4) 0 (p) The expression, a = 7 / 22 * ( 3.14 + 2 ) * 3 / 5 ; evaluates to (1) 8.28 (2) 6.28 (3) 3.14 (4) 0 (q) The expression, a = 30 * 1000 + 2768 ; evaluates to (1) 32768 (2) -32768 (3) 113040 (4) 0 (r) The expression x = 4 + 2 % - 8 evaluates to (1) -6 (2) 6 (3) 4 (4) None of the above (s) Hierarchy decides which operator (1) is most important (2) is used first (3) is fastest (4) operates on largest numbers (t) An integer constant in C must have: (1) At least one digit (2) Atleast one decimal point (3) A comma along with digits (4) Digits separated by commas (u) A character variable can never store more than
  • 7. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA (1) 32 characters (2) 8 characters (3) 254 characters (4) 1 character (v) In C a variable cannot contain (1) Blank spaces (2) Hyphen (3) Decimal point (4) All the above (w) Which of the following is FALSE in C (1) Keywords can be used as variable names (2) Variable names can contain a digit (3) Variable names do not contain a blank space (4) Capital letters can be used in variable names (x) In C, Arithmetic instruction cannot contain (1) variables (2) constants (3) variable names on right side of = (4) constants on left side of = (y) Which of the following shows the correct hierarchy of arithmetic operations in C (1) / + * - (2) * - / + (3) + - / * (4) * / + - (z) What will be the value of d if d is a float after the operation d = 2 / 7.0? (1) 0 (2) 0.2857 (3) Cannot be determined (4) None of the above [H] Write C programs for the following: (a) Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary. #include <stdio.h> int main() { float basic_sal = 0; printf("Enter the basic salary:"); scanf("%f",&basic_sal); float DA = 0; DA = basic_sal*40/100; float HRA = 0; HRA = basic_sal*20/100; float gross_sal = 0; gross_sal = basic_sal + DA + HRA;
  • 8. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA printf("The gross salary is:%f+%f+%f=%f",basic_sal,DA,HRA,gross_sal); return 0; } (b) The distance between two cities (in km.) is input through the keyboard. Write a program to convert and print this distance in meters, feet, inches and centimeters. #include <stdio.h> int main() { float dis_in_km = 0; printf("Enter the distance in kms:"); scanf("%f",&dis_in_km); float dis_in_cm = 0; dis_in_cm = dis_in_km*100000; float dis_in_m = 0; dis_in_m = dis_in_km*1000; float dis_in_foot = 0; dis_in_foot = dis_in_km*3281; float dis_in_inches = 0; dis_in_inches = dis_in_km*39370; printf("The distance in centimeteres = %fn",dis_in_cm); printf("The distance in meteres = %fn",dis_in_m); printf("The distance in inches = %fn",dis_in_inches); printf("The distance in feet = %fn",dis_in_foot); return 0; } (c) If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100. #include <stdio.h> int main() { float mark1,mark2,mark3,mark4,mark5; printf("Enter the marks of the 5 subjects:"); scanf("%f,%f,%f,%f,%f",&mark1,&mark2,&mark3,&mark4,&mark5); float average_of_marks; average_of_marks = (mark1+mark2+mark3+mark4+mark5)/5; float per_of_marks; per_of_marks = (mark1+mark2+mark3+mark4+mark5)/500*100; printf("The average of marks is:%fn",average_of_marks); printf("The percentage of marks is%fn",per_of_marks); } (d) Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into Centigrade degrees. #include <stdio.h> int main()
  • 9. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA { float temp_in_far; printf("Enter the temperature in farenheit:"); scanf("%f",&temp_in_far); float temp_in_cel1; temp_in_cel1 = temp_in_far-32; float temp_in_cel2; temp_in_cel2 = temp_in_cel1/9; float temp_in_cel3; temp_in_cel3 = temp_in_cel2*5; printf("The temperature in celsius is: %f",temp_in_cel3); } (e) The length & breadth of a rectangle and radius of a circle are input through the keyboard. Write a program to calculate the area & perimeter of the rectangle, and the area & circumference of the circle. #include <stdio.h> int main() { float length,breadth,radius; printf("Enter the length of the rectangle:"); scanf("%f",&length); printf("Enter the breadth of the rectangle:"); scanf("%f",&breadth); printf("Enter the radius of the circle:"); scanf("%f",&radius); float area_of_rect,peri_of_rect,area_of_circle,circum_of_circle; area_of_rect = length*breadth; peri_of_rect = 2*(length + breadth); area_of_circle = 22*radius*radius/7; circum_of_circle = 2*22*radius/7; printf("The area of the rectangle = %fn",area_of_rect); printf("The perimeter of the rectangle = %fn",peri_of_rect); printf("The circumference of the circle = %fn",circum_of_circle); printf("The area of the circle = %fn",area_of_circle); return 0; } (f) Two numbers are input through the keyboard into two locations C and D. Write a program to interchange the contents of C and D. #include <stdio.h> int main() { int c,d; printf("Enter the value of c:"); scanf("%d",&c); printf("Enter the value of d:"); scanf("%d",&d); c = c+d;
  • 10. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA d = c-d; c = c-d; printf("After interchanging the values of c and d we have c = %d and d = %d",c,d); return 0; } (g) If a five-digit number is input through the keyboard, write a program to calculate the sum of its digits. (Hint: Use the modulus operator ‘%’) #include <stdio.h> int main() { int num,sum,a,b,c,d,e,d1,d2,d3,d4,d5; printf("Enter any five digit number: "); scanf("%d",&num); a = num/10; d5 = num%10; b = a/10; d4 = a%10; c = b/10; d3 = b%10; d = c/10; d2 = c%10; e = d/10; d1 = d%10; sum = d1 + d2 + d3 + d4 + d5; printf("The sum of the digits of the five-digit number you had entered is: %d",sum); return 0; } (h) If a five-digit number is input through the keyboard, write a program to reverse the number. #include <stdio.h> int main() { int num,reversed_num,a,b,c,d,e,d1,d2,d3,d4,d5; printf("Enter any five digit number: "); scanf("%d",&num); a = num/10; d5 = num%10; b = a/10; d4 = a%10; c = b/10; d3 = b%10; d = c/10; d2 = c%10; e = d/10; d1 = d%10; reversed_num = (d5*10000) + (d4*1000) + (d3*100) + (d2*10) + (d1*1);
  • 11. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA printf("The sum of the reversed digits of the five-digit number you had entered is: %d",reversed_num); return 0; } (i) If a four-digit number is input through the keyboard, write a program to obtain the sum of the first and last digit of this number. #include <stdio.h> int main() { int num,sum,a,b,c,d,d1,d2,d3,d4; printf("Enter any five digit number: "); scanf("%d",&num); a = num/10; d4 = num%10; b = a/10; d3 = a%10; c = b/10; d2 = b%10; d = c/10; d1 = c%10; sum = d4 + d1; printf("The sum of the first and last digits of the four-digit number you had entered is: %d",sum); return 0; } (j) In a town, the percentage of men is 52. The percentage of total literacy is 48. If total percentage of literate men is 35 of the total population, write a program to find the total number of illiterate men and women if the population of the town is 80,000. #include <stdio.h> int main() { int total_pop,illiterate_men,illiterate_women,literate_men,literate_women,per_of_men,total_literacy, women; printf("Enter the total population of the area:"); scanf("%d",&total_pop); printf("Enter the percentage of men:"); scanf("%d",&per_of_men); printf("Enter the percentage of total literacy:"); scanf("%d",&total_literacy); printf("Enter the percentage of literate men:"); scanf("%d",&literate_men); illiterate_men = per_of_men-literate_men; illiterate_men = total_pop*illiterate_men/100; literate_women = total_literacy - literate_men; women = 100 - per_of_men;
  • 12. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA illiterate_women = women - literate_women; illiterate_women = total_pop*illiterate_women/100; printf("The number of illiterate men = %d ",illiterate_men); printf("The number of illiterate women = %d ",illiterate_women); return 0; } (k) A cashier has currency notes of denominations 10, 50 and 100. If the amount to be withdrawn is input through the keyboard in hundreds, find the total number of currency notes of each denomination the cashier will have to give to the withdrawer. #include <stdio.h> int main() { int amount; printf("Please enter the amount to be withdrawen:"); scanf("%d",&amount); int notes_100,notes_50,notes_10,notes_left; notes_100 = amount / 100; notes_50 = (amount % 100) / 50; notes_10 = ((amount % 100) % 50) / 10; notes_left = (((amount % 100) % 50) % 10); printf("The number of rupee 100 notes to be withdrawen are: %dn",notes_100); printf("The number of rupee 50 notes to be withdrawen are: %dn",notes_50); printf("The number of rupee 10 notes to be withdrawen are: %dn",notes_10); printf("The value of money left is: %dn",notes_left); return 0; } (l) If the total selling price of 15 items and the total profit earned on them is input through the keyboard, write a program to find the cost price of one item. #include <stdio.h> int main() { float sp,gain,cp; printf("Enter the sp of 15 items:"); scanf("%f",&sp); printf("Enter the gain :"); scanf("%f",&gain); cp = (sp-gain)/15; printf("The cp of the 15 items = %f",cp); return 0; } (m) If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example if the number that is input is 12391 then the output should be displayed as 23402 #include <stdio.h> int main()
  • 13. LET US C (5th EDITION) QUESTIONS AND ANSWERS BY-KAVYA SHARMA { int a,b,c,d,e,f,n,sum; printf("Enter a five digit numbern"); scanf("%d",&n); a=((n%10)+1)%10; f=n/10; b=((f%10)+1)%10; f=f/10; c=((f%10)+1)%10; f=f/10; d=((f%10)+1)%10; f=f/10; e=((f%10)+1)%10; f=f/10; sum = (e*10000) + (d*1000) + (c*100) + (b*10) + (a*1); printf("Result is %d",sum); return 0; }