JNTUK MID-1 Online Bites and Important Notes A.Y 2022-23 PROGRAMMING FOR PROBLEM SOLVING USING C

 

PROGRAMMING FOR PROBLEM SOLVING USING C (R20)


NOTE: “” Mark is the respective answer.

 

1. Size of a union is determined by sizeof,

           A. first member of union                    B. last member of union 

          C. sum of sizes of all members            D. biggest member of union


2. Output of the following program: float i-2.0; float j-1.0; float sum=0.0; main() { while(i/j>0.001) {          j+=j; sum-sum+(i/j); printf("%f/n, sum); } }

                    A. 8                  B. 10                C. 9                  D. 11


3.  Which loop is most suitable to first perform the operation & then test the condition? 

                 A. for loop              B. while loop       C. do while loop         D. repeat loop


4.  Output of the following program: int i, main() (if(1), else printf(else), return 0,)

      A run time error        B. else block executed     C. if block executed     D. compile time error


5. Which of the following sets first n characters of a string to a given character?

              A strnit( )    B. strset( )            C. strcset( )      D. strnset( )

6. Consider the following two C lines: 1: int var1; 2: extern int var2; Which of the following statements         is correct?

         A.   1 defines & declares var1,but second statement only declares var2

         B.    both statements declare define variables var1&var2

         C.    both statements only declare variables and dont define them

         D.   2 defines & declares var2,but 1 only declares var 1


7.       scanf() is a_____ function

            A. one to one        B. many to many                      C. many to one            D. one to many

8. Which loop is correct?

        A. do{//code) while( condition):                       B. do[//code) while condition)!

        C. do{ //code}while(condition);                   D. do(code);


9. Output of the following program: main() { printf(x,-1>>1); return 0; }

        A. 0fff              B. fff0              C. f0ff              D. ffff

10. Output of the following program: union test (int x, char arr[4]; int y, ); int main()

(union test t; t.x=0; t.arr[1]-G; printf("%s,t.arr); ) Assume, size of (char)=1 sizeof(int) 4

        A. error                        B. garbage value         C. G               D. nothing printed


11. Output of the following program typedef struct (int A; char B; char C, )info, main(){ printf("%d,sizeof(info)); }

        A. 8✓               B. 10                C. 14                D. 12

12. String is a

        A series of only numbers                    B. one character

        C. series of only one character           D. series of characters

13. Output of the following program: #include<stdio.h> int main() { register int i=10; int

*ptr-&i; printf("%d, *ptr); return 0; }


        A may generate compiler error✓                  B. may generate runtime error

        C. prints 0 on all compilers                                 D. prints 10 on all compilers


14. Output of the following program: #include<stdio.h> int main() { int i-3; printf("%d, (++1) ++); return 0; }

            A. 5                  B. 4                  C. 3                  D. compile time error


15. Output of the following program: main() { int a[5]; printf(%u,&a+1); }


        A. 2004            B. 2020✓                     C. 2040                        D. 2022


16. Structure of a C program can be mainly generalized into ______ parts


        A. 5               B. 6                  C. 4                  D. 3



1. Output of the following program: main() { Unsigned int a=0xffff, 'a; printf(%x‚a); }


            A. 0000✓                     B. 00ff             C. ffff               D. ddfd


2. int main() { int i=1024; for(;i;i>>=1) printf(hi); } How many times hi is printed?

        A. 11             B. 0                  C. infinite                    D. 10


3. Output of the following program: int i; main() { if(1); else printf(else); return 0; }

        A.  else block executed

        B.  compile time error

        C.  if block executed 

        D. run time error

4. Output of the following program: union test { int x; char arr[4]; int y; ); int main() (union test t; t.x=0; t.arr[1]-G; printf("%s,t.arr);} Assume, size of (char)=1 sizeof(int) 4


            A. G               B. nothing printed                   C. error                       D. garbage value


5. Return type of getchar() is

        A char              B. int✓                         C. float            D. unsigned char


6. In an enumerated type, each integer value is given an identifier called

            A. varying constant                             B. enumeration constant

            C. integer Constant                             D. constant


7. User defined data type can be derived by______

            A. int                 B. float                           C. typedef                 D. char


8. Output of the following program: main() { int a[5]; printf("%u,&a+1); }


        A. 2020                     B. 2040                        C. 2022                        D. 2004

9. Output of the following program: float i=2.0; float j-1.0; float sum=0.0; main() { while

(i/j>0.001) (j+=j; sum=sum+(ij); printf("%f\n,sum); } }


            A. 8                  B. 11✓             C. 9                  D. 10


10. Output of the following program: main(){ printf(%c,5[Geeks Quiz]); }


A. runtime error                      B. compile time error             C. Q               D. S


11. ____ is used to store integers.


A. Twos Complement Method                    B. Sign and Magnitude Method

C. Threes Complement Method                     D. Ones Complement Method


12. Output of the following program: main() { int a-1;b-0; b-a+++ a++; printf(%d%d,a,b); }


A. 36                B. compiler dependent                       C. 33             D. 34

13. C was derived from which of the following languages:

            A. MODULA-2              B. PASCAL           C. MODULA-3              D. B, BCPL


1. Output of the following program #include<stdio.h> int main() ( register i int *ptr-&i, printf("%d, *ptr); return 0,)


        A. may generate compiler error✓                 B. prints 0 on all compilers

        C. prints 10 on all compilers                           D. may generate runtime error


2 What is order of execution iteration becomes false given for loop? for(1,2,3) (4) if 2 after one

        A 2,1,4,3,2                   B. 3,4,1,2,2                  C. 1,4,3,2,2                  D. 1,2,4,3,2


3. Output of the following program: main() (Unsigned int a-Oxffff, 'a, printf(x,a);


        A. 00ff              B. 0000                    C. ddfd             D. ffff


4. Output of the following program: main() { int i-0, if(-0) { printf(hello).continue, ))


        A hello is printed infinite times                      B. compile time error

        C. hello                                                            D. varies


5 .Output of the following program main() (int i-0, switch() (case 0: case 0 printf(hi), ))


        A. run time error                     B.haihi             C. compile error      D.hi


6. Output of the following program typedef struct (int A; char B, char C, )info, main( printf("%d,sizeof(info)), )


        A 10                 B.8                 C 12                D. 14


7. Output of the following program #include<stdio.h> int main() (int a-10,b-20,c-30, if(c>b>a) printf(true), else printf(false), return 0;)

        A 1/0    B. Compiler error                   C. True                        D. False 


8. Output of the following program: main() (int a[5], printf("%u,&a+1), )


        A 2022             B. 2004                        C 2040             D. 2020


9. Output of the following program: main()( printf("%c.5[Geeks Quez]).)


A compile time error              B. S                  C runtime error          D. Q

10 Output of the following program main()( char *s-Geeks Quiz, int n-7,printf("%. *s,n.), ) 

    A. nothing printed B. Geeks Q    C. Geeks Qu D. Geeks Quiz

11. Output of the following program: float i-2.0; float j-1.0, float sum-0.0, main while(/j>0.001) (j+j, sum-sum+(1); printf("%fin, sum).)) 


        A. 9.        B. 10    C. 8       D. 11


12. S1 Promotion occurs if the right expression has lower rank. S2 Demotion occurs if right expression has higher rank

A. S2 is true &S1 is false         B. only $1        C. both S1&S2 are true ✓     D. SI is true & $2 is false


13. Which of following operator connects structure none to its member none?.

            A . -                   B.*      C. +      D. .


14. Output of the following program: union test (int x, char arr[4], int y.), int main( (union test 1; 1 x-0, tarr[1]-G, printf("%s,tarr);) Assume, size of (char)-1 sizeof(int)-4 


        A. G     B garbage value            C. nothing printed            D. error


15 Output of following #include<stdio.h> int var-20, int main() (int var var, printf("%d,var); return 0,)

        A 0       B 20     C. Compile error      D. Garbage value


16. How many times will the following for loop run? for(int -1;i<10;i++)()


        A. 11        B.8            C. 9         D. 10

 

1. Output of the following program include<stdio.h> Int main() (typedef static int *, int j, ia&j, printf(“%d, “a); return 0,)


        A.D      B garbage value          C. runtime error         D. compile error


2_bool datatype is defined in______ header file

        A stdio.h           B. stdbool .h             C. stdin .h                    D. stdtrue/stdfalse h


3. int main(int 1=1024; for(>>=1) printi(ha), ) How many times hi is printed?

        A infinite          B. 10    C. 11✓             D. 0


4 languages uses symbols, or mnemonics, to represent the various machine language instructions


    A High-level     B. Machine      C. Compilation            D. Assembly


5. Output of the following program: main() (unsigned int i-65000, while(i++1=0); print%d.), return 0;)

       

     A. 1✓               B. run time error                     C. 0      D. infinite loop


6. Twos complement of a number x is

     A x        B. x-1         C. x+1                       D. x+0.1


7 Output of the following program typedef struct (int A, char B, char C. )info, main(){ printf(d,sizeof(info));)


    A. 12                B. 8               C. 14                D. 10


8. Output of the following program: #include<stdio.h> int main() (int i=3, print%d(++)++), return 0,)

    A 3                   B. 4                  C. 5✓               D. compile time error

9 Output of the following program: main() (int c[5], a++//assume address of a is 2000,sizeof integer is        32 bit printf(“%u,a); )

        A 2004             B 2002             C. Lvalue required✓               D. 2020


10. Output of following #include<stdio.h> int var-20, int main() (int var var. printf(“%d,var), return 0,)

        

            A .0                  B. Compile error                     C. Garbage value                 D. 20


11. Explicit type conversion uses a______operator

        A typechecking                         B. typecast                 C.sizeof            D. typeof


1. Output of the following program main()( typedef struct tag( char s[10], int a ) har, har

h1,h2-(IHelp, 10), hl-h2, hl. Str[1]-h; printf(“%s %d,hl str.hl.a).)

                A ERROR

                B. Ihelp, 10

                C.IHelp.0 

                D. IHelp,10

2. An array is a

        A collection of values of same datatype

        B.   collection of values of different datatype

        C.   collection of same values

        D.  collection/not a collection

3. Output of the following program #include<stdio.h> int main() ( register int -10, int “ptri, printf(“%d,”ptr); return 0,)  

        A. prints 10 on all compilers

        B. prints 0 on all compilers 

        C. may generate compiler error

        D. may generate runtime error


4. Output of the following program: main() (int i-0, if(-0) (printf(hello). Continue, )) 

            A hello 

            B.   varies

            C.   hello is printed infinite times

            D.  compile time error

5.  Output of the following program main (int loop-10,while(printf(hello)&&loop-);)

        A hello hello (infinite times)

        B. hello hello (10 times) 

        C hello hello. (11 times)

        D. hello

6. Output of the following program typedef struct (int A, char B, char C. )info, main(){ printf(“%d,sizeof(info)), )

A 10

B. 8

C. 14

 D. 12

7. What loop requires only braces?

A repeat

B.   for

C.   do

D.  while

8. sprintf( ) is a____ function

A many to one

B.   many to many

C.   one to one

D.  one to many

9. Bitwise can be used to reverse a sign of number.

A. Yes 

B. No

C Need extra information.

 D. Maybe 

10. Output of the following program main() (int a-1,6-0, ba+++++; printf%d%d,a,b), )

A.   compiler dependent

B.   33.

C.   34

D.  36

 

11. Which of the following is correct with respect to jump statements in c?

A.   break

B.   return

C.   continue 

D.  all


12. Which of the following for down given scanf() is true? Scanf(%4s,str),


A.   reads minimum 4 characters

B.   reads exactly 4 characters

C.   reads nothing

D.  reads multiples of 4 characters

13. Getting the program into memory is the function of an operating system program known as the

A.   Linker

B.   Loader

C.   Compiler

D.  Text-editor

1. Loops are required for

A simplicity 

B.   no use

C.   repetition of blocks any no of times

D.  cant say


2. Function to rename a string?

A.   strrev

B.   strstr

C.   revstr

D.  strreverse()

3. Output of the following program union test (int x, char arr[4], int y.), int main()(union

test t, 1-0, tarr[1]-G, printf(“%star), ) Assume, size of (char)-1 sizeof(int)==4

        

A error

B.G

C.   garbage value

D.  nothing printed


4. Output of the following program main( printf(“%c.5[Geeks Quiz]), )

A. runtime error 

B  .compile time error

C  .Q

D. S


8. The_____ operator can be used to turn masked bit off


A. &

B.^

C.’

D. I

9. A _______ is a constant that allows a portion of memory to be shared by different  types of data

A.  field

B.  struct 

C .union

D. array

10. It is______ error to use a variable before it has been assigned a value

A .compile time

B.   runtime 

C.   logic

D.  No error


11. Output of the following program main (int i=0, switch() ( case 0: case 0:printf(hi);)) 

A. hihi

B. run time error 

C. compile error

D. hi

12. Which of the following performs division by 22

A <<

B. >>

C.|| 

D. ^

13. Output of the following program #include<stdio.h> int main() ( int a-10,b-20,c-30, if(c>b>a) printf(true); else printf(false); return 0.)

A.  True

B.  Compiler error

C.  False

D. 1/0


14. What is order of execution of given for loop? For(1,2,3) (4) if 2 after one iteration becomes false 

A 3,4,1,2,2

B. 2,1,4,3,2 

C 1,2,4,3,2

D 1,4,3,2,2

1. Output of the following program main() (unsigned int -65000, while(i++1=0); printf), return 0,)

A.   0

B.   run time error

C.   I

D.  infinite loop


2 Output of the following program main() { int i-0, if(-0) ( printf(hello), continue, )) 


A hello  

B.   compile time error

C.   hello is printed infinite times

D.  varies

3. Output of the following program main() (int i=0, switch(t) ( case 0: case @printf(hi), )) 

A. hihi

B.hi

C.   compile error

D.  run time error

4. Primary Storage is also known as

A Secondary Memory

B.  Cache Memory

C.  Main Memory

D Auxiliary Memory

5. Output of the following program #include<stdio.h> int main() (int-3; printf%d(++)++); return 0;)

A  4

B  .compile time error

C.   3

D.  5


6. A compound statement


A block

B.   composite statement 

C.   complex statements

D.  body

7. Output of the following program: #include<stdio h> int main() (register inti-10, int “ptr&I, printf(d,”ptr), return 0,)

A .may generate runtime error

B. prints 0 on all compilers  

C. may generate compiler error

D. prints 10 on all compilers


10. Output of the following program: main( typedef auto int a-10, printf(“%d,a), )


A error

B.   a

C.   100

D.  10

11. The case label in switch case is___expression

A.   static

B.   dynamic

C.   variable.

D.  contest


12. Output of the following program: main(( printf%c,5[Geeks Quiz]). )

A.Q

B .runtime error

C.   compile time error

D.  S


13. C allows the identifier length upto_characters long

A 31

B.   63

C.   32

D.  64


1. Output of the following program main() (Unsigned int a-0xffff, a. printf(x,a). 


A ddfd 

B. ffff

C.   00ff

D.  0000

2. Output of the following program int I, main() (ift), else printfielse), return 0;)

A.   if block executed

B.   else block executed

C.   run time error

D.  compile time error

3. Output of the following program: main()( typedef struct tag( char s[10], int a, )har, har

hl,h2-(IHeip, 10); hl-h2, hl. Str[1]-h, printf(“%s %d,hl str.hl.a)

A Thelp, 10

B.   IHelp,0

C.   IHelp,101

D.  ERROR


4. Output of the following program: main(( print%d,printf(Hello)); ) 


A. Hello 16

B.   Hello 4

C.   Hello Hello

D.  Hello 8

5. C allows the identifier length upto__characters long

 A 32

B.   31

C.   64

D.  63


6. Output of the following program typedef struct (int A, char B. char C. )info, Main()( printf(“%d,sizeof(info)), )


A .8

B.   10

C.   12

D.  14


7. Output of the following program main()( printf(“%c,5[Geeks Quiz]);)

A compile time error

B.   Q

C.   runtime error

D.  S


8. In C, the ampersand is also called____ Operator 


A.indirection.

B.   unidirection

C.   inaddress

D.  address


9. How many times will the following for loop run? For mnt 1;<10;++)()

         A 9                     B. 11 

         C. 10.

         D. 8

10. Output of the following program: include<stdio.h> int main() (int x>5, int *const ptr&x, ++(“ptr); printf(“%d, x), return 0; )

A 5 

B.   6

C.   comple error

D.  runtime error

11. Output of the following program #include<stdio.h> int main() { printf%d,sizeof(printf(“%d,7))).) Assume size of integer is 4 bytes

A  .74

B  .47

C.4

D.7

1. A is a constant that allows a portion of memory to be shared by different types of data 

A.struct

B.   array

C.   field

D.  union

2 Output of following #include<stdio.h> int var-20, int main() (int var var, printf%d,var); return 0,)

A.  20

B.  Compile error

C.0

D. Garbage value

3. sprintf) is a  ____ function

A one to many 

B.   one to one

C.   many one

D.  many to many

4. What are the 3 types of looping structures?

A infinite,count nested

B. while, for do

C count up.count down, infinite 

D. count, sentinental-controlled,rerult controlled

5. Output of the following program: #include<stdio.h> int main() (int x>5, int *const ptr&x, ++(*ptr), printf("%d, x); return 0;)

A.   runtime error

B.   6

C.   5

D.  compile error

6. If divisions of decimals are involved in a program, these numbers are stored in

A.   Original Numbers

B.   Irrational Numbers

C.   Rational Numbers

D.  Real Numbers

7._____  doesnt need any semi colon associated with it

A  .return

B  .expression

C. null

D compound


8. Char a[100][100], Assuming that main memory is byte addressable, array is stored starting from memory address 0,address of a[40] [50] is

A  4050

B  5040

 C 5050

D. 4040


9. Output of the following program #include<stdio.h> int main(){ printf%d, sizeof(printf("%d.7)))) Assume size of integer is 4 bytes


A 4

B.  74

C.  47 

D. 7

10. struct( short s[5], union( float y, long z, Ju; )t, Assume that object of type short, float & long occupy 2 bytes,4 bytes,8 bytes respectively Memory of tis

A 18B

B. 22B

C 14B

D. 10B


11. One's complement can be performed by using

A.'

B.&. 

C. I

D. ^

1. Scanf requires___ addresses I the address list

A  high level

B  constant

C. variable 

D. low level

2. Output of the following program typedef struct ( mnt. A, char B; char C. )info. Main()(printf(d,sizeof(info)).)

A.   10

B.   12

C.   8

D.  14

3. Output of the following program: main()( union v( int I, char c[2]: ), Union v val; val: c[0]-A, vai c[1]-B, printf%c, %c %d,val c[0],val c[1].vali), )

A AB,16961

B.   B.B.66.

C.   A,B,32

D.  A.B.0

4. Output of the following program: main(( printf(5+ Geeks Quiz); )

A Error 

B.   Geeks Quiz

C.   Quiz

D.  1005


5. Output of the following program: main( (int a-1,6-0, b+++++; printf%d%d,a,b);) 


A 36

B.   34

C.   compiler dependent

D.  33

7. sprintf() is a______ function

A.  one to one

B.  many to many 

C. many to one

D. one to many

8. Output of the following program: main() { int i-0-0; while(<5j<10) (++I;j++) printf(“%d,”%d,1)); )

A 510

B.   syntax error

C.   55

D.  10 10

9. Which of the following has highest conversion rank?

A long long  

B. long double

C char

 D. long

10. Output of the following program #include<stdio.h> Int main() (typedef static int *, intj, I a- &j, printf(“%d, “a); return 0,)

A garbage value

B. runtime error 

C. compile error

D.0


11.Array is_____ a datatype


A.   Derived

B.   Basic, Derived

C.   Primitive

D.  Basic

12. Which of following is not a character classification in c language?

A ASCII

B. digit C. control.

D graphical

13. By default a floating constant is of_____ data type header file.

A. long 

B. long double

C.   float

D.  double


14. Output of the following program for(0,1<4;i++) printf(“%d,i&1),

A 0000

 B. 0101

C.1111

D. 1010


1. Getting the program into memory known as the the function of an operating system program 


A. Linker 

B.   Loader

C.   Compiler

D.  Text-editor

2. Output of the following program union test (int x, char arr[4], int y.); int main() (uniontest t, t.x-0, Larr[1]-G, printf(“%s,tarr), ) Assume, size of (char)-1 sizeof(int)=4 

A nothing printed

B.   error

C.   G

D.  garbage value


3. How will you print \n on screen? 


A .print(\n),

B.  print\\n).

C.  print(\n), 

D. echo in,

4. Output of the following program typedef struct (int A, char B, char C, )info; main( print%d,sizeof(info)); }

A 12 

B.   8

C.   14

D.  10


5. What is order of execution of given for loop? For(1:2,3) (4) if 2 after one iteration becomes false 


A 1,4,3,2,2

B. 1,2,4,3,2

C 3,4,1,2,2

D. 2,1,4,3,2

6. Output of the following program: #include<stdio.h> int main() { int I; -1,2,3; Printf(“%d.), )

A 2

B.   3

C.   error

D.  1

7. int main() (int -1024; for(;I;i>>-1) printf(hi);) How many times hi printed?

A .11

B.  infinite

C.  10

D.0

8. Output of the following program main() (int i=0, switch(1) (case 0: case 0 printf(hi);)) 


A .run time error

B.   hihi

C.   hi

D.  compile error

9. Consider the following two C lines 1: int var1, 2: extern int var?, Which of the following statements is correct?

A.   1 defines & declares varl,but second statement only declares var2

B.   both statements declare define vanables varl &var2 

C.   both statements only declare variables and don’t define them

D.  2 defines & declares var2,but 1 only declares var 11

10. Char a[100] [100], Assuming that main memory is byte addressable, array is stored Starting from memory address 0,address of a[40][50] is

A 4050

B.   5040

C.   4040

D.  5050

11. Output of the following program: main() (char p; char buff[10]-(1,2,3,4,5,6,9,8). Pbuf+1)[5], printf(“%d/n.p), )

A.  9

B.  5

C .none

D. 6

1. How will you print \n on screen?

A .echo in

B. print(\\n).

C.print(\n).

 D. print(\n),

2. Output of the following program: main( printf(5+ GeeksQuiz); )

A.   1005

B.   Quiz

C.   Error

D.  Geeks Quiz

3. Output of the following program #include<stdio.h> Int main() (typedef static int*I, int j. I a=&j. printf(“%d, “a ); return 0; }

A.garbage value

B.  0

C.  runtime error 

D. compile error


4. Output of the following program main() (int a[5], printf(“%u,&a+1); }

A.   2020

B.   2022

C.   2040

D.  2004

5. It is_____ error to use a variable before it has been assigned a value

A.   runtime

B.   No error

C.   compile time

D.  logic

6. A negative number x is stored in memory as

A -x

B. ¹-1  

C.+01

D. x+1


7. _______ is responsible for executing instructions such as arithmetic calculations,comparisons among data and movement of data inside the system.

A.   CPU

B.   Input Devices

C.   Auxiliary Storage Devices

D.  Output Devices


8. How many times will the following for loop run? For(int i=1;i<10;i++)( ) 


A. 10

B.   8

C.   11

D.  9

9. Output of the following program union test (int x, char arr[4]; int y.); int main() (union

test t, tx-0, tarr[1] G, printf(“%s,tarr),) Assume, size of (char)=1 sizeof(int) 4

A.   garbage value

B.   G

C.   error

D.  nothing printed


10. A_____  is a constant that allows a portion of memory to be shared by different types of data 


A. array

B.  struct

C.  union 

D. field

11. Output of the following program #include<stdio.h> int main() { int a-10,b-20,c-30; if(c>b>a) printf(true); else printf(false); return 0; )

A.   False

B.   True

C.   1/0

D.  Compiler error


1. int main() (inti-1024, for(-1) printf(hi), ) How many times hi is printed? 


A 0

 B. 10

C infinate

D. 11

2. Output of the following program for(i=0;i<4j++) printfdi&1),

A 0000

B.   0101

C.   1010

D.  1111


3. Number of bytes in memory taken by below structure? Struct test( int k, char c; );


A.  integer size + character size

B.  multiple of wordsize

C: integer size multiple

D. platform dependent

4. Output of the following program #include<stdio.h> int main() (register int -10, int *ptr&I; printf(“%d, *ptr); return 0,)

A. prints 0 on all compilers  

B. may generate compiler error

C.   may generate runtime error

D.  prints 10 on all compilers


5. struct( short s[5], union( float y, long z, ju, )t, Assume that object of type short, Float & long occupy 2 bytes,4 bytes,8 bytes respectively Memory oft is


A 18B

B.   22B

C.   14B

D.  10B

6. Output of the following program #include<stdio.h> int main() (int i=(1,2,3). Printf(“%d,i), return 0,)

A 2

B.   1

C.   garbage value

D.  3

 

7. C allows the identifier length upto characters long

A.   63

B.   31

C.   32

D.  64

8. The integral data types of C can be further divided into categories

A 4

B. 3

C.5 

D. 2


9. int main() (int-1024, for(ii>>=1) printf(hi), ) How many times hi is printed? 


A 0 

B  infinite

C  10

D. 11

10. Output of the following program: float 2.0, float j-1.0; float sum-0.0, main() (

while(0.001) (jj, sum-sum+(); printf(“%fin, sum);))

        A. 10             B.9         C. 11         D. 8


11. Output of the following program #include<stdio.h> int main() { printf(“%d,sizeof printf%d,7))); ) Assume size of integer is 4 bytes


        A. 4               B. 47                C. 7                  D. 74


12. Output of the following program #include<stdio.h> int main() { int x>5, int *const ptr&x, ++(*ptr), printf(“%d, x), return 0,)

        

        A .compile error                      B. 5           C. 6     D.runtime error


13. Output of the following program: #inchade<stdio.h> int main() (int x>5, int “const ptr&x, ++(“ptr), printf%d, x), return 0,)


A compile error                       B. 5               C. 6      D. runtime error


14. Output of the following program, union test (int x, char arr[4], int y.), int main() (union test 1, 1-0, tarr[1]-G, printf%s,t arr), ) Assume, size of (char)=1 sizeof(int) 4 

A .error            B.G      C. nothing printed     D. garbage value

15. How many times is a do while loop guaranteed to loop 

A infinitely B. 0             C. cant say       D. I

16.______ languages uses symbols, or mnemonics, to represent the various machine language instructions as delimiter.

A. High-level B. Machine        C. Compilation         D. Assembly


17. Internally a string is stored having

A \2                  B. \1                C. \0                D. \n


18. Output of the following program: main() (printf(x,-1>>1), return 0,)

A fff0            B f0ff                C.0fff         D. ffff


19.  Output of the following program typedef struct (int A; char B, char C. ) info; main() { printf%d,sizeof(info)), ) 


    A. 8        B. 14    C. 10 D. 12



20.  Output of following #include<stdio.h> int var-20, int main() { int var var.printf(“%d,var); return 0, ). 

            A. 0                                            B. 20

            C. Garbage value                 D. Compile error


1. Output of the following program: main() (int i-0, if(-0) (printf(hello).continue, ))


A .compile time error         B. hello is printed infinite times

C. hello            D. varies


2. C allows the identifier length upto characters long 

        A. 64          B. 63         C. 31         D. 32


3.  If only one memory location is to be reserved for a class variable, no matter how many objects are instantiated, then the variable should be declared as 

    A extern           B. static        C. volatile        D. const


4.  Which of the following is not derived type?

A enumerated             B. float         C. arrays          D. pointers 


5. Which of following statement about pretest loop is true?

    A.   If pretest loop limit test is false, the loop executes one more time.

    B.   Pretest loop initialization is done first in body.

    C.   Pretest loops execute a minimum for one time.

    D.  The update for pretest loop must be part of loop body.


6. Output of the following program: #include<stdio.h> int main() (int(1,2,3), printf(“%d,i), return 0,)

A. 1       B. 3         C. garbage value          D. 2


7. Output of the following program: main() (Unsigned int a-Oxffff, ‘a; printf(%x,a);

A. ddfd             B. 00ff             C. 0000         D. ffff


8. How many times will the following for loop run? For(int i=1;i<10;i++)()

A 10                 B.9                C. 8      D. 11


9. Output of the following program main) (char p. char buf[10]-(1,2,3,4,5,6,9,8); pe(buf+1)[5], printf(“%d/n,p), )

A. none            B 6       C. 5      D .9

10. Structure is a

A collection of elements of different datatype

B.   collection of elements with same value

C.   collection of elements/only a element

D.  collection of elements of only same data types


11. The library function used to find last occurrence of character in string is


A. strnchr()        B. strstr           C. strnstr         D. laststr 


12. Which header file you need to include to use typecasting?

A stdio.h          B. ctype h                 C. math h        D. string h


6.________ statement doesn’t need any semi colon associated with it 


A .compound              B. return         C expression  D. null


7. In C static storage class cannot be used with


A Function parameter          B. Function name

C. Local variable                     D. Global variable



8. Output of following include<stdio.h> int var-20, int main() (int var-var,print%d, var), return 0,)

A .0                  B. 20                C. Compile error         D. Garbage value.


9 Output of the following program for(-0,1<4;i++) printf&1),

A .1111            B. 0101                     C. 0000            D. 1010



10._______ is responsible for executing instructions such as arithmetic calculations, comparisons among data and movement of data inside the system

A. Auxiliary Storage Devices  B. CPU           C. Input Devices          D. Output Devices

11. Two way selection is implemented with_____ Statement

A. else if          B. switch                      C.ifelse         D. case


12. Which of the following for down given scanf() is true? Scanf(“E,str),

A. reads exactly 4 characters             B. reads minimum 4 characters

C. reads nothing                                  D. reads multiples of 4 characters


13. struct( short s[5], union( float y, long z, Ju, )t, Assume that object of type short, float & long occupy 2 bytes,4 bytes,8 bytes respectively Memory oft is

A. 14B              B. 10B              C 18B                        D. 22B


19. Output of the following program #include<stdio.h> int main() (int i-(1,2,3), printf%d,a), return 0,)

A. 2       B .3              C. 1      D. garbage value



20. int main() (inti-1024, forti>>-1) printf(hi). ) How many times hi is printed?


A .0      B. 11             C. infinite        D. 10

1. Which of the following can be efficiently used with less no of tokens to read input? A. for, while B. for C. repeat   D. while

21. Conversion specification given in printf() is of the format

A %Minwidth Flag Precision code size            B. %Code Precision Flag

C. %Precision Minwidth Flag code                   D. %Flag Minwidth Precision size code


22. Output of the following program: main() (int a[5], printf(“%u,a+1), )


A. 2004                     B. 2020            C. 2002                        D. Lvalue required


23. Output of the following program: union test (int x, char arr[4], int y, ); int main() (union test 1, 1-0, tarr[1] G, printf(“%s,t arr); ) Assume, size of (char)-1sizeof(int)-4


A. nothing printed                   B.G      C error        D.garbage value


24. Output of the following program: main(){ printf(5+ GeeksQuiz), )


A Geeks Quiz B 1005  C. Error            D. Quiz


25. Output of the following program main() (int a-1,b-0, ba+++++, printf(“%d ,b);) 

A compiler dependent       B. 36    C. 33  D. 34


26. Output of the following program float i-2.0, float j-1.0, float sum-0.0, main() { while(0.001) (j+j, sum-zum+(); printf(“%fn,sum), ))

A 11 B. 8       C 10     D. 9


27. If only one memory location is to be reserved for a class variable no matter how many objects are instantiated, then the variable should be declared as

A const             B. volatile        C. extern         D. static


28.  Which of the following performs division by 27 

A.^    B. >> C. II       D. <<


29.  How will you print in on screen?

A echo In                     B. print(\n);     C. print(\\n).             D. print(n);


17. (1101)2=(?)10

A 26                 B. 15    C. 3      D. 13

18. Output of the following program: main() (int i=0; if(-0) (printf(hello), continue;))

A hello is printed infinite times          B. hello

C. varies                                  D. compile time error


netaji gandi Monday, December 12, 2022
JNTUK- A.Y 2022-23 PROGRAMMING FOR PROBLEM SOLVING USING C LAB

 

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

JNTUK-A.Y. 2022-23




PROGRAMMING FOR PROBLEM SOLVING USING C LAB

Course Objectives:

1) Apply the principles of C language in problem solving.
2) To design flowcharts, algorithms and knowing how to debug programs.
3) To design & develop of C programs using arrays, strings pointers &functions.
4) To review the file operations, preprocess or commands
 
Exercise 1:
         1. Write a C program to print a block F using hash (#), where the F 
              has a height of six characters and width of five and four characters.   Program
         2. Write a C program to compute the perimeter and area of a rectangle
              with a height of 7 inches and width of 5inches.     
Program
         3. Write a C program to display multiple variables.  
 Program

Exercise 2:
         1. Write a C program to calculate the distance between the two points.     Program
         2. Write a C program that accepts 4 integers p, q, r, s from the user where
              r and s are positive and p is even. If q is greater than r and s is greater       Program
              than p and if the sum of r and s is greater than the sum of p and q print
              "Correct values", otherwise print "Wrong values".


Exercise 3:
          1. Write a C program to convert a string to along integer.              Program
          2. Write a program in C which is a Menu-Driven Program to compute
               the area of the various geometrical shape.                                    Program

          3. Write a C program to calculate the factorial of a given number.          Program


Exercise 4:
          1. Write a program in C to display the n terms of even natural number and their sum.     Program
          2. Write a program in C to display the n terms of harmonic series
               and their sum. 1 + 1/2 + 1/3 + 1/4 + 1/5 ... 1/n terms.   
Program
          3. Write a C program to check whether a given number is an Armstrong number or not.

Exercise 5:
         1. Write a program in C to print all unique elements in an array.  Program
         2. Write a program in C to separate odd and even integers in separate arrays.   Program
         3. Write a program in C to sort elements of array in ascending order.   
Program

Exercise 6:
         1. Write a program in C for multiplication of two square Matrices.  Program
         2. Write a program in C to find transpose of a given matrix.  Program

Exercise 7:
        1. Write a program in C to search an element in a row wise and   
           column wise sorted matrix.   
Program
        2. Write a program in C to print individual characters of string in reverse order.  
Program

Exercise 8:
      1. Write a program in C to compare two strings without using string
          library functions.     
Program
      2. Write a program in C to copy one string to another string.   
Program

Exercise 9:
       1. Write a C Program to Store Information Using Structures with
           Dynamically Memory Allocation.    Program
       2. Write a program in C to demonstrate how to handle the pointers in the program.   Program

Exercise 10:
       1. Write a program in C to demonstrate the use of & (address of) and
          *(value at address)operator.   
Program
       2.write a program in C to add two numbers using pointers.   
Program

Exercise 11:
       1. Write a program in C to add numbers using call by reference.   Program
       2. Write a program in C to find the largest element using
            Dynamic Memory Allocation.        
Program

Exercise 12:
      1. Write a program in C to swap elements using call by reference.    Program
      2. Write a program in C to count the number of vowels and
          consonants in a string using a pointer.      
Program

Exercise 13:
      1. Write a program in C to show how a function returning pointer.     Program
      2. Write a C program to find sum of n elements entered by user. To
           perform this program, allocate memory dynamically using
           malloc()function.       
Program

Exercise 14:
     1. Write a C program to find sum of n elements entered by user. To
         perform this program, allocate memory dynamically using calloc( )
         function. Understand the difference between the above two programs.    
Program
     2. Write a program in C to convert decimal number to binary number
         using the function.   
Program

Exercise 15:
     1. Write a program in C to check whether a number is a prime number
         or not using the function.    
Program
     2. Write a program in C to get the largest element of an array using the function.   
Program

Exercise 16:
     1. Write a program in C to append multiple lines at the end of a text file.   Program
     2. Write a program in C to copy a file in another name.   Program
     3. Write a program in C to remove a file from the disk.   
Program


Course Outcomes:
     By the end of the Lab, the student
       1) Gains Knowledge on various concepts of a C language.
       2) Able to draw flowcharts and write algorithms.
       3) Able design and development of C problem solving skills.
       4) Able to design and develop modular programming skills.
       5) Able to trace and debug a program.


netaji gandi Monday, October 31, 2022
JNTUK A.Y 2022-23 PROGRAMMING FOR PROBLEM SOLVING USING C

 

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

 JNTUK-ECE- A.Y-2022-23

PROGRAMMING FOR PROBLEM SOLVING USING C


COURSE OBJECTIVES:

The objectives of Programming for Problem Solving Using C are

  • To learn about the computer systems, computing environments, developing of a computer program and Structure of a C Program.
  • To gain knowledge of the operators, selection, control statements and repetition in C
  • To learn about the design concepts of arrays, strings, enumerated structure and union types. To learn about their usage.
  • To assimilate about pointers, dynamic memory allocation and know the significance of Preprocessor.
  • To assimilate about File I/O and significance of functions
COURSE OUTCOMES:

On completion of this course students will be able to

S.NO.Course OutcomeKnowledge Level
CO1Describe the fundamentals of computers and comprehend the problem-solving component.Understand Level
CO2Demonstrate algorithm for the provided problem and draw flow chart.Understand Level
CO3Design and develop C program to evaluate simple expressions and logical operations.Application Level
CO4Implement C programs with suitable data types using arrays , strings and function concepts to solve the given problem.Application Level
CO5Demonstrate the concept of a pointer, file and execute I/O operationsApplication Level

SYLLABUS:

UNIT I

Introduction to Computers: Creating and running Programs, Computer Numbering System, Storing Integers, Storing Real Numbers

Introduction to the C Language: Background, C Programs, Identifiers, Types, Variable, Constants, Input/output, Programming Examples, Scope, Storage Classes and Type Qualifiers.

Structure of a C Program: Expressions Precedence and Associativity, Side Effects, Evaluating Expressions, Type Conversion Statements, Simple Programs, Command Line Arguments.



UNIT II

Bitwise Operators: Exact Size Integer Types, Logical Bitwise Operators, Shift Operators.

Selection & Making Decisions: Logical Data and Operators, Two Way Selection, Multiway Selection, More Standard Functions

Repetition: Concept of Loop, Pretest and Post-test Loops, Initialization and Updating, Event and Counter Controlled Loops, Loops in C, Other Statements Related to Looping, Looping Applications, Programming Examples


                                                                           UNIT III

Arrays: Concepts, Using Array in C, Array Application, Two Dimensional Arrays, Multidimensional Arrays, Programming ExampleCalculate Averages

Strings: String Concepts, C String, String Input / Output Functions, Arrays of Strings, String Manipulation Functions String/ Data Conversion, A Programming Example –Morse Code

Enumerated, Structure, and Union: The Type Definition (Type-def), Enumerated Types, Structure, Unions, and Programming Application


UNIT IV

Pointers: Introduction, Pointers to pointers, Compatibility, L value and R value

Pointer Applications: Arrays and Pointers, Pointer Arithmetic and Arrays, Memory Allocation Function, Array of Pointers, Programming Application

Processor Commands: Processor Commands


UNIT V

Functions: Designing, Structured Programs, Function in C, User Defined Functions, Inter- Function Communication, Standard Functions, Passing Array to Functions, Passing Pointers to Functions, Recursion

Text Input / Output: Files, Streams, Standard Library Input / Output Functions, Formatting Input / Output Functions, Character Input / Output Functions

Binary Input / Output: Text versus Binary Streams, Standard Library, Functions for Files, Converting File Type.


TEXT BOOKS:
  1. Programming for Problem Solving, Behrouz A. Forouzan, Richard F. Gilberg , CENGAGE
  2. The C Programming Language, Brian W. Kernighan, Dennis M. Ritchie,2e,Pearson
REFERENCES:
  1.  Computer Fundamentals and Programming, Sumithabha Das, McGrawHill
  2.  Programming in C, Ashok N. Kamthane,  AmitKamthane, Pearson
  3.  Computer Fundamentals and Programming in C, PradipDey, ManasGhosh,OXFORD


netaji gandi

OBJECT ORIENTED PROGRAMMING USING JAVA LAB

Java Programming Lab Experiments VR-23 2025-26 Java Programming Lab Experiments Experiment 1: Fibonacci Sequence The F...