0% found this document useful (0 votes)
31 views

C Lab Programs

This document contains 15 programming questions asking to correct errors in code snippets and print the output. The code snippets contain errors in Pascal programming concepts like variable declaration, input/output statements, loops, conditional statements, functions, and string handling.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

C Lab Programs

This document contains 15 programming questions asking to correct errors in code snippets and print the output. The code snippets contain errors in Pascal programming concepts like variable declaration, input/output statements, loops, conditional statements, functions, and string handling.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

Q1.Correct the Errors in the Program and Print the OutPut.

program Demonstration var Letter : char; Number : char; Dogfood : char begin Leter := 'P'; Number := 'A'; Dogfood := 'S'; Write(Letter,Number,Dogfood); Letter := Number Number := 'L'; Dogfood := 'C'; Write(Dogfood,Letter,Number); Writeln; End;

Q2.Correct the Errors in the Program and Print the OutPut. program natural var i,sum:integer; begin writeln('Enter the limit'); readln(n); sum:=0; for i:=1 to n do; sum=sum+i; writeln('Sum of first ',n,' natural number is ',sum); end; Q3.Correct the Errors in the Program and Print the OutPut. program factorial var i,n:integer; fact:longint; begin; writeln('Enter an integer number'); readln(n); fact:=0; for i:=1 to n do; fact:=fact*i; writeln('factorial of ',n,' is ',fact); end; Q4.Correct the Errors in the Program and Print the OutPut.

program table var i,n,prod:integer; begin writeln('Enter an integer number'); readln(n) writeln('The Multiplication table of ',n,' is'); for i:=1 to n do; begin prod:=n*i; writeln(i,' * ',n,'=',prod); end. End; Q5.Correct the Errors in the Program and Print the OutPut. program big uses var a,b,c:integer; begin clrscr; writeln('Enter the three numbers'); readln(a,b,c) if (a>b) and (a<c) then writeln('Big= ',a) else if b>c then writeln('Big= ',b) else writeln('Big = ',c); readln; end; Q6.Correct the Errors in the Program and Print the OutPut program Demonstrate_Case var Count : integer; begin for Count := 0 to 8 do begin Write(Count:5); case Count of 1 : Write(' One'); 2 : Write(' Two') 3 : Write(' Three'); else Write(' This number is not in the allowable list'); end; end end. . Q7.Correct the Errors in the Program and Print the OutPut

program addition(i,o); var a,b,sum:integer function add( c:integer;d:integer):integer; begin add:=c+d; end; begin writeln('Enter the values'); readln(a,b); sum:=add(a,b) writeln('sum =, 'sum); end. Q8.Correct the Errors in the Program and Print the OutPut program While Loop_Example var Counter : integer; begin Counter = 4; while Counter < 20 do begin; Writeln(Counter:4); Counter := Counter + 2; End. end. Q9.Correct the Errors in the Program and Print the OutPut program even uses var n,i:integer; begin clrscr writeln('Enter the limit of a number'); readln(n); for i:=1 to n do; if i mod 2 =0 then writeln(i); end Q10.Correct the Errors in the Program and Print the OutPut

program day var n:integer; begin writeln('Enter the day number[1..7]'); readln(n) case n of 1 writeln('Saturday'); 2:writeln('SUNDAY'); 3:writeln('Monday'); 4:writeln('Tuesday'); 5:writeln('Wednesday'); 6:writeln('Thursday') 7:writeln('Friday'); end; Q11.Correct the Errors in the Program and Print the OutPut program table1 var i,n,prod:integer; begin writeln('Enter an integer number'); readln(n); writeln('The Multiplication table of ',n,' is') for i:=1 to n do begin; prod:=n*i; writeln(i,' * ',n,'=',prod); end end. Q12.Correct the Errors in the Program and Print the OutPut program example3; var Alphabet : char; Begin; Write('The alphabet is '); for Alphabet := A to Z do Write(Alphabet); Writeln; End; Q13.Correct the Errors in the Program and Print the OutPut

program example2 var Count : integer; Total : integer; begin Total = 0; for Count := 1 to 10 do begin Total := Total + 12 Write('Count =',Count:3,' Total =',Total:5); Writeln; end end. Q14.Correct the Errors in the Program and Print the OutPut Program Concat1 Uses; Var Str1,str2,str : string Begin Str1=college Str2=science Writeln(str2=,str2) Writeln(str1=,str1) Str=concat(str2,str1); Writeln(The new string is,str); End; Q15.Correct the Errors in the Program and Print the OutPut Program string len; Uses Var Long :integer; Str1: string; Begin; Writeln(Enter a string); Readln(str1) Writeln(the string is,str1) Long=length(str1); Writeln(the length of string is,long); end

You might also like