Sunday, February 26, 2017

II nd CSE - I RPRA Work sheet....

work sheet on casting...
----------------------------------------
 1) Accept two integers and print sum,avg and
       difference.
main(){
int n1,n2,sum,diff;
float avg;
printf("\nEnter  two  integers?");
scanf("%d%d",&n1,&n2);
sum=n1+n2;
  printf("\nSum = %d",sum);
avg=(float)(n1+n2)/2;  /* explicit casting */
printf("\nAvg = %f",avg);
diff=fabs(n1-n2);
printf("\nDiff  = %f",fabs( (double)(n1-n2) )  );
}
 2)   Accept a floating point value and print only the
       dec part
    ex: -  i/p 10.345     o/p   0.345  only

main(){

float   fval , dec;
printf("\nEnter a float val ?");
scanf("%f",&fval);
dec=fval-(int)fval;
printf("\ndec part = %10.3f",dec);

}


  3)   accept   a 4 digit number only
        and test the number is
        4 digit number or   not?

int num;
int
printf("\nEnter  A  Number ?");
scanf("%d",&n1);
n1>=1000 && n1<=9999 ? printf("\n 4 digit number.."):
printf("\n not  a 4 digit number..");

work sheet if /nested if
---------------------------------------------------------------------
1) Swap two variable values with out using 3rd variable
2)Accept two integers and print absolute difference
    Hint: diffrence must be +ve (use abs() function )
3) Accept 4 digit year and print leap year or not
4)Accept 3 subject marks of student and print division
    >=70%   ---- distinction
    >=60%  ----- first
    >=50% ------ pass other wise fail
5) Accept a 4 digit number and print digit sum.
    Hint: use operators only
6) Accept a char and print in alternate case
7) Accept 3 integers and print second maximum
8)Accept a floting point value and print only the decimal part
    Hint : Example i/p   is  10.345        o/p  is  0.345
    Do in this order :   1  , 2 , 6 , 8 ,3 .....

9)Check Whether a Number is Even or Odd
10)Check Whether a Character is Vowel or consonant
11)Find the Largest Number Among Three Numbers Entered by 

User
12) Find all Roots of a Quadratic equation
13)Check Whether the Entered Year is Leap Year or not
14)Check Whether a Number is Positive or Negative or Zero.
15) Checker Whether a Character is an Alphabet or not
16)Find HCF of two Numbers
17)Find LCM of two numbers entered by user


/* work sheet on goto */
---------------------------------------------------------------------
1) print A B C D .... Z
2) print A B B C C D.....upto Z
3) print n'th table
Ex:-e
10 x 1 =10
10 x 2 =20
10 x 3 =30
...............
10 x 10 =100

/* work sheet on loops */
---------------------------------------------------------------------
1) program to print 10 to 1
2) print a....z
3) print fib series   0,1,1,2,3,5....
4)program to print sum of 10 integers
5) program to print first n numbers sum..
    10 number sum is 55
6)print 5 4 3 2 1 0 1 2 3 4 5
7) accespt a number and print digit sum use loops
8)Accept a number and  test wether a number is prime number or 

not

9)Find Sum of Natural Numbers
10)Find Factorial of a Number
11)Generate Multiplication Table
12)Count Number of Digits of an Integer
13)Reverse a Number
14)Calculate the Power of a Number
15)Check Whether a Number is Palindrome or Not
16)Check Whether an Integer is Prime or Not
17)Display Prime Numbers Between Two Intervals
18)Check Armstrong Number
19)Display Armstrong Number Between Two Intervals
20)Display Factors of a Number
21)Print Pyramids and Triangles in C programming using Loops
    different patterns
    
22)Make a Simple Calculator to Add, Subtract, Multiply or 

Divide Using switch...case

Saturday, February 18, 2017

Practice Paper in C for II-CSE RGAN

Menu Driven Mini Project in C For II-CSE-I RGAN [ 27-01-2017 to 18-02-2017 ]


    # include <stdio.h>
    # include <conio.h>
    # include <stdlib.h>


    char ch;
    FILE*f;
    /* student struct */
    struct  Student
    {
        int sno;
        char sname[15];
    };


    line(int col,int row,int color,int width)
    {
        int i;
        textcolor(color);
        gotoxy(col,row);

        for(i=1;i<=width;i++)
        {
        putch(219);
        }

    }


    menu()
    {
        clrscr();
        line(30,8,3,18);
        line(30,20,3,18);
        textcolor (YELLOW);
        gotoxy(30,10);
        cprintf("1....AddRec");
        gotoxy(30,11);
        cprintf("2....DisRecs");
        gotoxy(30,12);
        cprintf("3....Record Count");
        gotoxy(30,13);
        cprintf("4....Get Rec By Sno");
        gotoxy(30,14);
        cprintf("0....E X I T");
        gotoxy(30,18);
        textcolor (YELLOW+BLINK);
        cprintf("Choice?");
        textcolor (YELLOW);
        scanf("%c",&ch);

    }

    addrec()
    {
        struct Student s;
        gotoxy(30,22);
        cprintf("Enter student NO?");
        scanf("%d",&s.sno);
        gotoxy(30,23);
        cprintf("Enter student Name?");
        scanf("%s",&s.sname);

        /* ADDING REC */
        f=fopen("c:\\student.dat","a");
        if(f==NULL)
        {
            perror("\nUnable to open File for adding Record");
            return -1;
        }

        fwrite((struct Student*)&s,sizeof(struct Student),1,f);
        fclose(f);
        gotoxy(30,24);
        cprintf("Recod Added to Database.....");

    }

    disrecs()
    {
        struct Student s;
        gotoxy(30,22);
        cprintf("All Student Details....");
        /* displaying all  RECs */
        f=fopen("c:\\student.dat","r");
        if(f==NULL)
        {
            perror("\nUnable to open File for extracting Records");
            return -1;
        }

        fread((struct Student*)&s,sizeof(struct Student),1,f);
        while(!feof(f))
        {
        printf("\n%5d\t%15s",s.sno,s.sname);
        fread((struct Student*)&s,sizeof(struct Student),1,f);
        }
        fclose(f);
    }

    fileinfo()
    {
        int fs,rs,recs;
        gotoxy(30,22);
        cprintf("Fileinformation");
        f=fopen("c:\\student.dat","r");
        if(f==NULL)
        {
            perror("\nUnable to open File for extracting Records");
            return -1;
        }
        /* finding file size  & record size*/
        rs=sizeof(struct Student);
        fseek(f,0,SEEK_END);  /* position file poi at end */
        fs=ftell(f);
        recs=fs/rs;
        printf("\nFile size = %d",fs);
        printf("\nRec  size = %d",rs);
        printf("\nRecords   = %d",recs);
        fclose(f);


    }
    getrecbysno()
    {
        int sno;
        struct Student s;
        gotoxy(30,22);
        cprintf("\nEnter Sno to Ge?");
        scanf("%d",&sno);
        f=fopen("c:\\student.dat","r");
        if(f==NULL)
        {
            perror("\nUnable to open File for extracting Records");
            return -1;
        }
        /* searching */
        fread((struct Student*)&s,sizeof(struct Student),1,f);
        while(!feof(f))
        {
            if(sno==s.sno)
            {
            printf("\n%5d\t%15s",s.sno,s.sname);
            break;
            }
        fread((struct Student*)&s,sizeof(struct Student),1,f);
        }
        fclose(f);
    }

    main()
    {
        do
        {
        menu();
        switch(ch)
        {
            case '1':
                    addrec();
                    break;
            case '2':
                    disrecs();
                    break;
            case '3':
                    fileinfo();
                    break;
            case '4':
                    getrecbysno();
                    break;

            case '0':
                exit(0);
        }
        getch();
        }while(ch!='0');
/*  over */
    }

Friday, February 10, 2017

C-Program To find SET bits

/*  C-Program To find SET bits   */
main()
{
int count,x=7;

for ( count=0; x != 0; x>>=1)
{
if ( x & 1)
count++;
}

printf("%d", count);
}

Sunday, February 5, 2017

[ TT C Test ] Date : 05-2-2017 II CSE SECTION 1



05-2-2017    II   CSE   SECTION 1 ( 30q each 1 mark)   [ Compiled by RVS@RISE ]

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
21)
#include <stdio.h>
        int main()            {
                        if(1)
                        if(0);
                        else if(1)
                        printf("\nOver");
                        else;
        }
a)Over b)syntax missing error   c)nothing d)misplaced else

22)
1.#include<stdio.h>
int main(){
    int i,j;
    i=j=(2,3),0;
    while(--i&&j++)
         printf(" %d %d",i,j);
    return 0;
}
a)1 3     b)none  c)13  02  d)24 25

23)
. int main()
{
            int i=1,n;
            clrscr();
            for(i=0,n=0;i<=5;n+=i++);
            printf("%d",n);
}

a)25      b)21      c)garbage          d)15
24)
#include<stdio.h>
main()
{
  char not=!EOF;
  clrscr();
  printf("\n%d %d",EOF,not);
}
a. 0 0    b.error  c.-1 0   d.-1 1

25)
Int a=2;
a=a++ + ~++a;
a value is?
a)      0         b)1   c)-1   d)2

26)
 void main()
                {           while(1,2,'a',0)
                                {
                                                printf("abc");
                                }
                                printf(" def");
                }

a)abc def   b)error   c) def   d)abc abc abc def
27) void main()
{
int a=4,b=6;
if(++a==--b && 1)
printf("\ntrue");
else;
printf(" false");
}
a)true   b)false   c)true false  d)error
28)
main()
{
                printf(“RISE_ONGOLE”+4);
}
a)         RISE     b)RISE_    c)_ONGOLE   d) error

29)main()
{
enum {india,is=7,great};
printf(“%d%d”,india,great);
}
a)      7 1  b)7 8        c) 1  2    d)erro



30)  main() {
printf(“%d”,7>3>2?10:20<4?0:1);
a)      0    b) 1    c)  10      d) error

-------------------------------Think Globally & Get Locally Ur RVS  ------------------------------------