Monday, December 25, 2017

Finding string in another string

# include <stdio.h>
# include <conio.h>
# include <string.h>
main(){     /* finding fstr in str */
char str[]="i love c , i love cpp  and i love java";
char fstr[]="love";
int i,j,k,L,flag=0;
clrscr();
for(L=0;str[L]!=0;L++);   /* finding length */

for(i=0;i<L;i++)
{
for(k=0,j=i;fstr[k]!=0;k++,j++)
{
if(str[j]!=fstr[k])
break;
}
if(k==strlen(fstr))
printf("\n'%s' found at %d",fstr,i+1,flag++);
}
if(flag==0)
printf("\nNot found");
else
printf("\n'%s' Found %d times",fstr,flag);

}








Saturday, December 16, 2017

Context On 2D Array - c Programming : hackerrank problem




Friday, December 15, 2017

TECHNICAL TEST-2 3rd cse crt-1 & crt-2 Dt 15-12-2017

TECHNICAL TEST-2                                                          
NAME:_____________________Branch________
Roll Number____________                     
1.
void main()
{
 int i =0;
for( ; i<=2; )
 printf(“%d”,++i);
}
a.0 1 2                         b.0 1 2 3
c.1 2 3                         d. 1 2  
2.
void main()
{
int x=6,y=3;
x/=x/y;
printf(“%d”,x);
}
a.6                   b.2
c.3                   d.0
3.void main()
{
  int a,b;
  a=1,3,5;
  b=(2,4,6);
  printf(“\n%d”,a+b);
}
a.3       b.7       c.21     d. 17
4.void main()
  {
   int a=25;
   clrscr();
   printf(“%o %x”,a,a);
  }
a.      25  25  b.025  0x25
b.      12  42 d.31   19
5.void main(){
      int a=5,b=10,c=1;
      if(a&&b>c){
          printf("RISE");
      }
     else{
         break;  }}
a.RISE                             b)it will print nothing
c)Compilation error     d)none

6. void main(){
    int a=100;
    if(a>10)
         printf("CIVIL");
    else if(a>20)
         printf("EEE");
    else if(a>30)
           printf("CSE");
}
a.CIVIL                                  b.EEE
c.CIVIL EEE CSE                  d.CSE
7. void main(){
    int m=5,n=10,q=20;
    if(q/n*m)
         printf("William Gates");
    else
         printf(" Warren Buffet");
         printf(" Carlos Slim Helu");
}
a.William Gates               c.Runtime error
b.Warren Buffet Carlos Slim Helu d.Compilation error
e.None of the above
8.void main(){
    int a=10;
    if(printf("%d",a>=10)-10)
         for(;;)
             break;
    else;
}
Choose all that apply:
a. It will print nothing    b.0          c.1
D.Compilation error: misplaced else
9.int main()
{
    int i=5, j=-2, k=-3, m;
    m = i++ || ++j && ++k;
    printf("%d, %d, %d, %d\n", i, j, k, m);
    return 0;
}
A. 5, -2, -3, 0       B.            6, -1, -2, 0
C.6, -1, -2, 1        D.            6, - 2, -3, 1
10.int main()
{
int x=55;
printf("%d, %d, %d\n", x<=55, x=140, x>=10);
    return 0;}
1, 140, 1
1, 55, 1
1, 55, 0
0, 140, 1
11.void main()
{
  Int i=0;
  For(i=0;i<20;i++)
{
  switch(i){
default: i+=4;break;
case 0: i+=5;
case 1: i+=2;
case 5:i+=5;}
printf(“%d”,i);
}}            
a.12  17  22     b.0  5  9  13  17 c.16  21  d.5  9  13  17
12. void main()
  {
   int i=2;
   for(i=0;i++;printf(“%d”,i));
     printf(“%d”,i);
}
a.2          b.1          c.0          d.3

13.  void main()
{
int k=5^8;
printf(“%d”,k);
}
a.11        b.12       c.13        d.14
14.void main()
   {
 printf(“abcde\rABC”);
}
a.abcde                                b.ABC    c.ABCde               d.abcdeABC
15.void main()
 {
int  i=20;
do{
  printf(“%d”,++i);
}while(5,4,3,2,1,0);
}
a. 20       b.21       c.21 22  d.21 22 23 24 25
16.void main()
  {
  float a=6.60,b=3.30;
 printf(“%f”,a%b);
}
a. 0         b. 2         c. error d. none
17.void main()
{
 int i=9;
int a=5+8*6/3-2+i-- + --i;
printf(“%d”,i);
}
a.9     b.35            c.7          d.36

18. void main()
{
printf(“%d,%g,%g”,5/2,5.5/2,(float)5/2);
}
a. 2  2.75 2.5        b.2  2.75  2           c. 2  2.75  2 d.error
19.which of the following statement is wrong
1. 5+5=a;                              2.ss=12.25;
3.st=’m’*’b’;                      4.is=’a’+10;

a. 3,4                     b.1,3,4                  c.1          d.3

20.
# define N   >90
# define  M  >80
Void main()
{
int x=10,p;
p=x*5N;
p=p+90M;
printf(“%d”,p);
}
a.       0              b.90       c.80        d.1


21. Write a  Program for floyd’s triangle
                1
                2              3             
                4              5              6
                7              8              9              10
                11           12           13           14           15


             Ans:
1 c
2 c
3 b
4 d
5 c
6 a
7 e
8 a
9 d
10 d
11 a
12 b
13 c
14 c
15 b
16 c
17 c
18 a
19 c
20 d
                   

Thursday, December 7, 2017

RGAN TT sample test questions 08-12-2017

(1)What will be output of the following program?
#include<stdio.h>
int main(){
    float a=0.7;
    if(a<0.7){
         printf("C");
    }
    else{
         printf("C++");
    }
    return 0;
}
A)    C     B)C++    C)ERROR   D)NONE
(2)What will be output of the following program?
   
#include<stdio.h>
int main(){
    int I=5,j;
    j=++I + ++I + ++I;
    printf("%d ",j);
    return 0;
}
A)18   B)21   C)24    D)15
(3)What will be output of the following program?
#include<stdio.h>
int main()
{
    int i=1;
    i=2+2*i++;
    printf("%d",i);
    return 0;
}

A)4    B) 5      C)6    D)NONE
(4)What will be output of the following program?
#include<stdio.h>
int main(){
    int a=2,b=7,c=10;
    c=a==b;
    printf("%d",c);
    return 0;
}
A)1   B)0   C)10   D)2
(5)What will be output of the following program?
#include<stdio.h>
void main(){
    int x;
    x=10,20,30;
    printf("%d",x);
    return 0;}
A)10  B)20   C)30  D)60
(6)What will be output of the following program?
#include<stdio.h>
int main(){
    int a=0,b=10;
    if(a=0){
         printf("true");
    }
    else{
         printf("false");
    }
    return 0;
}
A)    true   B) false   C) syntax error   D)none
(7)What will be output of the following program?
#include<stdio.h>
int main(){
    int a;
    a=015 + 0x71 +5;
    printf("%d",a);
    return 0;
}
    A) 91   B)131    C)Syntax error  D)20 
 (8)What will be output of the following program?
#include<stdio.h>
int main(){
    printf("%d %d %d", sizeof(3.14),sizeof(3.14f),sizeof(3.14L));
    return 0;
}
A) 8  4  10   B)4  4  4   C) 8  8  4   D)4  4  10
(9)What will be output of the following program?
#include<stdio.h>
int main(){
    int x=100,y=20,z=5;
    printf("%d %d %d");
    return 0;
}
A)100 20  5 B)5  20  100  C) error  D)20 100  5
(10)What will be output of the following program?
#include<stdio.h>       
int main(){
    int a=2;
    a=a++ + ~++a;
    printf("%d",a);
    return 0;
}
A) 0   B)  1  C)-1   D) 2

(11)What will be output of the following program?

#include<stdio.h>
int main(){
    int a;
    a=sizeof(!5.6);
    printf("%d",a);
    return 0;
}
A) 2    B)4   C)8   D)10
12) What will be output when you will execute following c code?
#include<stdio.h>
void main(){
     int movie=1;
     switch(movie<<2+movie){
        default:printf("3 Idiots");
        case 4: printf(" Ghajini");
        case 5: printf(" Krrish");
        case 8: printf(" Race");
     }
}


A)3 Idiots Ghajini Krrish Race    
B) Race

C) Krrish     D) Ghajini Krrish Race
(13)What will be output of the following program?

#include<stdio.h>
int main(){
     int i=7;
     int j=++i + i++ + ++i;
     printf("%d",j);
     return 0;
}
A)  27  B)28   C)21  D)24
(14)    By default a real number is treated as a
    A.
Float       B.double  
C.
long double    D.far double  

  15 What will be output of the following program?
int main(){     
char f=255;
             f++;
    printf("%d",sizeof(f));
return 0;
}
 (a)1 (b)2  (c)4  (d)Compiler error

16. What will be output of the following program?
#define value 10\2
int main(){
printf("%d",value);
return 0;
}
(a)5  (b)20  (c)102 (d)Compiler error
(17) What will be output of the following program?
#define max 5
#define a max*max
#define value a\a
int main(){
    const int aa=5;
    printf("%d",value+aa);
return 0;
}

(a)5 (b)6  (c)10 (d)Compiler error
18. What will be output of the following program?
#include<stdio.h>
int main(){
    int a=2,b=7,c;
    c=a==b==0;
    printf("%d",c);
    return 0;
}
}
A)    0  B)  1   C) error   D) none
19.     Which of the following are unary operators in C?
1.    !
2.    sizeof
3.    ~
4.    &&

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

20.    Which bitwise operator is suitable for checking whether a particular bit is on or off?

A.&& operator    B.& operator
C.|| operator    D.! operator

/*  * C Program to Check if a given Bit Position is set to One or not */
#include <stdio.h>
void main()
{
    unsigned int number;
    int result, position;
     printf("Enter the unsigned integer:\n");
    scanf("%d", &number);
    printf("enter position to be searched\n");
    scanf("%d", &position);
    result = (number >> (position));
    if (result & 1)
        printf("TRUE\n");
    else
        printf("FALSE\n");  
}





TT TEST-1 (C-PROGRAMMING) RGAN FOR 3rd CSE

1)
main(){
printf("%d  %d   %d",sizeof(400L),sizeof(400)
,sizeof(400.0));
a)4 2 8     b)2  2 4      c)2 2 8     3)error

2)
char ch='xy';
val of ch is?
a)y         (b)x            c)none      d)NULL

3)
main()
{
int x;
x=10,20,30;
printf("%d",x);
}
a)30   b)20    c)10   d)error;
4)
main()
{
int a=117;
printf("%x",a);
}
a)75     b)117   c)error   d)0
5)
main(){
enum    bykes{suzuki,honda=3,hero};
printf("%d",suzuki+hero);
}
a)4       b)2       c)6     d)error
6)
Main()
{
int a=3,b=7,c;
c=a==b==1;
printf("%d",c);  
}
a)1           b)0        c)3      d)7
7)
#  define max (a,b)    a/b
Main() {
Printf(“\n%d”,max(10,3));
}
a)      3   b)3.333  c)3.333333  d)error


8) .what will be the output of the program?
#include<stdio.h>
int main()
{
    int k, num = 30;
    k = (num < 10) ? 100 : 200;
    printf("%d\n", num);
    return 0;
}
a)200    b)30    c)100     d)500

9).what are the invalid identifiers?
a.DOUBLE
b.Int
c.Float
d.all above


10) what will be the output of the program?
void  main()
{
int x;
x=015+0x71+5;
printf(“%d”,x);
}
a.13
b.131
c. compiler error
d.9

11). float f=10.3456F; int x=f;
 what was the value of x?
A.  10.3
B.  10
C.  10.345
D.  10.346

12)
int i=5;
int j;
j=++i + ++i + ++i;
printf("%d",j);
A.  21
B.  18
C.  24
D.  15

13).
int a=0,b=1;
if(a=0)
 { printf("\ntrue"); }
 else
 { printf("\nfalse"); }
A.  none
B.  true
C.  syntax error
D.  false
14)
printf(" %d %d %d",sizeof(3.14) , sizeof(3.14F), 
sizeof(3.14L));
A.  8 4 10
B.  4 4 4
C.  8 8 8
D.  4 4 10
9
15)which of the following are unary operators
 1. !     2. sizeof      3. ~        4. &&
A.  1,2
B.  1,3
C.  1,2,3
D.  2,4

16)char f=255; f++; printf("%d ",sizeof(f));
A.  2
B.  4
C.  compilation error
D.  1
17)
int a; a=sizeof(!5.6); printf("%d",a);
A.  2
B.  4
C.  10
D.  8
18)
void main()
{
            float x=10.2345F;
            int a;
            clrscr();
            a=x-(int)x;
            printf("\n%f",(float)a);
}
a)10.234500                b)0.000000                  c)error                         d)10.2345

19) 3.#include<stdio.h>
void main()
{
            int ch=NULL || EOF+1 && EOF ;
            clrscr();
            printf("%d",ch);
}
a)0       b)1       c)-1      d)48
20)
12. #include<stdio.h>
void main()
{
            int a=5^8;
            printf("%d",a*a);
}
a)13     b)169   c)-169  d)-13