Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
30 views
15 pages
Assign Emt
Uploaded by
collegmemories0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Assign Emt For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
30 views
15 pages
Assign Emt
Uploaded by
collegmemories0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Assign Emt For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 15
Search
Fullscreen
Dr B R Ambedkar National Institute of Technology Jalandhar Department of Computer Science and Engineering Assignment —2 Faculty : Dr. Lalatendu Behera Full Marks - 100 ‘Student Name: Branch Name: Roll Number: QL. Which of the following are invalid variable names and why? Rs] BASICSALARY basic basichra #MEAN group. 422 population in 2006 over time mindovermatter FLOAT hELLO queue. team’svictory Plot #3 2015_DDay Q2. Point out the errors, if any, in the following C statements, if there is an error write reason 0 (251 (2) int = 314.562 * 150; (b) name = ‘Ajay’ ; (©) varchar = ‘3’ ; (@)3.14*1*r*h=vol_of cyl; ()k=(a*b)(ct(25a+b)(d+e); (@) m_inst = rate of interest * amount in rs ; (g) si= principal * rateofinterest * numberofyears / 100 ; (hy area = 3.14 r=*2; (O volume = 3.14" r42*h; @k=((a*b)+)(25*a+b); Q3. Evaluate the following expressions and show their hierarchy. ray (a) g=big/2 + big * 4/big -big + abc /3;(abe = 2.5, big = 2, assume g to be a float) ()— on=ink * act/2+3/2* act+2+ ig; (ink = 4, act = 1, tig = 3.2, assume on to be an int) © wit add /4-6/2+2/3*6/ god; (qui = 4, add = 2, god = 2, assume s to be an int) @ 3*a/4-6/2+2/3*6/g; (a= 4, g=3, assume s to be an int) Q4. Convert the following equations into corresponding C statements. i Ge zo S8C+b)2/e-0542a/(q+r) (a+b)*Cim) as De (peDye? 4 (@ pa Wt622 (era) BtV (A= LDC +a)/e-0.8 +2b (xtra (lly)QS. What would be the output of the following programs: Is] @) void main { inti float a, b; keisj*is l=jlitiz he bajsimi; rintt( "6d %6d %f %f", k, 1, a, b); } (o) int main() { int a = 80, b = 85, c = 70,d = 75, e = 60; printf("Average of 5 subjects is: %0.2F", latb+c+d+e)/5.0); return 0; } (e) int main() { inta = 5, b= 8; printf("Numbers before swapping a = %d, b = %d", a,b); a=atb; ab; a=ab; printf("\nNumbers after swapping a = %d, b = %d", a,b); return 0; } 0) main() printf (“a = %db = %d", a,b); } @ main() { printf ("nn \n\n nin" ) ; prinef ("nn /n/n nnn" ) ; , eo main() { int pqs printf ("Enter values of p and q"); scanf (" %d %d", p,q); printt ("p= %d q =%d", p,q); }Q6. What would be the output of the following programs? [uo] (@) main() { int a= 300, b, ¢; if(a>= 400) b= 300; 100 ; printf ("\n%d %d", b,c); } (©) main() { int x = 10, y= 20; if(x==y)5 printf ("\n%d %d", x, y) 3 } (e) main() { int x = float y if(x printf ("\nx and y are equal” ) ; else printf ("\nx and y are not equal" ); yt (b) main() { int a= 500, b,c; if(a>=400) b= 300; c= 200; printf ("\n%d %d", b, ¢); } (@) main() { intx=3,y=5; if( ) printf ("\n%ql", x) else; printf ("\n%d", y , (8 main() { intx=3,y,25 y=x=10; z=x<10; printf ("nx = %d y = %d 2 = %d", x, y, 2); }@ main() { int k= 35; printf ("\n%d %d %d", k } = 35, k= 50, k> 40); o main( ) 5.b,c5 15; c=a
=}) printf ("\na and b are equal” ) ; } (© main() (@) main( ){ { if(X'<'x') int x= 10; printf ( "\nascii value of X is smaller than that of if (x >= 2) then x") printf ("\n9%d", x); } } (e) main() (8) main( ) { { int x= 10; int x= 10, y=15; ifx>=2 if (x% 2=¥%3) printf ("\nd%d", x); printf (*\nCarpathians” ) ; } } (g) main( ) (h) main( ) { { intx=30, y=40; int x= 10; if(x==y) if (x>=2) then printi( "x is equal to y" ); printf ("in%dl", x) elseif (x>y) } printf( “x is greater than y" ) ; elseif (x
50) if(i=5 &&2>5) prinef ("\nDean of students affairs" ); else printf ("wnDosa" ) ; , printf ("\wnLet us C" ); else printf ("wnWish C was free !" ) ; ,(©) main() { inti=4,j=-1,k=0,w, x,y,z; w=illjllk; X= 8& j &&k; y=illj&&k; Z=18&j||k; printf ("nw = %d x = %d y = %d-2 = %6d", W, x, ¥, 2); ) (e) main() { inti=-3,j=3; if(itj*1) printf ("\nMassaro” ) ; else printé ("\nBennarivo" ) ; } (g) main() { int p= 8,q= 20; if (p==5 &&q>5) printf ("\nWhy not G") ; else printf ("\nDefinitely C 1") ; ) (i) main() { intx=20,y=40,2=45; if(x>y&&x>z) printi( "x is big"); else if (y > x && y>z) (a) main() { inti=4,j=-1,k=0,y,2; yri+S&&j+1k+2; Z=i+5||j+1&&k+2; printf (“\ny = %d z= 96d", y, 2) 5 y (9 main( ) { int a= 40; if (a> 40 &&a<45) printf (“a is greater than 40 and less than 45" ) ; else printf ("96d a) } (hy main() { inti=-1,)= 1k); =i &&j; 1=illj printf (°%d % } LI): G) main() { int Is fills printf ("%d %d", i,j) 3prinei( "y is big") ; else if (2 > x && 2>y) printi( "2 is big” ); ) Q9. Point out the errors, if any, in the following programs and give reason of error: [8] @ main() { inti=2,j)=5; if(i== 2 &&j==5) printf ( "\nSatisfied at last" ); } (© main() { char spy ='a', password = if (spy == 'a' or password = printf ("\nAll the birds are safe in the nest" ) ; } (©) main() { int x = 10, y = 20; if (x>=2 andy <=50) printf ("\n%q", x); } (g) main() { int x = 2; if (x==2 &&x!=0); { (b) main() { int code, flag 5 if (code == 1 & flag == 0) printf ("\nThe eagle has landed” ) ; + (@) main { inti = 10, j=20; if(i=5) &&if (j= 10) printf ("\nHlave a nice day” ); } (Q main() { inta, b; if(a printf (\nGod is Great" ); } (b) main() { inti= 10, j=10 if (1 && j == 10) printf ("\nHave a nice day" );printf ( "nH" ); } printf( "\nHello” ) ; } else printf( "Bye" ) ; } Q10. What would be the output of the following programs: BI (a) main() (b) main() { { inti=-4,j, num; int k, num = 30 ; j= (num <0? 0: num * num ) ; = (num > 5 ? (num <= 10? 100 : 200) : 500); printf ("ind j); printf ("\n%d", num ) ; ) + (c) main() { imtj=45 (1j != 1? printf ("\nWelcome") : printf ( "\nGood Bye") ) ; } QU1. Point out the errors, if any, in the following programs: 7 (a) main() (b) main() { int tag = 0, code = 1; if (tag ==0) 29%", i) 5 code > 1? printf ("\nHello" ) ? printf ("\ "))5 printf ("\nHello Hi !!") ; } (©) main() (@ main() { { inti=10,j; inta=5,b=6; i>=52(j=10):(j=15); (a==b? printé( "%d",a) );princt ("ined %d", i,j) 5 , (e) main() { intn=9; ¢ ? printf( "You ate correct" ) ; prinef( "You are wrong" );) , (© main() { int kk = 65 ,I1; kk == 65 : printf ( "\n kk is equal to 65" ) : printf (Cn kk is not equal (0 65"); printf( "%d", IL) : } (g) main() { intx= 10, x== 20 && y != 10? printf( "True" prine{( "False" ); ) Q12. What would be the output of the following programs 18] (a) main() (b) main( ) { { intj; inti while (j <= 10) while (i<=10); { { printf ("\n9%d", j) 5 prinef ("wn%d", 1) 5 j=jrds itt; } , } } (©) main() (@) main() { { int; intx=1; while (j <= 10) while (x == 1) { printf ("in%q", 5); x=x-1; j=itl; printf ("\n%d", x) } }(e) main() { intx=1; while (x == 1) x=x-1 printf ("nd , (g) main() , @ main() { while (‘a' <'b') printf ( "\nmalyalam is a palindrome" ) ; } (&) main() { inti; while (i= 10) { prinef ("\n%d", i) ; isitt; } , } (8 main() { char x; while (x = 0; x <= 255 ;x*+) printf ("“\WnAscii value %d Character %e", x, x) 5 , (h) main() { intx=4,y=3,2; printf ("ind %d %d", x, y, 2) 3 , @) main() { inti=10 while (i= 20) printf ("nA computer buff!" ); > @ main() { float x = 1.1; while (x == 1.1) 4 pring ("wn%f", x); x=x-01; } ,(m) main() { while (‘1'<'2) printf (“\nln while loop" ) ; + (0) main() { intx=4, y=0, 2; while (x { we continue ; else printf (“ind %d"”, x, y ) 5 , } (q@ main() { inti=1,j)=1; for(s3) { if(i>5) break ; else jets printf ("\n%d", j); isis , } (13)Find the output for following programs (n) main) { char x ; for (x= 0; x <= 255; x++) printf ("\MnAscii value %d Character 6", XX) 5 + (p) main() { intx=4, y=0, 2; while (x>=0) { if(x==y) break ; else printf (“\n%d %d”, x, y) 5 yes } } () intmaing { inti=1,j=1; for(; js printi(” jaier <1; return 0; } 17](@) int main() { unsigned int a = 10; ana; prine{("%d\n", a); ) o void main() { int x= 97; int y = sizeof(x++); printh("x is %d", x); } © void main() { inta int k= (a+, ++a); prinef("%d\n", k); } () int main() ( if (~0 == 1) printf("yes\n"); else printf("no\n"); o (b) int main() { if (7 & 8) print{("Honesty"); if ((~7 & 0x000f) == 8) printf("is the best policy\n");} @) void main() { inta=5,b=-7,c=0,d; d= +a && +b | +6; printh("in%d%d%d%d", a,b, c, ds } o int main) { int x = +2; x=x2> 1 printf("%din", x); ) (h) void main() { float x = 0.1; if (== 0.1) print{("Sanfoundry"); else printf(" Advanced C Classes"); oint main void main { { unsigned int i = 23; float x = 0.1; signed char c= -23; printf("%d, ", »); if(i>o printt("%f", x); printi("Yest y else if (i <0) printf("No\n"); } 6 0 void main int main() { { double ch; switch (printf("Do")) printf(“enter a value between 1 to 2:"); q scanf("%I0", &ch); case 1: switch (ch) printf("Firstin"); break; case 2: print{("Second\n"); break; default: printf("Defaultin"); break; ) ) ) (m) (a) int main) int main() { { inti=0,}=0; inti=0; while (<5, |< 10) { itt; ies } continue; printf("%d, %6dh\n", i,j); printf("In while loop "); ) } while (i < 2); printf("%din", 1);© int main() { inti=0, j= 0, for (i 1< 25: for j= 0;) <3; printf("Lin"); break; } prinef("2\n"); } print{(“after loop\n"); , @ int main() { inti=0, j=0; while (1 < 2) { Titty while (<3) { printf("Loop\n"); goto 11; } } , ©) int main { inti= char ¢= "a while (i < 2){ iss switch (c) { primtf("9%c ", ); break; break; } ) printf("after loopin");
You might also like
AROOJ
PDF
No ratings yet
AROOJ
27 pages
Ceng230 Midterm Sorulari
PDF
No ratings yet
Ceng230 Midterm Sorulari
98 pages
One Word
PDF
No ratings yet
One Word
22 pages
Control STR Ifswitch19to11!24!11 20111
PDF
No ratings yet
Control STR Ifswitch19to11!24!11 20111
3 pages
C Sample Qyestions
PDF
0% (1)
C Sample Qyestions
145 pages
C Pratical
PDF
No ratings yet
C Pratical
14 pages
Programming in C Journal
PDF
No ratings yet
Programming in C Journal
51 pages
C Language Complete Notes
PDF
No ratings yet
C Language Complete Notes
64 pages
Cosc101 Practice Questions
PDF
No ratings yet
Cosc101 Practice Questions
7 pages
C Programming - Weekly Test 01 - Test Paper
PDF
No ratings yet
C Programming - Weekly Test 01 - Test Paper
5 pages
DPP 3
PDF
No ratings yet
DPP 3
6 pages
C Language Output Finding
PDF
No ratings yet
C Language Output Finding
6 pages
Chapter 2 Outputs and Errors
PDF
No ratings yet
Chapter 2 Outputs and Errors
11 pages
Chapter 10 Errors and Outputs - Final
PDF
No ratings yet
Chapter 10 Errors and Outputs - Final
3 pages
Book Chapter 3 Programming With C
PDF
No ratings yet
Book Chapter 3 Programming With C
36 pages
Computer Programming Assignment-1: (Submission Date: 10/02/2021)
PDF
No ratings yet
Computer Programming Assignment-1: (Submission Date: 10/02/2021)
15 pages
Chapter 10 Errors and Outputs
PDF
No ratings yet
Chapter 10 Errors and Outputs
4 pages
CF Chap2 Engineering Fe Mcq's
PDF
100% (2)
CF Chap2 Engineering Fe Mcq's
54 pages
Bca C Lab Manual 2024-28
PDF
No ratings yet
Bca C Lab Manual 2024-28
22 pages
100 C Objectives
PDF
No ratings yet
100 C Objectives
37 pages
Aptitude Questions Inautix Technologies India Limited Section A
PDF
No ratings yet
Aptitude Questions Inautix Technologies India Limited Section A
32 pages
Written Quizzes Solutions Spring
PDF
No ratings yet
Written Quizzes Solutions Spring
33 pages
DPP 2
PDF
No ratings yet
DPP 2
9 pages
Conditional and Looping Statements: Answer: Explanation
PDF
No ratings yet
Conditional and Looping Statements: Answer: Explanation
10 pages
C - Complete Notes
PDF
No ratings yet
C - Complete Notes
57 pages
C Objective Sheet1
PDF
No ratings yet
C Objective Sheet1
5 pages
2CS101 Detailed List of Tutorials
PDF
No ratings yet
2CS101 Detailed List of Tutorials
7 pages
C Assignment
PDF
No ratings yet
C Assignment
26 pages
Key CP 2 Prog C
PDF
No ratings yet
Key CP 2 Prog C
32 pages
Saumya Gupta IT-2 09213203120 Assignment
PDF
No ratings yet
Saumya Gupta IT-2 09213203120 Assignment
17 pages
Midsem Exam
PDF
No ratings yet
Midsem Exam
8 pages
Assignment: Computer Science
PDF
No ratings yet
Assignment: Computer Science
8 pages
Assignment 2 Anshuman
PDF
No ratings yet
Assignment 2 Anshuman
6 pages
Name: Student Id: Section: Signature
PDF
No ratings yet
Name: Student Id: Section: Signature
4 pages
Most Important Programs of CPS Theory Exam
PDF
No ratings yet
Most Important Programs of CPS Theory Exam
11 pages
C Quiz
PDF
No ratings yet
C Quiz
20 pages
Let Us C Solution
PDF
No ratings yet
Let Us C Solution
16 pages
EMU CMPE112 - CMSE112 - Exercises (19273)
PDF
No ratings yet
EMU CMPE112 - CMSE112 - Exercises (19273)
18 pages
Solution Assignment
PDF
No ratings yet
Solution Assignment
5 pages
My C Notes
PDF
100% (1)
My C Notes
9 pages
Mt1 With Answers
PDF
No ratings yet
Mt1 With Answers
4 pages
15-16 Midsem Solutions Makeup PDF
PDF
No ratings yet
15-16 Midsem Solutions Makeup PDF
5 pages
200 Objective-Type Questions Ramesh
PDF
No ratings yet
200 Objective-Type Questions Ramesh
32 pages
Name: Student Id: Section: Signature
PDF
No ratings yet
Name: Student Id: Section: Signature
4 pages
ESC 101: Fundamentals of Computing Name Roll No Dept. Section
PDF
No ratings yet
ESC 101: Fundamentals of Computing Name Roll No Dept. Section
8 pages
C Basic Questions
PDF
No ratings yet
C Basic Questions
7 pages
Amcat
PDF
No ratings yet
Amcat
32 pages
Smt. Bhagwati Chaturvedi College of Engineering: Spandan-2012
PDF
No ratings yet
Smt. Bhagwati Chaturvedi College of Engineering: Spandan-2012
4 pages
Final
PDF
No ratings yet
Final
8 pages