2020 S2C :: EST 102 Programming in C

Syllabus
                             .pdf
Students' List
s2c


Contact  Hours


13/1 ->
  20/1 ->
Monday


Tuesday 3
4
Wednesday 4
2(T)
Thursday
3(T)
1
Friday



Tests
Sessional

Doubt clearing
Attendance Students are expected to attend all the classes. Please be at the class at the time of commencement.

Attendance shall be marked only if physically present in the class.

Also, late comers will be marked, and two late marks will count as one absence.
Message
Material




On Line Latest activities with recent events on top
27/7
See the marks and attendance as entered in KTU portal.
Discrepancy with published data if any, please report.
26/7
Final Sessional
Explanation follows....

Hope you will be able to decode .

        a=(a1+a2+ga)/7.0; // (34+16+20)/7=10
       
        //Booster - limit applied
        t2=1.1*t2+16*(t2!=0);
        t3=1.1*t3+16*(t3!=0);
        a+=1;
        t2=limit(t2,50);
        t3=limit(t3,50);
        a=limit(a,10);
       
        t=(t2 + t3)/5.0;//(50+50)/5=20
       
        mt = t + a + gm; //sessional

22/7
Sessional marks - As per actual data.
Expect slight upward modification.

Minimum attendance required is 75%.
The following students have shortage of attendance as per data with me.
9, 47, and 12.

rn    t2    t3    T    lab    at.cl    at.tk    at.lb    att    Sess
in that order

 9    1    3    0.8      13    31    1    18    7.14     21  
47    0    2    0.4      17    27    0    20    6.71     24  
12    0    0    0        18    26    0    20    6.57     25  

17/07
Sessional marks - As per actual data.
Expect slight upward modification.
12/07
Task attendance details

Reg Class + Tests  + Video attendance

Receiving emails  asking me to recheck.  Check yourself first.
Most of the attendance data are composed using scripts.
If still error exists argue with details.

Also seen some new file uploads. They will not be counted, as counting is over.


The 16 files used for counting task attendance are these.

    f1=$dn.0807.c
    f2=$dn.0707.c
    f3=$dn.0607.c
    f4=$dn.0307.c
    f5=$dn.0107.c
    f6=$dn.3006.c
    f7=$dn.2906.c
    f8=$dn.2306.c
    f9=$dn.2206.c
    f10=$dn.1906.c
    f11=$dn.1806.c
    f12=$dn.1706.1.c
    f13=$dn.1706.2.c
    f14=$dn.1506.c
    f15=$dn.1206.c
    f16=$dn.1106.c

09/07
With the daily task of  yesterday our regular activities are coming to an end!

Including our regular class room sessions in the BC era, video sessions, daily tasks, the tests -  all put together we have accounted for 50 contact hours. We will add the lab contact hours also for counting the attendance. The marks of test2 and test3 will be considered fro 20 marks. Another 20 marks for the lab session. And 10 marks for total attendance.


Further updations about sessionals will be posted as and when ready.

Also, if any one have topic queries, that will be addressed via video or web posting as required.




Task 0807 receipt:
cs19c01.0807.c    cs19c06.0807.c    cs19c15.0807.c    cs19c23.0807.c    cs19c28.0807.c    cs19c36.0807.c    cs19c42.0807.c    cs19c50.0807.c    cs19c56.0807.c    cs19c62.0807.c
cs19c02.0807.c    cs19c07.0807.c    cs19c18.0807.c    cs19c24.0807.c    cs19c30.0807.c    cs19c37.0807.c    cs19c44.0807.c    cs19c51.0807.c    cs19c57.0807.c
cs19c03.0807.c    cs19c08.0807.c    cs19c19.0807.c    cs19c25.0807.c    cs19c31.0807.c    cs19c38.0807.c    cs19c45.0807.c    cs19c52.0807.c    cs19c58.0807.c
cs19c04.0807.c    cs19c10.0807.c    cs19c20.0807.c    cs19c26.0807.c    cs19c33.0807.c    cs19c39.0807.c    cs19c46.0807.c    cs19c54.0807.c    cs19c59.0807.c
cs19c05.0807.c    cs19c11.0807.c    cs19c22.0807.c    cs19c27.0807.c    cs19c34.0807.c    cs19c40.0807.c    cs19c49.0807.c    cs19c55.0807.c    cs19c61.0807.c



T2, T3, Attendance Details are here.

Break up of attendance count 50: Regular class + Tasks + Video sessions + Tests = 21 + 16 + 7 + 6

Duty leave related decisions, I am not authorised to take my own. That should come from higher authorities/faculty assigned with such responsibilities. Documents  sent directly to me by students will not be entertained unless I am instructed so by authorities.


08/07
Task 0707 received.
cs19c01.0707.c    cs19c07.0707.c    cs19c16.0707.c    cs19c21.0707.c    cs19c27.0707.c    cs19c37.0707.c    cs19c42.0707.c    cs19c46.0707.c    cs19c55.0707.c    cs19c61.0707.c
cs19c03.0707.c    cs19c13.0707.c    cs19c17.0707.c    cs19c23.0707.c    cs19c31.0707.c    cs19c38.0707.c    cs19c43.0707.c    cs19c48.0707.c    cs19c57.0707.c    cs19c62.0707.c
cs19c04.0707.c    cs19c14.0707.c    cs19c19.0707.c    cs19c25.0707.c    cs19c32.0707.c    cs19c39.0707.c    cs19c44.0707.c    cs19c52.0707.c    cs19c58.0707.c
cs19c05.0707.c    cs19c15.0707.c    cs19c20.0707.c    cs19c26.0707.c    cs19c35.0707.c    cs19c41.0707.c    cs19c45.0707.c    cs19c53.0707.c    cs19c60.0707.c

Task for the day.
Upload anytime today;  program file  cs19cxx.0807.c

Download the file s2c.0807.c
Read and understand the program. As remark at the top write a question which suits this program.
Also insert appropriate comments everywhere required.
There will be some warnings generated with the given program, even though it will still compile and execute.
Modify the code to get rid of the warnings without affecting the intended purpose.
Upload the modified code renamed as your code.

Task comments:
61, 44: Good
40: Comment "computing average" is not accurate.
xx: "printing details off all students" - I know when these types of typos happen!

07/07
No 0607 task uploads seen.

Task for the day.
Upload anytime today;  program file  cs19cxx.0707.c

Write a function to compute ab (i.e. a multiplied b times).
From main() call this function to compute the value of a polynomial of the form
anxn +  ... + a1x + a0

Early birds
cs19c44.0707.c -- Good
cs19c61.0707.c
-- Good?
cs19c07.0707.c -- Not exactly
&
cs19c53.0707.c -- Bad
cs19c13.0707.c -- Bad

06/07
Task for the day.
Upload anytime today;  program file  cs19cxx.0607.c; Data file  cs19cxx.0607.txt

Using a text editor, c
reate a .txt file  with the following details of 10 students.
Roll number, marks in Maths, marks in Physics, and marks in Chemistry.
Roll number should be from 1001 to 1010. Maximum marks per subject is 100.
One students details per line.
All data are of type integer.

Using a C program read these data into an array. Compute the total and store it in the same array. Sort the data on total marks and create a rank list.
Tie break order -  Maths, Physics. If still same, award same rank.

Now print the rank list with appropriate headings. The output should have the following details.
Rank (Topper on top), roll number, total, maths, phy, and chem marks in that order.

Write the final rank list data (without headings) into the file
cs19cxx.0607.txt

05/07
T3 Marks after considering late emails also.

04/07
Task 0307 Rcvd:
cs19c01.0307.c    cs19c08.0307.c    cs19c16.0307.c    cs19c23.0307.c    cs19c28.0307.c    cs19c34.0307.c    cs19c39.0307.c    cs19c43.0307.c    cs19c48.0307.c    cs19c52.0307.c    cs19c57.0307.c
cs19c03.0307.c    cs19c10.0307.c    cs19c18.0307.c    cs19c25.0307.c    cs19c30.0307.c    cs19c35.0307.c    cs19c40.0307.c    cs19c44.0307.c    cs19c49.0307.c    cs19c54.0307.c    cs19c58.0307.c
cs19c04.0307.c    cs19c11.0307.c    cs19c19.0307.c    cs19c26.0307.c    cs19c31.0307.c    cs19c37.0307.c    cs19c41.0307.c    cs19c45.0307.c    cs19c50.0307.c    cs19c55.0307.c    cs19c61.0307.c
cs19c05.0307.c    cs19c14.0307.c    cs19c20.0307.c    cs19c27.0307.c    cs19c33.0307.c    cs19c38.0307.c    cs19c42.0307.c    cs19c46.0307.c    cs19c51.0307.c    cs19c56.0307.c

Don't worry if your roll number is missing. Some emails in this regard I received. The files are there. But, not downloaded to my system due to some security precautions.
Diagonised. Overcame. Thank you for pointing it out 07, and 62.


03/07
Task for the day.
Upload anytime today  as cs19cxx.0307.c


Using switch-case count the number of each vowel characters in an input string.
Process all characters until EOF.
Press ^D to feed EOF in Linux.



T3 marks after including file received in time via email but uploaded before time in server. So following files are considered.
cs19c56.t31.c   cs19c56.t32.c   cs19c56.t33.c   cs19c42.t31.c   cs19c42.t32.c   cs19c42.t33.c   cs19c50.t31.c   cs19c50.t33.c  
cs19c50.t32.c   cs19c49.t31.c   cs19c49.t32.c   cs19c13.t31.c   cs19c13.t33.c   cs19c41.t31.c   cs19c41.t32.c   cs19c41.t33.c

These files with wrong file names which were delivered in time via email are now considered.
cs1920x.t32.c
cs19c07.t31.o
cs19c33.t31.c.C
cs19c33.t32.c.C
CS19C33.t33.c.C
'cs19c60.t31.c '
q3.c

New T3 marks


01/07
Task for the day.
Download s2c.names.txt
Upload anytime today  as cs19cxx.0107.c

Modified Q3 of T3

Write this program for all the 62 students using a loop.
From the given file using fgets or any suitable file reading technique, read the  name into a string variable studname.
Determine the  length of
studname using relevant string function. Print it.

Do the following works and print the results with appropriate headings/captions.

ˆConcatenate ”The name is: ” in front of studname. Then print it using puts, and printf
on different lines.
ˆConcatenate ” : is the name \n” at the end of studname. Then print it using printf and puts on different lines.
ˆCopy studname to another variable 
and print it using puts, and printf  on different lines.

Task files received till 23:25
cs19c05.0107.c    cs19c10.0107.c    cs19c14.0107.c    cs19c17.0107.c    cs19c18.0107.c    cs19c19.0107.c    cs19c21.0107.c    cs19c31.0107.c    cs19c52.0107.c

cs19c17.0107.c, cs19c31.0107.c,cs19c18.0107.c  - Good. See the effect of newline char at the end of studanme.

cs19c14.0107.c - Okay. 
See the effect of newline char at the end of studname.
cs19c52.0107.c - Not exactly the desired result.

cs19c21.0107.c - Include string.h to get rid off the warnings. Data file name?
cs19c05.0107.c - Check the output
cs19c19.0107.c - Well
cs19c10.0107.c - Error
 
30/6
Task for the day.
Upload anytime today  as cs19cxx.3006.c and
cs19cxx.3006.txt
Modified Q2 of T3

Manually create a data file as a text file named cs19cxx.3006.txt with four fields (Register number, mark 1, mark 2, mark 3 separated by space or tab with one line per student) of 10 students. Register numbers are to be consecutive numbers starting from 201.

Write a C program to do the following tasks. Write the code well indented and with enough remarks.

(a) Print a prompt message and accept the roll number RN  in the range 1 to 62.
If the input is not proper exit with a message.
Let R = RN + 30
N = R %10; if (N < 4) then N += 5

(b)Then c
reate a 2D array representing register number, mark 1, mark 2, mark 3 of N students by reading the data from the data file using fscanf().
Print the data with appropriate headings. Do the rest of the code using this array.

(c) In the code calculate : k = R % 3 + 1
Print all the details of the students who have scored highest in exam k (i.e mark k)

(d) Print all the details of the students who have scored ≥ 45 marks in at least one exam

(e) In the code calculate , regno = R % N + 201
Print the details and total marks of the student with register number regno

T3 valuation
31: Mark entry mistake corrected.

The following entries were wrongly happened to be in the second list and hence removed.

 cs19c06.t31.c  cs19c11.t33.c  cs19c40.t33.c cs19c54.t33.c


Modified second list
cs19c01.t31.c  cs19c01.t33.c  cs19c03.t31.c  cs19c03.t33.c  cs19c05.t32.c  cs19c07.t32.c  cs19c10.t31.c  cs19c10.t33.c  cs19c11.t31.c  cs19c17.t33.c  cs19c18.t32.c  cs19c20.t33.c  cs19c23.t31.c  cs19c23.t32.c  cs19c23.t33.c  cs19c25.t32.c  cs19c26.t31.c  cs19c28.t31.c  cs19c28.t32.c  cs19c28.t33.c  cs19c30.t31.c  cs19c30.t32.c  cs19c30.t33.c  cs19c31.t32.c  cs19c34.t32.c  cs19c37.t31.c  cs19c37.t32.c  cs19c37.t33.c  cs19c40.t32.c  cs19c43.t31.c  cs19c43.t33.c  cs19c45.t33.c  cs19c52.t32.c  cs19c54.t31.c  cs19c54.t32.c  cs19c57.t31.c  cs19c57.t33.c  cs19c58.t31.c  cs19c58.t32.c  cs19c58.t33.c  cs19c59.t31.c  cs19c59.t32.c  cs19c59.t33.c  cs19c61.t33.c  cs19c62.t32.c  cs19c62.t33.c


There is another one which could be read as the third column in yesterday's side-by-side code display.
Deeply disappointed to see this even from  second semester. That too in the third test after enough indication that this will not be tolerated.
Is there anyone more?

//**************
// ***********
#include<stdio.h>
int main()
{
    int arr[10][5],N=5,i,j,roll=200,max=0,stu,rn,k;
    for(i=0;i<N;i++)
    {
        for(j=0;j<4;j++)
        {
            if(j==0)
            {
                roll++;
                arr[i][0]=roll;
               
            }
            else
            {   
                printf("Enter Marks%d for %d =",j,roll);
                scanf("%d",&arr[i][j]);
           
            }
        }
    }
    k=1;
    printf("\nStudent who scored highest in Exam %d\n",k);
    for(i=0;i<N;i++)
    {
        for(j=k;j<k+1;j++)
        {
            if(max<arr[i][j])
            {
                max = arr[i][j];
                stu = i;
            }
        }
    }

    printf("Roll no = %d, Mark1 = %d, Mark2 = %d, Mark3 = %d\n",arr[stu][0],arr[stu][1],arr[stu][2],arr[stu][3]);

    printf("\nStudents who scored 45+ in atleast one exam\n");
    for(i=0;i<N;i++)
    {
        for(j=1;j<4;j++)
        {
            if(arr[i][j]>45)
            {   
                printf("Roll no = %d, Mark1 = %d, Mark2 = %d, Mark3 = %d\n",arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
                break;
            }
        }
    }
    rn=201;
    printf("\nDetails of student with roll no = %d\n",rn);
    for(i=0;i<N;i++)
    {
        for(j=0;j<1;j++)
        {
            if(arr[i][j]==rn)
            {
                printf("Roll no = %d, Mark1 = %d, Mark2 = %d, Mark3 = %d\n",arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
                break;
            }
        }
    }
    return 0;
               
}



Task comment:
Only one submission till now (23 hrs).
cs19c04: Need to write code much more indented. The text file is supposed to be a data file.
Don't get prejudiced by the test question. This is a new task.  Read the task carefully..............


T3 marks after second set of evaluation

29/6
Task for the day.
Upload anytime today  as cs19cxx.2906.c
Modified Q1 of T3.

Calculate and print the following values for all the  student of your class.

Let RN be the roll number 
Let R be RN + 30
N = R %10; if (N < 4) then N += 5

Separate the digits of R as x and y using appropriate C statements.
Perform bit wise operations (i) AND (ii) OR with x and y.
Compute x*4 using bit wise operation.

Print RN, R, N, x, y, result of AND, result of OR, and x*4 as computed above row-wise per student.


Two T3 Q2 answers are here side by side.
Authors will easily identify theirs.
I want to know more from them.
Please don't play possum.





// ######## cs19c##

#include<stdio.h>
int main()
{
    int arr[10][5],N=9,i,j,roll=200,max=0,stu,rn,k;
    for(i=0;i<N;i++)
    {
        for(j=0;j<4;j++)
        {
            if(j==0)
            {
                roll++;
                arr[i][0]=roll;
               
            }
            else
            {   
                printf("Enter Marks%d for %d =",j,roll);
                scanf("%d",&arr[i][j]);
           
            }
        }
    }
    k=2;
    printf("\nStudent who scored highest in Exam %d\n",k);
    for(i=0;i<N;i++)
    {
        for(j=k;j<k+1;j++)
        {
            if(max<arr[i][j])
            {
                max = arr[i][j];
                stu = i;
            }
        }
    }

    printf("Roll no = %d, Mark1 = %d, Mark2 = %d, Mark3 = %d\n",arr[stu][0],arr[stu][1],arr[stu][2],arr[stu][3]);

    printf("\nStudents who scored 45+ in atleast one exam\n");
    for(i=0;i<N;i++)
    {
        for(j=1;j<4;j++)
        {
            if(arr[i][j]>45)
            {   
                printf("Roll no = %d, Mark1 = %d, Mark2 = %d, Mark3 = %d\n",arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
                break;
            }
        }
    }
    rn=202;
    printf("\nDetails of student with roll no = %d\n",rn);
    for(i=0;i<N;i++)
    {
        for(j=0;j<1;j++)
        {
            if(arr[i][j]==rn)
            {
                printf("Roll no = %d, Mark1 = %d, Mark2 = %d, Mark3 = %d\n",arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
                break;
            }
        }
    }
    return 0;
               
}


/*SUBMITTED BY:###########
             S2C
             ROLL NUMBER:##


*/
#include<stdio.h>
int main()
{
    int arr[10][5],N=8,i,j,roll=200,max=0,stu,rn,k;
    for(i=0;i<N;i++)
    {
        for(j=0;j<4;j++)
        {
            if(j==0)
            {
                roll++;
                arr[i][0]=roll;

            }
            else
            {
                printf("Enter Marks%d for %d =",j,roll);
                scanf("%d",&arr[i][j]);

            }
        }
    }
    k=1;
    printf("\nStudent who scored highest in Exam %d\n",k);
    for(i=0;i<N;i++)
    {
        for(j=k;j<k+1;j++)
        {
            if(max<arr[i][j])
            {
                max = arr[i][j];
                stu = i;
            }
        }
    }

    printf("Roll no = %d, Mark1 = %d, Mark2 = %d, Mark3 = %d\n",arr[stu][0],arr[stu][1],arr[stu][2],arr[stu][3]);

    printf("\nStudents who scored 45+ in atleast one exam\n");
    for(i=0;i<N;i++)
    {
        for(j=1;j<4;j++)
        {
            if(arr[i][j]>45)
            {
                printf("Roll no = %d, Mark1 = %d, Mark2 = %d, Mark3 = %d\n",arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
                break;
            }
        }
    }
    rn=201;
    printf("\nDetails of student with roll no = %d\n",rn);
    for(i=0;i<N;i++)
    {
        for(j=0;j<1;j++)
        {
            if(arr[i][j]==rn)
            {
                printf("Roll no = %d, Mark1 = %d, Mark2 = %d, Mark3 = %d\n",arr[i][0],arr[i][1],arr[i][2],arr[i][3]);
                break;
            }
        }
    }
    return 0;

}



Task submission feed back:
cs19c18.2906.c: Re-read the question!
cs19c25.2906.c: Right
cs19c31.2906.c: Right
cs19c44.2906.c: Right
cs19c61.2906.c: Right. Note the format warning.


T3: Next set of files to be evaluated.
These are the files received by email in time, but not uploaded in server by the time time I downloaded the files from the server. Again done with another script. So only identify files with correct names.
Rest of evaluation after this.
cs19c01.t31.c  cs19c01.t33.c  cs19c03.t31.c  cs19c03.t33.c  cs19c05.t32.c  cs19c06.t31.c  cs19c07.t32.c  cs19c10.t31.c  cs19c10.t33.c  cs19c11.t31.c  cs19c11.t33.c  cs19c17.t33.c  cs19c18.t32.c  cs19c20.t33.c  cs19c23.t31.c  cs19c23.t32.c  cs19c23.t33.c  cs19c25.t32.c  cs19c26.t31.c  cs19c28.t31.c  cs19c28.t32.c  cs19c28.t33.c  cs19c30.t31.c  cs19c30.t32.c  cs19c30.t33.c  cs19c31.t32.c  cs19c34.t32.c  cs19c37.t31.c  cs19c37.t32.c  cs19c37.t33.c  cs19c40.t32.c  cs19c40.t33.c  cs19c43.t31.c  cs19c43.t33.c  cs19c45.t33.c  cs19c52.t32.c  cs19c54.t31.c  cs19c54.t32.c  cs19c54.t33.c  cs19c57.t31.c  cs19c57.t33.c  cs19c58.t31.c  cs19c58.t32.c  cs19c58.t33.c  cs19c59.t31.c  cs19c59.t32.c  cs19c59.t33.c  cs19c61.t33.c  cs19c62.t32.c  cs19c62.t33.c


T3: Break-up of marks
Q1:  RN printing 2; assign value for r  2; x 2; y 2; & 2; | 2; << 3
Q2: Array creation 5; Print 3; (a) 4; (b) 4; (c) 4
Q3: gets() and len 5; Rest 10;

Wherever asked for manual calculation, and if done via code that is not correct.

Marks after first round valuation is here - done as per the file list already posted.
Please don't send me email asking for where you have lost mark. I have much much more important pending works before me, including identifying and extracting answers received not as per instructions.
But, if you feel that the marks you got is much less than what you deserve, you could claim them with proper arguments justifying the claim.
Carefully read the few sentences above before composing the mail!


28/06
All the lists  displayed are generated using commands or simple shell scripts. So, if nay file is missing it means the criteria for shortlisting is not met.  These are machine decisions. Of course programming is also the art of letting the machines take appropriate decisions as per the constraints fed by us.

Later I will look into cases which missed from the machine generated  list and take human decisions appropriately. Wait...
27/06
T3:
List of files received in time (5:10PM) via email:
cs19c01.t31.c cs19c01.t33.c cs19c02.t31.c cs19c02.t32.c cs19c02.t33.c cs19c03.t31.c cs19c03.t33.c cs19c04.t31.c cs19c04.t32.c cs19c04.t33.c cs19c05.t31.c cs19c05.t32.c cs19c05.t33.c cs19c06.t31.c cs19c07.t32.c cs19c08.t31.c cs19c08.t32.c cs19c08.t33.c cs19c10.t31.c cs19c10.t33.c cs19c11.t31.c cs19c11.t33.c cs19c13.t31.c cs19c13.t33.c cs19c14.t31.c cs19c14.t33.c cs19c15.t31.c cs19c15.t32.c cs19c15.t33.c cs19c17.t32.c cs19c17.t33.c cs19c18.t31.c cs19c18.t32.c cs19c18.t33.c cs19c19.t31.c cs19c19.t32.c cs19c19.t33.c cs19c20.t31.c cs19c20.t33.c cs19c22.t31.c cs19c22.t32.c cs19c22.t33.c cs19c23.t31.c cs19c23.t32.c cs19c23.t33.c cs19c24.t31.c cs19c24.t32.c cs19c25.t31.c cs19c25.t32.c cs19c25.t33.c cs19c26.t31.c cs19c26.t32.c cs19c26.t33.c cs19c27.t31.c cs19c28.t31.c cs19c28.t32.c cs19c28.t33.c cs19c29.t31.c cs19c30.t31.c cs19c30.t32.c cs19c30.t33.c cs19c31.t31.c cs19c31.t32.c cs19c31.t33.c cs19c32.t31.c cs19c32.t32.c cs19c32.t33.c cs19c34.t31.c cs19c34.t32.c cs19c34.t33.c cs19c35.t31.c cs19c35.t32.c cs19c35.t33.c cs19c36.t31.c cs19c36.t32.c cs19c36.t33.c cs19c37.t31.c cs19c37.t32.c cs19c37.t33.c cs19c38.t31.c cs19c38.t32.c cs19c38.t33.c cs19c39.t31.c cs19c39.t32.c cs19c40.t32.c cs19c40.t33.c cs19c41.t31.c cs19c41.t32.c cs19c41.t33.c cs19c42.t31.c cs19c42.t32.c cs19c42.t33.c cs19c43.t31.c cs19c43.t33.c cs19c44.t31.c cs19c44.t33.c cs19c45.t31.c cs19c45.t32.c cs19c45.t33.c cs19c46.t31.c cs19c46.t32.c cs19c46.t33.c cs19c48.t31.c cs19c48.t32.c cs19c48.t33.c cs19c49.t31.c cs19c49.t32.c cs19c50.t31.c cs19c50.t32.c cs19c50.t33.c cs19c51.t31.c cs19c51.t32.c cs19c51.t33.c cs19c52.t31.c cs19c52.t32.c cs19c52.t33.c cs19c53.t31.c cs19c53.t32.c cs19c53.t33.c cs19c54.t31.c cs19c54.t32.c cs19c54.t33.c cs19c55.t31.c cs19c55.t33.c cs19c56.t31.c cs19c56.t32.c cs19c56.t33.c cs19c57.t31.c cs19c57.t33.c cs19c58.t31.c cs19c58.t32.c cs19c58.t33.c cs19c59.t31.c cs19c59.t32.c cs19c59.t33.c cs19c60.t33.c cs19c61.t31.c cs19c61.t33.c cs19c62.t31.c cs19c62.t32.c cs19c62.t33.c


List of files uploaded to server before time(5.30PM) against instruction

-rw-r--r--   1 cs19c13 cs19c   279 Jun 25 17:15 cs19c13.t31.c
-rw-r--r--   1 cs19c13 cs19c   336 Jun 25 17:15 cs19c13.t33.c
-rw-r--r--   1 cs19c33 cs19c   301 Jun 25 17:19 cs19c33.t31.c
-rw-r--r--   1 cs19c33 cs19c   393 Jun 25 17:19 CS19C33.t33.c
-rw-r--r--   1 cs19c33 cs19c   405 Jun 25 17:19 cs19c33.t32.c
-rw-r--r--   1 cs19c41 cs19c  1313 Jun 25 17:17 cs19c41.t32.c
-rw-r--r--   1 cs19c41 cs19c   220 Jun 25 17:17 cs19c41.t33.c
-rw-r--r--   1 cs19c41 cs19c   234 Jun 25 17:17 cs19c41.t31.c
-rw-r--r--   1 cs19c42 cs19c  1478 Jun 25 17:02 cs19c42.t32.c
-rw-r--r--   1 cs19c42 cs19c   291 Jun 25 17:02 cs19c42.t33.c
-rw-r--r--   1 cs19c42 cs19c   399 Jun 25 17:02 cs19c42.t31.c
-rw-r--r--   1 cs19c49 cs19c   310 Jun 25 17:15 cs19c49.t31.c
-rw-r--r--   1 cs19c49 cs19c   344 Jun 25 17:15 cs19c49.t32.c
-rw-r--r--   1 cs19c50 cs19c   317 Jun 25 16:51 cs19c50.t33.c
-rw-r--r--   1 cs19c50 cs19c   378 Jun 25 16:31 cs19c50.t31.c
-rw-r--r--   1 cs19c50 cs19c   698 Jun 25 17:02 cs19c50.t32.c
-rw-r--r--   1 cs19c56 cs19c   303 Jun 25 16:59 cs19c56.t31.c
-rw-r--r--   1 cs19c56 cs19c   306 Jun 25 16:59 cs19c56.t33.c
-rw-r--r--   1 cs19c56 cs19c   336 Jun 25 16:59 cs19c56.t32.c


Files received in time via email and same copy available at server

cs19c02.t31.c  cs19c08.t31.c  cs19c15.t32.c  cs19c20.t31.c  cs19c26.t32.c  cs19c32.t33.c  cs19c36.t33.c  cs19c42.t33.c    cs19c48.t31.c  cs19c52.t31.c  cs19c56.t32.c
cs19c02.t32.c  cs19c08.t32.c  cs19c15.t33.c  cs19c22.t31.c  cs19c26.t33.c  cs19c34.t31.c  cs19c38.t31.c  cs19c44.t31.c    cs19c48.t32.c  cs19c52.t33.c  cs19c56.t33.c
cs19c02.t33.c  cs19c08.t33.c  cs19c17.t32.c  cs19c22.t32.c  cs19c27.t31.c  cs19c34.t33.c  cs19c38.t32.c  cs19c44.t33.c    cs19c48.t33.c  cs19c53.t31.c  cs19c60.t33.c
cs19c04.t31.c  cs19c13.t31.c  cs19c18.t31.c  cs19c22.t33.c  cs19c29.t31.c  cs19c35.t31.c  cs19c38.t33.c  cs19c45.t31.c    cs19c50.t31.c  cs19c53.t32.c  cs19c61.t31.c
cs19c04.t32.c  cs19c13.t33.c  cs19c18.t33.c  cs19c24.t31.c  cs19c31.t31.c  cs19c35.t32.c  cs19c39.t31.c  cs19c45.t32.c    cs19c50.t33.c  cs19c53.t33.c  cs19c62.t31.c
cs19c04.t33.c  cs19c14.t31.c  cs19c19.t31.c  cs19c24.t32.c  cs19c31.t33.c  cs19c35.t33.c  cs19c39.t32.c  cs19c46.t31.c    cs19c51.t31.c  cs19c55.t31.c
cs19c05.t31.c  cs19c14.t33.c  cs19c19.t32.c  cs19c25.t31.c  cs19c32.t31.c  cs19c36.t31.c  cs19c42.t31.c  cs19c46.t32.c    cs19c51.t32.c  cs19c55.t33.c
cs19c05.t33.c  cs19c15.t31.c  cs19c19.t33.c  cs19c25.t33.c  cs19c32.t32.c  cs19c36.t32.c  cs19c42.t32.c  cs19c46.t33.c    cs19c51.t33.c  cs19c56.t31.c



Files received in time via email and same copy uploaded to server after 5.30 (correct cases)
cs19c02.t31.c  cs19c05.t33.c  cs19c15.t32.c  cs19c19.t33.c  cs19c25.t31.c  cs19c31.t33.c  cs19c35.t32.c  cs19c38.t33.c    cs19c46.t31.c  cs19c51.t32.c  cs19c55.t31.c
cs19c02.t32.c  cs19c08.t31.c  cs19c15.t33.c  cs19c20.t31.c  cs19c25.t33.c  cs19c32.t31.c  cs19c35.t33.c  cs19c39.t31.c    cs19c46.t32.c  cs19c51.t33.c  cs19c55.t33.c
cs19c02.t33.c  cs19c08.t32.c  cs19c17.t32.c  cs19c22.t31.c  cs19c26.t32.c  cs19c32.t32.c  cs19c36.t31.c  cs19c39.t32.c    cs19c46.t33.c  cs19c52.t31.c  cs19c60.t33.c
cs19c04.t31.c  cs19c08.t33.c  cs19c18.t31.c  cs19c22.t32.c  cs19c26.t33.c  cs19c32.t33.c  cs19c36.t32.c  cs19c44.t31.c    cs19c48.t31.c  cs19c52.t33.c  cs19c61.t31.c
cs19c04.t32.c  cs19c14.t31.c  cs19c18.t33.c  cs19c22.t33.c  cs19c27.t31.c  cs19c34.t31.c  cs19c36.t33.c  cs19c44.t33.c    cs19c48.t32.c  cs19c53.t31.c  cs19c62.t31.c
cs19c04.t33.c  cs19c14.t33.c  cs19c19.t31.c  cs19c24.t31.c  cs19c29.t31.c  cs19c34.t33.c  cs19c38.t31.c  cs19c45.t31.c    cs19c48.t33.c  cs19c53.t32.c 
cs19c05.t31.c  cs19c15.t31.c  cs19c19.t32.c  cs19c24.t32.c  cs19c31.t31.c  cs19c35.t31.c  cs19c38.t32.c  cs19c45.t32.c    cs19c51.t31.c  cs19c53.t33.c

Above are the files I am going to evaluate first, as they are delivered to me as per instructions.
Rest of the cases I shall address later.

26/06
No new task for the day
25/06
Test:
Please read the instructions here and in question paper very carefully. Adhere to them.
After the exam you send the three program files by email only.
Do not immediately upload. Upload the same files to the server after 5.30PM.

All the 62 students should write exam independently. No communication between students are allowed from 3 PM to 5.30PM.

Queries if any by email will be addressed. To get proper attention, write briefly, and properly with your clear identity.

Time 2 hrs.

Sending answer  files should be done immediately after finishing the exam.  Everything should be readied and sent by 5 PM. Do not share your answer with anybody else until 5.30PM.

Your email time should be at most 5PM. I can also verify the landing time in my inbox. Set your system time as per IST correctly.  Mails with timing after 5.05PM will be considered as late and will be scrutinized and treated so.

Program should be able to compile and run from Linux.
Should not use conio.h

File names: Adhere strictly. Practice or test  yourself beforehand.

Question 1: cs19cxx.t31.c
Question 2: cs19cxx.t32.c
Question 3: cs19cxx.t33.c

Write your name and roll number as comments in every program


email subject: S2C EST102 T3

QP Link

will be available from 2.57PM

Re-posted the QP. Sorry for the trouble.

Please send one email with three attachments(each answer program).
Files size will be small. Hence do not zip/compress.

Reminding again: In email put your identity.

-----
17:23 Checking the mail and server.

Hope you have written well.

But some immediate feed backs.

Please, please, please read the instructions oneself and follow it.
Learn to follow the instructions.

You are supposed to upload the files to the server after 5.30PM only.

How could you justify directing me to receive your files with total size around 1KB only  to your google drive? How will you prove me that you have not edited by the time I download it?

The genuine excuse emails receiving, I shall consider on merit.

Many emails without identity.
Many emails after the time limit.

Thank you 55
Sankar Raj for highlighting the warning message generated while compiling C code with gets(). Some of you may still remember when gets() was discussed in our class way back in February 25, I had mentioned this fact. Since this function is there in the syllabus we can't overlook it completely. Personally I don't think I have ever used it. [ C and shell scripts are my languages now a days ].


Repeated reminders gone in vain. Many have chosen to name the files as they like. Why can't we even give a file name as suggested?

List of files received at server and via email with correct name and same content.
Done via code.
(Pending checking of other constraints)
cs19c02.t31.c  cs19c08.t31.c  cs19c15.t32.c  cs19c20.t31.c  cs19c26.t32.c  cs19c32.t33.c  cs19c36.t33.c  cs19c42.t33.c    cs19c48.t31.c  cs19c52.t31.c  cs19c56.t32.c
cs19c02.t32.c  cs19c08.t32.c  cs19c15.t33.c  cs19c22.t31.c  cs19c26.t33.c  cs19c34.t31.c  cs19c38.t31.c  cs19c44.t31.c    cs19c48.t32.c  cs19c52.t33.c  cs19c56.t33.c
cs19c02.t33.c  cs19c08.t33.c  cs19c17.t32.c  cs19c22.t32.c  cs19c27.t31.c  cs19c34.t33.c  cs19c38.t32.c  cs19c44.t33.c    cs19c48.t33.c  cs19c53.t31.c  cs19c60.t33.c
cs19c04.t31.c  cs19c13.t31.c  cs19c18.t31.c  cs19c22.t33.c  cs19c29.t31.c  cs19c35.t31.c  cs19c38.t33.c  cs19c45.t31.c    cs19c50.t31.c  cs19c53.t32.c  cs19c61.t31.c
cs19c04.t32.c  cs19c13.t33.c  cs19c18.t33.c  cs19c24.t31.c  cs19c31.t31.c  cs19c35.t32.c  cs19c39.t31.c  cs19c45.t32.c    cs19c50.t33.c  cs19c53.t33.c  cs19c62.t31.c
cs19c04.t33.c  cs19c14.t31.c  cs19c19.t31.c  cs19c24.t32.c  cs19c31.t33.c  cs19c35.t33.c  cs19c39.t32.c  cs19c46.t31.c    cs19c51.t31.c  cs19c55.t31.c
cs19c05.t31.c  cs19c14.t33.c  cs19c19.t32.c  cs19c25.t31.c  cs19c32.t31.c  cs19c36.t31.c  cs19c42.t31.c  cs19c46.t32.c    cs19c51.t32.c  cs19c55.t33.c
cs19c05.t33.c  cs19c15.t31.c  cs19c19.t33.c  cs19c25.t33.c  cs19c32.t32.c  cs19c36.t32.c  cs19c42.t32.c  cs19c46.t33.c    cs19c51.t33.c  cs19c56.t31.c

Rest of the files I have to go through manually through server and emails.

Code compiling and evaluation will commence later.

24/06
No new tasks today and tomorrow. But, reminding the test tomorrow.

23/06
Most of the faculty are undergoing a training course today, and tomorrow. I am also attending.
Hence checked in now(8PM)! Happy to see that almost all have posted the code. Shall have a look later today.

Task for the day will be posted soon. Upload by anytime tomorrow.

Try to do the same task as yesterday with b() implemented using pointers. i.e. Don't use array subscripts in b().

Attempting a() with pointers (that is creating the array) is a little difficult. Hence b(). Except for b() use pointers only where array/ subscripts will not work.


In case of tasks where there is good response, I shall post my own solution later. Please wait.
Reminding: Errors and mistakes are part of the learning process. Be patient. Hard work will have its returns.
Post your codes, irrespective of correctness. You could also see your colleagues answers from the server and learn different methods.

Comments on task of 22/06

I will check 5 15 25 35 45 55 today and comment.
I will go through the code quickly.

My intention was you solve the problem with minimal use of pointers.

5: Okay. Indentation need attention.

15 Same logic and implementation. Indentation need attention.

25 Same logic.

35  Okay.

45  Where are you using the arguments of main()?  Otherwise okay. Indentation need attention.

55 Okay
-------------------------------------------------


Meanwhile changing variable name j to t or s won't make much difference!


22/6
The declared test will be on 25/06, 3 - 5PM


Task for the day: Upload any time today.
Write three functions a(), b(), c() in a program
cs19cxx.2206.c

main() reads an input value n from standard input.
calls a() with n as argument.
a() reads an array of n integers ar1[] from standard input and returns ar1[] to main().

main() calls b() with ar1[]
and n as arguments.
b() prints the array.

main() then calls c() with 
ar1[] and n as arguments.
c() sorts the array and returns the sorted version as ar2[].
Keep ar1[] intact.

main() calls b() with ar1[] and n again.
main() then calls b() with ar2[] and n.


20/6
 Answer of T2 Q1 based task given on 17/6/20. cs19c00.1706.op1.txt
19/6
Task for the day.
Solve Q3 of T2 for all the 4 cases.
Upload code as cs19cxx.1906.c


As done after the first test, I am reminding some of you to come straight. Denial, justification, put forth stubborn arguments etc. may make matters worse. Why many of you resorted to unfair means despite warnings after the first test? As a teacher I will not tolerate unjust means. Of course, I may not have time and energy to unearth everything. But, whatever identified I have to proceed with.  It is not difficult to reasonably establish the role each one played in such cases. If you justify , it means, still not willing to rectify. In that case I am helpless.

Of course you could seek external help to reply me. But, first consult your parents - I am also going to do that. Also, consult with wise people. Such efforts should ultimately help you. At this young age of yours, no faculty will try to put you into difficulty. But, it is their duty not to look aside on unethical academic activities. Hence, if you go to the denial, defensive mode, then things may not be easily resolvable.

For the first time, today morning I have officially reported the matter without details to your staff advisor, our HoD, and the Principal.

Meanwhile reiterating that if any topics from modules 1 to 5 are to be discussed, convey me through your class rep to schedule it.

There will be one more test covering first three modules next week.
You have to write short programs.

Going through daily tasks submitted -  please cultivate the habit of writing code well indented, document with comments, and use white space and blank lines when required.

From daily task submissions, I am checking some random files to give you feedback. If taken for sessional purpose, all submissions will be evaluated.

cs19c62.1706.1.c, and cs19c62.1706.2.c : Check the outputs - seems doubtful. Also seems both are using files. Read the task.

Task of 1806: In two question options we have to return the array. 3 methods are here:
(1) Declare the array globally - declare before any function including main()
(2) Declare the array as static either in main() or in a function.
(3) Declare the array in main() and pass it as another argument to the function - Not aptly fit for this question though.

I could see cs19c46.1806.c using static array to fill max and min values. Could have accessed this array from main() as asked in question.


cs19c32.1806.c, and cs19c52.1806.c are using the global declaration option.  In case of cs19c52.1806.c the initialization of max and min with constant values could be avoided.



18/6
Task for the day:
Solve Q2 of T2 for all the three cases.
Upload code as cs19cxx.1806.c

T2 evaluation based on first download from server  is ON. Reached 42. Got a few cases for further analysis.  Happy to see 42 has solved the third question well.

Email submissions, other cases will be looked into after this set of evaluation is over.


While submitting code, avoid conio.h. It will not compile everywhere. It is OS dependent.


Codes written by two students are here.
Those who wrote this will immediately identify it.
They are asked to kindly tell me via email by June 19, why the codes are so similar.

#include<stdio.h>
int*func(int a[10],int n)
{
   int an[2],large,small,i;
   large=a[0];
   for(i=1;i<n;i++)
          if(large<a[i])
               large=a[i];
   small=a[0];
   for(i=1;i<n;i++)
          if(small>a[i])
               small=a[i];
  an[0]=large;
  an[1]=small;
  return an;
}
int main()
{
   int arr[100],size,i,largest,smallest;
   printf("Enter the size of array\n");
   scanf("%d",&size);
   printf("Enter the elements\n");
   for(i=0;i<size;i++)
         scanf("%d",&arr[i]);
   int *x;
   x=func(arr,size);
   printf("largest=%d\nsmallest=%d",x[0],
   x[1]);
   return 0;
}
// cs19cXX XXXXXX XXXXXXX//
// dX=X//
#include<stdio.h>
int*func(int a[10],int n)
{
   int b[2],large,small,i;
   large=a[0];
   for(i=1;i<n;i++)
          if(large<a[i])
               large=a[i];
   small=a[0];
   for(i=1;i<n;i++)
          if(small>a[i])
               small=a[i];
  b[0]=large;
  b[1]=small;
  return b;
}
int main()
{
   int arr[10],size,i,largest,smallest;
   printf("enter the size of array\n");
   scanf("%d",&size);
   printf("enter the elements\n");
   for(i=0;i<size;i++)
         scanf("%d",&arr[i]);
   int *c;
   c=func(arr,size);
   printf("largest=%d\nsmallest=%d",c[0],
   c[1]);
   return 0;
}


T2 valuation based on 18.11 hrs.  download from server has been completed.
T2.txt
Now on, emails will be processed to update it.
Also, the marks are provisional. Subject to correction for valid reasons till final submission.



T2 evaluation from email submission is ON.
But, need to have more clarity at many places.

Following are submissions from two students. Could they help me to find out what went wrong. Reply by email by June 19.

//###################
#include <stdio.h>

struct student
{
    char rollno[3];
    int m1;
    int m2;
    int m3;
};

void main()
{
    int r=##;
    int d4=#;
    int n=r/3;
    int i=0;
    struct student s;
    FILE *fin = fopen("list.txt", "r");
    FILE *fout = fopen("list.##", "wb");
    fseek(fin,(n-1)*sizeof(s),SEEK_SET);
    while(n)
    {
   
    fscanf(fin,"%s%d%d%d",s.rollno,&s.m1,&s.m2,&s.m3);
    //fread(&s, sizeof(s),1,fin);
    fwrite(&s, sizeof(s), 1,fout);
    /*
        printf("rollno%d:%s",i+1,s.rollno);
        printf("\n");
        printf("mone%d:%d",i+1,s.m1);
        printf("\n");
        printf("mtwo%d:%d",i+1,s.m2);
        printf("\n");
        printf("mthree%d:%d",i+1,s.m3);
        printf("\n");*/
        n--;
       
    }
    /*fwrite(&s, sizeof(struct student),1,fout);*/

    fclose(fin);
    fclose(fout);
    FILE *f = fopen("list.##", "rb");
    FILE *fp = fopen("list.n.##", "wb");
    while ((fread(&s, sizeof(s), 1,f)))
        if((s.m1>50)&& (s.m2>50 )&& (s.m3 >50 ))
            fwrite(&s, sizeof(s), 1,fp);

    fclose(f);
    fclose(fp);

    FILE *a = fopen("list.##", "rb");
    FILE *b = fopen("list.n.##", "rb");
    FILE *c = fopen("list.txt", "r");

    printf("file list.##:\n");
    while ((fread(&s, sizeof(s), 1,a)))
        {
            printf("rollno%d:%s",i+1,s.rollno);
        printf("\n");
        printf("mone%d:%d",i+1,s.m1);
        printf("\n");
        printf("mtwo%d:%d",i+1,s.m2);
        printf("\n");
        printf("mthree%d:%d",i+1,s.m3);
        printf("\n");
        }

    printf("file list.n.##:\n");
    while ((fread(&s, sizeof(s), 1,b)))
                {
            printf("rollno%d:%s",i+1,s.rollno);
        printf("\n");
        printf("mone%d:%d",i+1,s.m1);
        printf("\n");
        printf("mtwo%d:%d",i+1,s.m2);
        printf("\n");
        printf("mthree%d:%d",i+1,s.m3);
        printf("\n");
        }


    printf("file list.txt:\n");
     while ((fread(&s, sizeof(s), 1,c)))
                {
            printf("rollno%d:%s",i+1,s.rollno);
        printf("\n");
        printf("mone%d:%d",i+1,s.m1);
        printf("\n");
        printf("mtwo%d:%d",i+1,s.m2);
        printf("\n");
        printf("mthree%d:%d",i+1,s.m3);
        printf("\n");
        }



fclose(a);
    fclose(b);
    fclose(f);
    fclose(c);

}

//###################
#include <stdio.h>

struct student
{
    char rollno[3];
    int m1;
    int m2;
    int m3;
};

void main()
{
    int r=##;
    int d4=#;
    int n=r/3;
    int i=0;
    struct student s;
    FILE *fin = fopen("list.txt", "r");
    FILE *fout = fopen("list.##", "wb");
    fseek(fin,(n-1)*sizeof(s),SEEK_SET);
    while(n)
    {
   
    fscanf(fin,"%s%d%d%d",s.rollno,&s.m1,&s.m2,&s.m3);
    //fread(&s, sizeof(s),1,fin);
    fwrite(&s, sizeof(s), 1,fout);
    /*
        printf("rollno%d:%s",i+1,s.rollno);
        printf("\n");
        printf("mone%d:%d",i+1,s.m1);
        printf("\n");
        printf("mtwo%d:%d",i+1,s.m2);
        printf("\n");
        printf("mthree%d:%d",i+1,s.m3);
        printf("\n");*/
        n--;
       
    }
    /*fwrite(&s, sizeof(struct student),1,fout);*/

    fclose(fin);
    fclose(fout);
    FILE *f = fopen("list.##", "rb");
    FILE *fp = fopen("list.n.##", "wb");
    while ((fread(&s, sizeof(s), 1,f)))
        if((s.m1>50)&& (s.m2>50 )&& (s.m3 >50 ))
            fwrite(&s, sizeof(s), 1,fp);

    fclose(f);
    fclose(fp);

    FILE *a = fopen("list.##", "rb");
    FILE *b = fopen("list.n.##", "rb");
    FILE *c = fopen("list.txt", "r");

    printf("file list.##:\n");
    while ((fread(&s, sizeof(s), 1,a)))
        {
            printf("rollno%d:%s",i+1,s.rollno);
        printf("\n");
        printf("mone%d:%d",i+1,s.m1);
        printf("\n");
        printf("mtwo%d:%d",i+1,s.m2);
        printf("\n");
        printf("mthree%d:%d",i+1,s.m3);
        printf("\n");
        }

    printf("file list.n.##:\n");
    while ((fread(&s, sizeof(s), 1,b)))
                {
            printf("rollno%d:%s",i+1,s.rollno);
        printf("\n");
        printf("mone%d:%d",i+1,s.m1);
        printf("\n");
        printf("mtwo%d:%d",i+1,s.m2);
        printf("\n");
        printf("mthree%d:%d",i+1,s.m3);
        printf("\n");
        }


    printf("file list.txt:\n");
     while ((fread(&s, sizeof(s), 1,c)))
                {
            printf("rollno%d:%s",i+1,s.rollno);
        printf("\n");
        printf("mone%d:%d",i+1,s.m1);
        printf("\n");
        printf("mtwo%d:%d",i+1,s.m2);
        printf("\n");
        printf("mthree%d:%d",i+1,s.m3);
        printf("\n");
        }



fclose(a);
    fclose(b);
    fclose(f);
    fclose(c);

}


Following are submissions from two students. Could they help me to find out what went wrong. Reply by email by June 19.
::::::::::::::
cs19c##.t22.c
::::::::::::::
#include<stdio.h>
int *find(int x[],int y);
void main()
{
int d3,n,i,*p;
int a[100];
printf("Enter d3\n");
scanf("%d",&d3);
printf("Enter no of elements\n");
scanf("%d",&n);
printf("Enter elements\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
p=find(a,n);
printf("Displaying array\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
printf("\n");
for(i=0;i<2;i++)
{
printf("%d",*(p+i));
}
}
int *find(int x[],int y)
{
int z[2],i;
int large=0;
int small=x[0];
for(i=0;i<y;i++)
{
if(x[i]>large)
large=x[i];
if(small>x[i])
small=x[i];
}
z[0]=large;
z[1]=small;
return (&z[0]);
}
//###############//
::::::::::::::
cs19c##.t22.c
::::::::::::::
#include<stdio.h>
int *find(int x[],int y);
void main()
{
int d3,n,i,*p;
int a[100];
printf("Enter d3\n");
scanf("%d",&d3);
printf("Enter no of elements\n");
scanf("%d",&n);
printf("Enter elements\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
p=find(a,n);
printf("Displaying array\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
printf("\n");
for(i=0;i<2;i++)
{
printf("%d",*(p+i));
}
}
int *find(int x[],int y)
{
int z[2],i;
int large=0;
int small=x[0];
for(i=0;i<y;i++)
{
if(x[i]>large)
large=x[i];
if(small>x[i])
small=x[i];
}
z[0]=large;
z[1]=small;
return (&z[0]);
}



Following are submissions from two students. Could they help me to find out what went wrong. Reply by email by June 19.
::::::::::::::
cs19c##.t22.c
::::::::::::::
//#################
#include<stdio.h>
int sum(int a[50],int n)
{    int s=0;
     for(int i=0;i<n;i+=2)
          s+=a[i];
     return s;
}
int main()
{    int n,a[50],s;
     printf("input no. of elements(<50):");
     scanf("%d",&n);
     for(int i=0;i<n;++i)
     {
         printf("element no. %d=",i+1);
         scanf("%d",&a[i]);
       
     }
     s=sum(a,n);
     printf("The array is:");
     for(int i=0;i<n;++i)
         printf("\n%d",a[i]);
     printf("Sum of alternate nos=%d",s);
     return 0;
}

::::::::::::::
cs19c##.t22.c
::::::::::::::
// ##################
#include<stdio.h>
int sum(int a[50],int n)
{    int s=0;
     for(int i=0;i<n;i+=2)
          s+=a[i];
     return s;
}
int main()
{    int n,a[50],s;
     printf("input no. of elements(<50):");
     scanf("%d",&n);
     for(int i=0;i<n;++i)
     {
         printf("element no. %d=",i+1);
         scanf("%d",&a[i]);
       
     }
     s=sum(a,n);
     printf("The array is:");
     for(int i=0;i<n;++i)
         printf("\n%d",a[i]);
     printf("Sum of alternate nos=%d",s);
     return 0;
}



Following are submissions from two students. Could they help me to find out what went wrong. Reply by email by June 19.
::::::::::::::
cs19c##.t21.c
::::::::::::::
//################
#include<stdio.h>
 void main()
{
 int r,r1;
int d3,d4;
 printf("Enter roll number\n");
 scanf("%d",&r);
 r1=((r+10)*(r+10))+999;
 if(r%2!=0)
{
r=r1/100;
}
else
 {
 r=r1%100;
 }
if(r<10)
r=r+10;
 d3=r%3;
d4=r%4;
 printf("r=%d\n",r);
printf("d3=%d\n",d3);
printf("d4=%d\n",d4);
 }


::::::::::::::
cs19c##.t21.c
::::::::::::::
 //################
 void main()
{
 int r,r1;
int d3,d4;
 printf("Enter roll number\n");
 scanf("%d",&r);
 r1=((r+10)*(r+10))+999;
 if(r%2!=0)
{
r=r1/100;
}
else
 {
 r=r1%100;
 }
if(r<10)
r=r+10;
 d3=r%3;
d4=r%4;
 printf("r=%d\n",r);
printf("d3=%d\n",d3);
printf("d4=%d\n",d4);
 }




17/6
Many have communicated that they have sent files before 6PM and server file upload was delayed.
So, I shall consider those requests positively. Emails are yet to be processed in detail.  If files are sent correctly by email, delay in server upload will not cause a trouble if both versions of files are the same. As an excuse for delay in server upload, some people stated that they came to know of the requirement late - not a an acceptable reason though.


Task for the day:
Write two programs to generate the specific numbers mentioned in Q1 of T2 conducted yesterday for all the students of S2C as a table, with roll number, r, d3, and d4 separated by tab.

(1) First program shall write the output to standard output. And output redirection can be used to store it as a file.
Program name -
cs19cxx.1706.1.c
Redirected output file - cs19cxx.1706.op1.txt

(2) Second program does the same thing, but instead of standard output write the result to a text file.

Program name - cs19cxx.1706.2.c
Output file - cs19cxx.1706.op2.txt

Upload anytime today. Don't send by email.



Meanwhile bear in mind that a file created using structures and fwrite() is a binary file, and not always readable using a text editor/viewer.

Read about these from your favourite sources. Also, explained in our video class, listen again if you wish.

Reminding for nth time:
When
sending me email it should have
Your Name, Roll number, and Class mentioned in it.

I have very short memory space set aside to remember and identify persons just seeing their email id or name!



For that matter it is not a bad practice to reveal our identity when communicating officially, especially with teachers and office personnel.

I am reiterating the statement made in the wee hours of today  that if sent by email in right time, in right format, late server uploads will not cause any trouble, provided you upload the same contents.

Since, I am receiving many emails from S2C, it will be difficult to answer individually.  I will read them and decide.

We have been training to upload files for a week or so. Have you used that opportunity, many of the excuses could have been avoided.

And, if a system doesn't permit you to process files without some specific extensions, my opinion is to  abandon that environment and move where every file format is permitted.

Of course, when you disregard a teacher's instruction and proceed ahead differently, that is your choice, but again my suggestions is, that different method should be better than what the teacher is suggesting such that whatever task given by the teacher is still implementable without excuse!

Become Computer Science & Engineering folks at the earliest! Accept challenges as opportunities!!

 
16/6
There will be three programming questions with different levels of difficulty. You have to type in the code before submission. No handwritten submission. All program files should have your name and roll number written on top as comments.

 The program files and data files should be sent via email and also uploaded to the server.

Be careful to use the file names as instructed. All file names should be in small letters.

Send the files from your own personal email id, which were provided by the class rep to me.
Send only one email at the end attaching all the files.
Upload files individually or combined as you like.

The questions are so diverse that there will be  no scope to argue that "we have referred the same text and notes" to have identical answers.

Program file names to be uploaded and send via email
Question 1: cs19cxx.t21.c
Question 2: cs19cxx.t22.c
Question 3: cs19cxx.t23.c

Two data files are to be uploaded for Question 3 only:
Data file names are mentioned in the question.


The first question will generate some numbers which will be used in questions 2 and 3. So, after 30 minutes, if you are struggling with the first question, and wish to proceed to solve the next two, please email me with your identity(Name, roll number, class-S2C) asking for the said generated numbers. I shall reply you with the answer.
Query: "Sir, I could not generate Q1 answers. Please provide me them".
Name:
Roll No: cs19cxx
Class: S2C


For verification of answers of question 1 also you could email me with the values you got.
Only if you are not sure.

Query: "Sir,  I have generated the numbers as ............... Are they correct?"
Name:
Roll No: cs19cxx
Class: S2C

Answering, file uploading, sending files by email all should be completed by 6PM strictly..


Question paper

list.txt file


Programs should be  compilable in Linux.


Downloaded the files from the server at 18.11.
See this -------- 94M Jun 16 17:55 list.n.08
Why such a big file? What is in it?


Think of me please.
I have to deal with possibly 5x62 = 310 files.
So, follow the instructions strictly.
I will
only look into submissions strictly adhered to instructions - that is only possible.


Thank you Sir/Madam. Hope you all have performed well.

List of files with  time, and size downloaded from server at 18.11 hrs. --- down.txt

I am using C programs and shell scripts to for my academic work including evaluations. So, my programs won't see your files with wrong file names.
Why are you making such errors even after repeated warnings?
Don't be casual with online activities.

Also, read the instructions on your own.

The line "list.txt file" written above was interpreted as a file name
"list.txt.file" by someone wrongly.
Fed up replying by email. That is only a message with a link. Real file name is at the link. The file name is list.txt. Stop blaming me for every one's fault! I am responsible for my fault definitely!!.

Files downloaded  from server at 19.23 and 22.49 hrs -- down2.txt    and down3.txt

Just downloaded. Decisions pending.



15/6
Task: From s2c.hl display the details of 5 each students on either side of your roll number (exclude you).  Consider the roll numbers in a circular fashion. ie. next number after 62 is 01. Use seek file operation in the code.
Upload the code as cs19cxx.1506.c
Upload anytime on 15/6

Upload check: 
bash /home/ask/fexist15.sh


Gone thro the first submission -  by 44 - well done.
But, please consider this. To position the 'file position indicator' via fseek the practice is to apply sizeof() instead of hard coding constant values. Don't worry. You may think of the improved code when you are free, within the next 3 days - applicable only for 44.

But, those who are yet commence coding, should consider the above suggestion.

Reminder:
Second series test is scheduled for 16/06/20, 3 - 5PM
Further details about the test will be posted tomorrow.
Questions will be from last two modules.
14/6
Education in general - Engineering education well included, Compute Science study very much there - is not just about somehow score high marks. Definitely scoring high is an important objective. But, we need to tread the ethical path to maximise our numerical credit values.

When a faculty is pointing out some practices which cannot be considered as ethical or seek clarifications, students and if any one involved in framing their reactions should understand that, it is easy to put forth arguments justifying the actions of the students, but they should look into the merit of the issue raised by the faculty. It is their duty to drive the students ethically.

In the present day scenario, it is easy to put the teachers under pressure on these aspects. And, in every walks of life there will be people who would like keep their integrity high and have a strong personal ethical commitment that we should not take decisions based on fear or favour, we should take ethically correct decisions that will help grow the system in which they are working.   Every teacher should try to elevate  to that level - because that is their duty. And I am a teacher.


I will be more happy to see wrong genuine answers, than seeing replica of correct codes among submissions. 

In the two sets of files uploaded, already detected  3 students who have submitted the same files - one in the first 10, one in the third 10, and one in the last 10.  I am making this comment well aware that small programs will be alike.

Under Linux there are many tools to compare the contents of files - no need to visually compare.

So, my general humble request for your own professional development is to cultivate the habit of submitting own contents. Of course you can discuss, share, read and play with others work. But, whatever we submit should be our genuine work.

17:20 11/6's submission: file names verified
01 03 04 05 07 08 10 11 17 19 20 24 26 27 29 31 32 37 38 39 41 42 44 45 46 48 50 52 54 55 58 59 61 62

12/6's submission:
01 02 03 04 05 07 08 10 11 17 19 20 22 24 25 26 27 29 31 32 37 38 39 41 42 44 45 46 48 49 50 52 54 55 58 59 61 62


13/6
If asked to upload files,  do so, if any difficulty, try later.
12/6
Day's task: Upload anytime today.

Using the structure as used to create  s2c.hl yesterday, read and display the following details: Roll number, Name

Upload the code as cs19cxx.1206.c

I will check who have uploaded the files using
 
bash /home/ask/fexist12.sh



Our scheduled second series exam will not be descriptive. It will be asking you to type in the code and send/upload.
Details later.

When sending mail, not just to me, there should be someone responsible - even when representing a group.
So put the name of the person composing  the mail.

Put your roll number and name on top of the program file as a comment.


Yesterday's task: A program demonstrating how to read the contents of the given text file is here. It is also displaying the data. Now it is your turn to use fwrite to create the desired output file.
11/6 Day's task: Upload anytime today.
Read the text file s2c.hl.txt  then create another binary file  s2c.hl using structures with the same content as in the given file.
Do not write the serial number into the  new file. All fields shall be characters or strings.
The fields are - admno, rollno, name,  gender

Upload only the c program as cs19cxx.1106.c and s2c.hl
(all letters are small)
Upload options (be in the directory where the file exists)

1) rsync   -a  {cs19cxx.1106.c,s2c.hl}    cs19cxx@14.139.189.217:

or

2) scp   {cs19cxx.1106.c,s2c.hl}   cs19cxx@14.139.189.217:


Be careful with filenames.

Check with   bash /home/ask/fexist11.sh


When a task is given, even if it is not complete, upload what is available before deadline.

Ensure that uploaded files have read permission for others.

Expected that the program should read the given file.


Files uploaded by:  05 17
10/6
10.30 session will commence as usual

Link: https://meet.jit.si/cec-cs-ask-day7

Youtube Link

files    frwk.c   bfswap.c  

Absentees:  21 22 23

Our regular sessions are over. So, if you need any further sessions on any topics please convey me via your student rep.

Second series test is scheduled for 16/06/20, 3 - 5PM

From tomorrow onward, we shall solve some simple problems and upload the code and associated files. Details will be posted daily. Upload the files to record attendance.
9/6
Day's session link will be posted after 12.15

Session Link: https://meet.jit.si/cec-cs-ask-d6

Youtube link

Day's files   frwm.c    bfops.c
 
Absentees: 18 21 22 47
8/6
9.30 session link will be posted after 9.15

Session Link: https://meet.jit.si/ceccsaskdayfive

Youtube Link

Absentees: 12 21 22

Day's files:

frw.c    frwn.c     marks.txt      marksn.txt


The task: Separate roll number, and total marks via structures. Spend 30 minutes on the task. That will be enough.
You may not be able to easily solve it. 



7/6
File-names of work given on 5/6 seen okay: 01 02 03 04 05 06 07 08 10 11 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 61 62

Referring to the last comment on the previous day, during the test, if any of you have shared the answers between yourselves, please admit it now and send me email. If I detect any malpractice, then the course of action will be decided by the institution. So it is your chance for self correction. Those who have not indulged in such things please ignore this message.

Seen that some answer papers are sent from colleagues email id. That indicates that before submission you have shared it. Not acceptable.

The student rep please send me a copy of the email ids of your class, with roll number, name, and email id columns.

Similarity of answers among 10, and 11 is to be investigated, especially the similarity  of mistakes.

Reminding, it is your chance now ......

Currently reached only 7 papers.


Whatever be it, if you have done it in good faith, gentleman's approach is to tell first, instead of leaving it for detection and subsequent arguments.


6/6
Uploads so far with correct filenames: 01 02 03 05 06 07 08 13 15 17 19 20 22 24 25 27 33 39 41 42 43 44 45 46 51 52 53 55 58 62

After uploading the files, if you want to check whether the files are correct and in proper place
login to the server via ssh and issue the command

bash /home/ask/filename.sh

If your roll number appears in the result then be happy!



T1 evaluation has just commenced.  I need to establish how 7, and 58 have very very similar answers.


5/6
Today there will not be any video session.
But, do the following exercises and upload them to your home folder in the server via your account anytime today.
Server access instructions are posted already.  Also you could learn between yourselves.
Please do not send by email.

Write a program to read via keyboard-input the marks in three subjects of 20 students with roll numbers from 1 to 20. Write the details into a text file named as marks.txt. Close the file.

In the same program open the marks.txt file and compute the total marks and write  the roll number and total marks to a file total.txt. This file should not have the three subject-wise marks.

Your program name shall be cs19cxx.file.c with all lowercase letters.
Day's attendance will be marked based on file upload status.
Hope I will not detect any plagiarism!

Upload all three files.

Time 19:48 ->
I was offline for quite a long time today.
Based on the few emails and server postings seen today, my immediate feed backs are  here.

48 and 26 successfully uploaded in the server. Very good. Please share others how you have done. Other students may consult them also.

Please read the instructions carefully now and ever. I have now highlighted some points above.

It should be marks.txt and not anything else like Marks.txt,  MARKS.TXT etc.

And total.txt and not Total.txt, TOTAL.TXT etc.

Program file is to be exactly cs19cxx.file.c where xx is to be replaced using the digits from your roll number.

Being CS students we should not err on file naming.

All files should be typed in, not scanned.

Server access:
The instructions were posted already.

Reproduced here:


An account is created for each one of you. User name and password are here: cs19cxx - replace xx by your 2-digit roll number. You are advised to change the password.  It is a Linux server, and you could access it via ssh. To upload files you may use scp, ftp, or rsync.

rsync usage example is here: Suppose you want to upload bubblesort.c to your home directory at the server, use the command -
rsync -a bubblesort.c cs19cxx@14.139.189.217:

(there is a colon after 217 here)

Ensure that all the files uploaded are either c programs or .txt files.

And for those with only smart phone access there are some terminal apps like Termux, which you could try. I  do not have much experience on that front though.

Take challenges as opportunities. Upload by anytime tomorrow.

To know the status of your upload
login via
ssh
cs19cxx@14.139.189.217

( there is no colon after 217 here)


issue ls -l
and see that your files are there.

Some errors may happen, may get frustrated - yes all these are part and parcel of life in every walk!

Be patient, things will be on track!!


rsync to upload all 3 files in one shot:
rsync -a {cs19cxx.file.c,marks.txt,total.txt} cs19cxx@14.139.189.217:

Ensure that between the curly braces { and } there is no space character.

Be sure that your local directory has all the three files.



Files seen ok for : 62 07 19 46 20 58 27 61 52 48 39 45 41 01 42 24 25 51 33 22 02

Are 25 41 42 45 using the same system/network?!!



4/6
8:30
Session Link: https://meet.jit.si/ceccsask-d4

To record attendance type in your roll number as
cs19c01 etc

programs and files discussed today

sess.c        t1.txt      t2.txt      a1.txt    heading.c     file.creat.c

Absentees: 22 23

Youtube Video Link


13:46 First Series question will be posted today by 3 PM. Write the answer in paper and scan and send them via email: ask@ceconline.edu

Complete the process by 5.15PM


Here is the Question Paper

Just gone through the header lines of the emails. Thank you all for taking pain to respond as requested. An immediate reaction from me which you may consider in  future - give meaningful file names always.

Also while programming give  
meaningful variable  names.

Now, I have a task ahead - evaluate 62 answer papers looking at the screen!

3/6
10:30

Session Link: https://meet.jit.si/ceccsaskday3

To record attendance type in your roll number as
cs19c01 etc
2/6
For poor audio quality in the 28/5 session I shall put the blame on me instead of Jitsi.

Today(2/6), we will hopefully have the session 1t 12.30 as per TT. It will be in Jitsi Meet - I will enquire with you about the quality at the beginning of the session.

Also on 4/6/ AN we will have the first series test. Be prepared. Details tomorrow. Portions - as announced earlier in March.



Day's session link. Session will be active as far as power is available at my place!

https://meet.jit.si/ceccsaskd2



Thank you all for listening me.
Later, I have observed that the mouse pointer is not visible in the shared screen. Hope to resolve.

Here are the programs we discussed so far.

Day 1 code - as such it will result in segmentation fault, you hopefully know the solution

Day 2 code


If anyone of you have the chat history for the duration before the  power-failure break at my end, please email it.
1/06/20 As until now, I could not connect to College server,  Today's 9.30 session for EST102 will not be there. We will commence tomorrow. May be we have a test session today 7PM. Will announce later.
30/5 Next sessions as per time table from June 1 onward.
28/5 I will be using 'Konsole' and 'micro' (terminal emulator, and in-terminal editor) for the session. You may download and install them.

Advice to use a Linux based system if possible. Else use a smartphone for the session.

link will be posted at 7PM


https://meet.jit.si/ceccsask

Those in android give room name as ceccsask

Absentees:  6 12 14 16 22 24 40 47
27/5/2020 We shall have a video session tomorrow (28/5/20) 7PM via Jitsi Meet.
Details will be posted later.
Please convey to colleagues.

Topic: C pointers. We will start with once again discussing the content posted on 20/4.
The session will last 1 to 2  hours.

If anybody is using institutional resources for attending the class, please inform me by tomorrow 2 PM so that we could schedule it for day time.

Jitsi Meet is simple to use. Either download the app. Or from a browser load the web page.  https://meet.jit.si/
Just enter the room name in the box. That's all. Or you can type the room name in the address bar itself.
No login is required. Assuming that everybody behave responsibly, there will not be any restrictions and all including me will have equal privileges.
Also, you may try it before the class on your own! during the session, ensure that you pin my screen!

Room name of our session will be conveyed close to the commencement of the meet.


Date
Online learning
Aprl 3, 2020
In the wake the Covid-19 lock-down we are resuming our academic activities with respect to the theory portion of this subject here from today.
Here I will explain the remaining portions of our syllabus. You please read and understand the topic. You may refer additional material like books, online videos etc. KTU site has provided some links to online materials.  You could also view video lectures from http://ocw.mit.edu.
It is better to try writing the program on your own and check whether you are getting the desired result.

In case, you want to check your codes or have any doubt, I request you to upload the program or question to this server. For that purpose, an account is created for each one of you. User name and password are here: cs19cxx - replace xx by your 2-digit roll number. You are advised to change the password.  It is a Linux server, and you could access it via ssh. To upload files you may use scp, ftp, or rsync.

rsync usage example is here: Suppose you want to upload bubblesort.c to your home directory at the server, use the command -
rsync -a bubblesort.c cs19cxx@14.139.189.217:

I will check the server everyday and will see the uploaded contents.

Ensure that all the files uploaded are either c programs or .txt files.

---------------------------------------------------------------------------------------------------------------------------------
Now let us begin:-

Arrays as Function Parameters:

When we discussed functions in the class we have learned how to pass scalar data to a function.
Now we learn how to pass an entire array to a function.

See the code below.

#include <stdio.h>

void printarray(int ar[], int no)//function to print an array
{    int i;
      for (i = 0; i < no;i++)
            printf("%d ", ar[i]);
      putchar('\n');
}

main()
{    int n=10;
      int a[10] = {3,5,4,1,8,2,9,6,0,7};
      printf("%-15s", "Array:");
      printarray(a, n);
}


In above code, we have defined a function  to print an array. The arguments passed are an array, and its size.
This function is called from the main() function. A function is executed only if it is called from somewhere else.
main() function will be executed as the starting function.

See the three ways in which the array is used:
Array declaration: a[10]
Function parameter declaration: ar[]
Function calling: a

Please code this and get yourself ready for further learning.
Also, try this: Write a function to sum the elements of an array.  Use this function in a program to find the sum of an array.
********************
Repeating the same mantra gain! Write the code well indented.

This method of passing array as an argument to a function is called "call by reference". Here, a reference or an address of the array is passed  to the function. Remember that the method we have learned previously is called "call by value" - where when we call a function the value of the scalar variable declared at the top of the function is passed by the calling code segment.

So in the call-by-reference method used in the above example, the address of the array a is passed. The function stores  this address  at ar and it is used to access the array.

**
If you are using the server account, to change the password, after logging in type "passwd" and press enter key.
 
4/4/20
ssh login instructions:
From a Linux system, open a terminal and type
ssh cs19cxx@14.139.189.217

From smartphone you may install a terminal app and try.
From Windows either use virtual OS options to use Linux, or there may be sites helping to access Linux terminals via web browser -  I haven't used.

But, for comfortable use, better to have a Linux system.
--------------------------------------------------------------------------------------------------------
Continuing with the array-based functions, let us discus a little complex example.
The problem is to read roll numbers and marks in three subjects of n students and then to compute the total marks of each student and also to compute the average marks per subject. it also sorts (selection sort ) the data based on total marks. All operations are performed in-place i.e. the same array is modified.

The program  uses multiple functions to perform different tasks
- To read data and populate the array
- To print the marks
- To compute the total
- To sort the marks
- To swap the positions of two students as part of the sort function

-------
#include <stdio.h>

int readmarks(float M[][5], int c) // rn and marks in three subjects
{  int i,j,n;
    printf("How many students? ");
    scanf("%d",&n);
   
    for (i=0;i<n; i++)
          for (j=0; j<c; j++)
                scanf("%f", &M[i][j]);
    return n;
}

printmarks(float M[][5], int r, int c)
{  int i, j;
    printf("\nR\tM1\tM2\tM3\tT\n");
    printf("-----------------------------------");
    printf("-----------------\n");
    for (i=0; i<r; i++, printf("\n"))
          for (j=0; j<c; j++)
                printf("%.3g\t",M[i][j]);
    printf("-----------------------------------");
    printf("-----------------\n\n");
}

computesess(float M[][5], int r, int c)
{  int i, j;
    for (i=0; i<r; i++)
          M[i][c]  = M[i][1] + M[i][2] + M[i][3];       
}

swap(float M[][5], int r1, int r2, int c)
{  float t;
    int i, j;
    for (j=0; j<c; j++)
    {    t=M[r1][j];
          M[r1][j]=M[r2][j];
          M[r2][j]=t;
    }
}   

sortmarks(float M[][5], int r, int c)
{  int i, j;
    for (i=0; i<r-1; i++)
          for (j=i+1; j<r; j++)
                if (M[i][c] < M[j][c])
                   swap(M,i,j,c+1);
}

computeavg (float M[][5], int r, int c)
{  int i,j;
    for (i=1;i<c;i++)
    {    for (j=1;j<r;j++)
                M[r][i]+=M[j][i];
          M[r][i]/=(r-1);
    }
}

main()
{  float Marks[50][5]={0};
    int r, c=4;
    r=readmarks(Marks,c); //r - number of rows = no of students
    printf("r=%d\n",r);
    printmarks(Marks,r,c);
    computesess(Marks,r,c);
    printmarks(Marks,r,c+1);
    sortmarks(Marks,r,c-1);
    printmarks(Marks,r,c+1);
    computeavg(Marks,r,c);
    printmarks(Marks,r+1,c+1);
}
-----------

main() first declares a 2d array of 50x5, sufficient enough  to store the details of 50 students. The details to be stored are - roll number, marks in 3 subjects, and total. Hence the second dimension as 5.
As shown in the code, this 2d array is initialized to zero. Hence all entries initially will be zero.
First the readmarks() function is called. Look at the function definition.  As against the 1d array, here we have to mention the number of columns. It is to help the function to identify row boundaries.
Look also at how the main() calls this fn. Simply readmarks(Marks,c). As in a 1d array only the name of the array needs to be passed. A separate argument c is also passed to tell the number of columns - which is not essential though.
The function reads the marks and stores them in the 2d array. Since arrays are accessed and processed by reference, M[][] and Marks[][]  will access the same memory location. The function after the input process returns the number of rows (no. of students) it read to the main program.

Explanation to be continued tomorrow...

Note: A slight mistake is inserted in the code intentionally. Please correct them on your own.

5/4/20
It seems only very few S2C students have visited here. Hence, no posting today.
6/4/20
We will continue the discussion on the above example.
You may insert a message statement to prompt the user to input the roll numbers and marks in three subjects before the loop in the readmarks() function.

After readmarks() is executed the control goes back to the main(). It prints r, the number of rows or number of students whose marks were read.

Now main() invokes printmarks() function with three arguments:
 - Marks,  the 2d array
 - r, no of rows/students
 - c, number of columns
This function prints the available data in the matrix (or 2d array).
At this stage, even though, space is still there we have not computed the total marks.
Hence total will be empty.


What we learned so far?
How to use a function to populate a 2d array.
Then, how to use this 2d array to print its contents using another function.
Thus, we were able to pass the reference to a 2d array from main() to another function - say readmarks()  - and back.
Then we were able to pass the reference to a 2d array from main() to yet another function - say  printmarks()
7/4
Now the third function - computesess() is invoked by main(). The arguments passed are Marks, r, c.
computesess() simply sums the three marks of every student and stores it as the last column value of every row.

Now, printmarks() is again invoked. But, now the third argument is c+1. Since the total is now ready, it also need to be displayed. Hence c+1.

Next the sortmarks()  function is invoked. It sorts the marks based on total marks. You may spent a few minutes to understand the function.
But main() calls it with one wrong argument in the given code. Could you find out the mistake?
8/4
sortmarks() explained:

sortmarks(float M[][5], int r, int c)
{  int i, j;
    for (i=0; i<r-1; i++)
          for (j=i+1; j<r; j++)
                if (M[i][c] < M[j][c])
                   swap(M,i,j,c+1);
}

It employs a sorting technique called selection sort.  The total marks referred as M[i][c] are considered for sorting. The index i points to starting row first. The index j accesses every subsequent row.
if ith total is less than jth total, the rows are swapped. All entries in the rows are swapped.
So when i is 0, j varies from 1 to r-1, the last row.  At the end of this step the student with highest score moves to the first row.
When i is 1, j varies from 2 to r-1.  At the end of this step the student with second highest score moves to the second row.
When i is 2, j varies from 3 to r-1 -
.
.
Finally, when i is r-2 j has only one value r-1.

Now, the swap function:
swap(float M[][5], int r1, int r2, int c)
{  float t;
    int i, j;
    for (j=0; j<c; j++)
    {    t=M[r1][j];
          M[r1][j]=M[r2][j];
          M[r2][j]=t;
    }
}   

All entries in r1 are swapped with corresponding entries in r2. Here the array is passed by reference, but r1, r2 and number of columns c are passed by value.
There is an unnecessary local variable declared in the function. You may remove it. Since the array is accesses by reference, the swap performed by this function modifies the array. Hence change persists throughout the program.
To see the sorted version, the printmarks() function is again invoked by main().

9/4
computeavg (float M[][5], int r, int c)
{  int i,j;
    for (i=1;i<c;i++)
    {    for (j=1;j<r;j++)
                M[r][i]+=M[j][i];
          M[r][i]/=(r-1);
    }
}

Now, this function is supposed to compute the average of each subject.
The first index i here represents the column, because the marks of the one subject appears  vertically.
j indicates the row number  as for every subject every student's marks are added to the next row.
After one subject's marks are summed, its average is calculated. This calculation is outside the inner loop, but inside the outer loop.

Have you verified whether you are getting the correct average?
If not, verify it now before reading further.


Actually, there are two mistakes (not compile errors) in this function. Correct those slight mistakes to get the correct average!


You may make a slight modification to this function to compute the overall average across all subjects. Try that also.

10/4
Now we will discuss structures in C.
Till time we have used scalar data types, and arrays. Both using the same data type. But in real situations we need to process data of heterogeneous type together. For example, when we process the academic data of students, we have to deal with different data types - roll numbers as integers or alphanumeric strings, names as strings, marks as integers, grades as characters, gpa as float etc.  In such situations we may use structure data type. The word struct is a C key word. Structures are user defined. The name and details are defined by the programmer.

Let us take another slightly lengthy program to discuss it.
The purpose is to compute the sessional marks of S2C in a subject. Maximum sessional is 50. The input data are two assignment marks, two test marks, an attendance mark per student.
Each assignment  marks will be converted to 7.5 base, and each test marks will be converted to 12.5 base.

First let us define a structure named as stud as follows:

struct stud
{    int rn; //roll number
      float a1,a2,t1,t2,a; // assignment  marks, test marks, attendance mark
      int s; //sessional
};

For simplicity we have used only int and float here. Any other data type could also be used to represent a component of the structure. Here stud is the name of the structure data type we have defined.


Once this is understood we will use it in a main() to read the marks.

--------------------------------------------------------------------------------
#include <stdio.h>

struct stud
{    int rn;
      float a1,a2,t1,t2,a;
      int s;
};

readmarks(struct stud s[],  int r)
{    int i;
      printf(" First Enter the marks of student 0 to record the maximum marks in each component\n");
      for (i=0; i<r; i++)
     {     s[i].rn=i;
            printf("Enter marks of student %d:  A1  A2  T1  T2  Att ",i);
       
            scanf("%f %f %f %f %f", &s[i].a1, &s[i].a2, &s[i].t1, &s[i].t2, &s[i].a);
     }
}


main()
{    struct stud st[64]={0};
      int r;

      printf("Enter number of students: ");
      scanf("%d",&r);
      r++;

      readmarks(st,r);
}

-----------------------------------------------------------------------
Now let us explain the code.
struct stud is defined - we have explained and understood  it already.
Now in main() we are declaring an array named  st of structures of size 64.
And each value of the structure is initialized to zero.
r to represent the roll number.
First read how many students are there.
r is incremented by one to represent a dummy student with roll number 0.
The purpose will be clearer later.
Normally the faculty conducts tests for 50 marks and the assignment max marks may vary from faculty to faculty.
Against the dummy student 0 we enter the maximum marks for each component, which will be converted to appropriate weight in the program. We will discuss that later.



Now the readmarks() function is called by main()
The arguments passed are st by call-by-reference and r by call-by-value.
The matching variables in the function are s and r.
An internal variable i is used inside the readmarks() function.
It reads the A1, A2, T1, T2, and Att marks in that order of every student.

The new thing in the scanf portion is how structure elements are accessed. The dot operator is used to access the members.
Note that the subscripts are mentioned before the dot operator.

Compile it and run it.
Also, try to write a function to print the data we read through readmarks().

To be continued....
 

*** Meanwhile it seems that only very few S2C students are accessing this. Those who happens to see this, please convey others to access this site.

11/4
Now we will discuss  the printmarks() function.

printmarks(struct stud s[], int r)
{    int i;
      printf("\nR\tA1\tA2\tT1\tT2\tA\tS\n");
      printf("-----------------------------------");
      printf("-----------------\n");
      for (i=0; i<r; i++, printf("\n"))
            printf("%d \t%.3g \t%.3g \t%.3g \t%.3g \t%.3g \t%d", s[i].rn,s[i].a1,s[i].a2,s[i].t1,s[i].t2,s[i].a,s[i].s);
      printf("-----------------------------------");
      printf("-----------------\n\n");
}

And the main() is modified as below.

main()
{    struct stud st[64]={0};
      int r;

      printf("Enter number of students: ");
      scanf("%d",&r);
      r++;

      readmarks(st,r);
      printmarks(st,r);
}
----------------
Once the  readmarks() function is understood, printmarks() is straightforward.


Now, we will compute the sessional.


computesess(struct stud M[], int r)
{    int i;
      float s;
      for (i=0; i<r; i++)
     {    s  = M[i].a1*7.5/M[0].a1;
           s += M[i].a2*7.5/M[0].a2;
           s += M[i].t1*12.5/M[0].t1;
           s += M[i].t2*12.5/M[0].t2;
           s += M[i].a;
          M[i].s=s+.5;
     }       
}
---------------------


Th input arguments are the same.
An internal variable s is used to store the sessional temporarily. Finally it is written to the structure.
Let us explain this line:
s  = M[i].a1*7.5/M[0].a1;
We have stated that the first row (with student roll no. 0) will carry the maximum marks for each component.
The above statement converts the first assignment marks of student i  to base 7.5 and the value is assigned to s.
Subsequent statements add other sessional components to s. Final s written to the structure.


main() will now look like below.

main()
{    struct stud st[64]={0};
      int r;

      printf("Enter number of students: ");
      scanf("%d",&r);
      r++;

      readmarks(st,r);
      printmarks(st,r);
     
     computesess(st,r);
     printmarks(st,r);

}



To be continued.

13/4
Now we will sort the marks, such that the highest scorer will come to the top. We will retain row 0 intact.



sortmarks(struct stud M[], int r)
{    int i, j;
      for (i=1; i<r-1; i++)
           for (j=i+1; j<r; j++)
               if (M[i].s < M[j].s)
                  swap(M,i,j);
}


The sorting is straightforward if we had understood the same sorting process in the previous  example.

But the swap() requires an explanation.

swap(struct stud M[], int r1, int r2)
{    struct stud T=M[r1];
      M[r1]=M[r2];
      M[r2]=T;
}  

It swaps two entire rows, r1 and r2.
More importantly, see the declaration of T. It is of type struct stud, but holds  the data of one student only. But, M[] is an array of structure.
When we say,  T=M[r], it means each element (rn,a1,a2,t1,t2,a,s)  of M[r] is copied to corresponding elements of T.

Now, the complete program is here:

//structure demo
//CEC CS S2C 2020 -  ask
#include <stdio.h>

struct stud
{    int rn;
      float a1,a2,t1,t2,a;
      int s;
};

readmarks(struct stud s[],  int r)
{    int i;
      printf(" First Enter the marks of student 0 to record the maximum marks in each component\n");
      for (i=0; i<r; i++)
      {     s[i].rn=i;
            printf("Enter marks of student %d:  A1  A2  T1  T2  Att ",i);
       
            scanf("%f %f %f %f %f", &s[i].a1, &s[i].a2, &s[i].t1, &s[i].t2, &s[i].a);
      }
}

printmarks(struct stud s[], int r)
{    int i;
      printf("\nR\tA1\tA2\tT1\tT2\tA\tS\n");
      printf("-----------------------------------");
      printf("-----------------\n");
      for (i=0; i<r; i++, printf("\n"))
           printf("%d \t%.3g \t%.3g \t%.3g \t%.3g \t%.3g \t%d", s[i].rn,s[i].a1,s[i].a2,s[i].t1,s[i].t2,s[i].a,s[i].s);
      printf("-----------------------------------");
      printf("-----------------\n\n");
}

computesess(struct stud M[], int r)
{    int i;
      float s;
      for (i=0; i<r; i++)
      {    s  = M[i].a1*7.5/M[0].a1;
            s += M[i].a2*7.5/M[0].a2;
            s += M[i].t1*12.5/M[0].t1;
            s += M[i].t2*12.5/M[0].t2;
            s += M[i].a;
           M[i].s=s+.5;
      }       
}
swap(struct stud M[], int r1, int r2)
{    struct stud T=M[r1];
      M[r1]=M[r2];
      M[r2]=T;
}   

sortmarks(struct stud M[], int r)
{    int i, j;
      for (i=1; i<r-1; i++)
           for (j=i+1; j<r; j++)
                 if (M[i].s < M[j].s)
                    swap(M,i,j);
}

main()
{    struct stud st[64]={0};
      int r;

      printf("Enter number of students: ");
      scanf("%d",&r);
      r++;

      readmarks(st,r);
      printmarks(st,r);

      computesess(st,r);
      printmarks(st,r);

      sortmarks(st,r);
      printmarks(st,r);
}                       

15/4
Union

C union allows a mechanism whereby two or more variables of same or different type share the same data (stored in memory). It is also a user defined data type.
First a simple example.

#include <stdio.h> //union

main()
{    union ut
     {    int x;
           int y;
     } xy;
   
     xy.x=5;
     printf("%d %d \n", xy.x, xy.y);

     xy.y=10;
     printf("%d %d \n", xy.x, xy.y);
   

}


Here we have defined a union type named ut. Along with that we have also declared a variable xy of type union ut.  xy has two elements x and y, They share the same storage space.
First x is assigned with 5, and both x and y generates 5 when printed. When y is assigned with 10, and both x and y generates 10 when printed.


Now let us have another example where the union elements are of different type.

#include <stdio.h>

main()
{    union ut
     {    int x;
          int y;
          char z;
     } xy;
   
     xy.x=5;
     printf("%d %d %d\n", xy.x, xy.y, xy.z);
     printf("%p %p %p %p\n", &xy, &xy.x, &xy.y, &xy.z);

     xy.y=400;
     printf("%d %d %d\n", xy.x, xy.y, xy.z);
   
   
}


The following line prints address:
printf("%p %p %p %p\n", &xy, &xy.x, &xy.y, &xy.z);

They are all same.

After modifying the value, the last line prints the data again.
But, z prints a different value. Can anyone explain exactly why?
16/4
When union is used each element will take its allocated bytes of memory from the starting location of the union. If one element is scalar and the other element is an array then only the first location of the array is used for sharing. Example is here:

#include <stdio.h>
//union demo CEC S2C.20 - ask
main()
{    union ut
     {    int x;
           int y;
           char z;
           int a[2];
      } xy;
   
      xy.x=5;
      printf("%d %d \n", xy.x, xy.y);
   
      printf("%p %p %p %p %p  %p \n", &xy, &xy.x, &xy.y, xy.a, &xy.a[0], &xy.a[1]);

      xy.y=8;
      printf("%d %d %d\n", xy.x, xy.y, xy.z);
   
      xy.a[0]=10;
      xy.a[1]=20;

      printf("%d %d %d %d %d\n", xy.x, xy.y, xy.z, xy.a[0], xy.a[1]);
   
   
}


18/4
Storage Classes, Scope and life time of variables:

Storage classes are used to declare where shall  variables or sometimes functions reside/exist. The four classes are auto, static, register, extern. Storage classes also have a role in deciding the scope of variables.

Scope of variable refers to where shall a particular variable be available or accessible.

Lifetime of a variable refers to till when that variable is available. 
 
auto: Variables when declared are by default are auto. They reside in stack memory. They exist (scope) as far as the block in which they are declared exists.

static: Variables that are available within a block, but retains the value even afterwards. So, if the same block is reached again previous value of the static variable exists.
Functions can also be declared as static. Normally functions are global. But, static functions should reside in the same file as the calling block.

register: A variable is declared register when very fast and frequent accesses are required. Such variables reside in the register memory of the CPU. Scope and life - within the block.

extern: A variable declared outside the block, may be in another file. Scope is global and life is program life.
Functions are extern by default. Their scope can be limited by static explained earlier.

 Example program

#include <stdio.h>
//scope demo
//CEC S2C 2020  - ask

int global = 10;

int fn()
{    int fni=20;
      global+=20;
      printf(" Within fn: fni= %d, global=%d\n",fni,global);
}

main()
{    int maini=15;
      global+=20;
      printf(" Within main: maini= %d, global=%d\n",maini,global);
     {    int maini=70;
           global+=20;
           printf(" Within main sub block: maini= %d, global=%d\n",maini,global);
      }
      printf(" Within main agin: maini= %d, global=%d\n",maini,global);
      fn();
}


Now let us write one more function in another file as below:

file: scopef1.c

#include <stdio.h>
int fn1(int global)
{    int fni=20;
      global+=20;
      printf(" Within fn1: fni= %d, global=%d\n",fni,global);
}

-------------------
Let us modify the main program as below:

file: scope1.c

#include <stdio.h>
//scope demo
//CEC S2C 2020  - ask

int global = 10;

int fn()
{    int fni=20;
      global+=20;
      printf(" Within fn: fni= %d, global=%d\n",fni,global);
}

main()
{    int maini=15;
      global+=20;
      printf(" Within main: maini= %d, global=%d\n",maini,global);
      {    int maini=70;
            global+=20;
            printf(" Within main sub block: maini= %d, global=%d\n",maini,global);
       }
      printf(" Within main agin: maini= %d, global=%d\n",maini,global);
      fn();
      printf(" Within main agin: maini= %d, global=%d\n",maini,global);
      fn1(global);
      printf(" Within main agin: maini= %d, global=%d\n",maini,global);
   
}


-------
Now, compile the two files together as gcc
scope1.c scopef1.c
See and understand the result.

-----------------
Now, make fn1() static as below.


file: scopef1.1.c

#include <stdio.h>
static int fn1(int global)
{    int fni=20;
      global+=20;
      printf(" Within fn1: fni= %d, global=%d\n",fni,global);
}

-------
If compiled (
gcc scope1.c scopef1.1.c) now, it will report an error.

Now, copy the function
fn1() of scopef1.1.c to scope1.c, save it as scope1.1.c,
and comiple it as gcc
scope1.1.c. No errors are reported.

See and understand the result.

19/4
Examples for extern and static variables



Compile and execute the above code. If you are able to explain the result, it indicates that you have understood static variables.


Now, we will see an example for extern:

Let us create two files:
1. ex2.c
with just one line code.


2.  and aother program file ex1.c




-------

Compile them as gcc ex1.c ex2.c

ex is assigned with 5 in ex2.c.  ex1.c declare ex as external variable.So, when compiled with ex2.c the variable becomes declared and defined in ex1.c
See and understand the result. Experiment with the programs.
20/4
Pointers

C pointer is a variable which stores the address of another variable. So a pointer points to a variable. The main purpose is to dynamically allocate memory during program execution.  Before, reaching there let us learn the concepts and play with some examples.

int *p;

means p is a pointer to an integer variable.




Code explained below:

x is declared as integer.
p is declared as a pointer to an integer.

No assignment yet.  So, output is garbage.

Next x is assigned with 30.  So correct output for x, garbage for *p. *p means the content of the address pointed by p.

Next, p is assigned with the address of x.  Hence same output for x and *p.

Next, *p is assigned with 50. Since x and *p are pointing to the same location, same values are printed.

Note that p is an address of variable and hence p= &x;
*p is pointing to an integer location is memory( same location pointed by x).
21/4
Those S2C students who happened to be here, please invite other S2C students also here.
22/4
Planning to be on Jitsi Meet tomorrow after 7PM for discussion with students. Details later. 
23/4
I am there. ceccs
passwd cscec
over
       

Course So Far
Month
Date
Hr.
Progress
Class
Count
QA
Range
Absentees
No. of
Absentees
Late
Remarks
January
2019
13
5,6
Intro, h/w, software, language, syntax-grammar, semantic-meaning, C example - addition of two numbers etc.

2
23-30
31 33 34 35 47 52 61 1 12
9



14
3
ax+b=0 discussion, flowchart, algorithm, program.
algorithm - function style later
program - if else - floating point calculation and output issues later. printf, scanf.
3
31-36
32 2 20 46 53
5



15
3
While loop - temperature conversion C to F.
4
37-38
19 24 36 62
4



15
4
For loop  - above example, marks total example.
5
39-45
36 62
2



16
5
Array Intro -  read, store, search. Q: average of marks - subjects, and total
6
46-50
46 47
2



21
5
Some linux commands, Q answer discussion, arithmetic expression - floating point conversion.
7
51-5






22
2
RAM, secondary storage, nested loop. Q: model, watt, qty, price bulb total
8
6-13





23
1
Logical & relational operators. Largest of 3 - different methods.
9
6-10
37
1



28
3
switch case, break, do -while
10
14-15
45
1
34 42


29
2
solve quadratic eqn; exit, return; math.h; gcc -lm
11
16-19
30
1



30
1
Array revision as requested. Also discussed about number systems.
12
20-25


9 35 23 51

February
4
4
Program indentation, symbolic constants, getchar(),  EOF, long, double, empty loop;
13
26-36
50 51 58 2 6 14 20 23 25 28 29 33 35 40 45 46
16
34 17


5
2
scope, &&, ||, leap year, %
14
37-15





11
4
comp arch, proc, mem, i/o, ap sw, sys sw, compiler, interpreter, hll, lll
15

12 13 14 25 28 33 34 45 47 50 58 59
12
23


12
2
compiler, interpreter, hll, lll, processors - 4 bit to 64 bit, 70s to today, 4004,8008,8080,8085, 8086, 8088, 80286, 80368, 80486, P5, P6, pentium II, multicore, 64 bit processors, i3,i5, i7 etc.
clock 4.7 MHz  to 3GHz, address bus, data bus, control bus, virtual memory  calculation.
16
16-19
20 25 28 30 34 58
6



18
4
pseudo code - bubble sort alg - both directions.
17
20-27
55
1
51 23

19
2
character set, tokens, identifiers, variables, data types, constants, number systems, binary, octal, decimal, hexadecimal, floating point representation.
18
28-34
14 26
2



20
1
sizeof, bitwise operators, operator precedence, goto, ?:
19
35-41
9 23 46
3
51


25
4
string - strlen, atrcpy, strcat, strcmp, puts, gets
20
42-43
9 14 15
3



27
1
functions - need, structure, examples.
21
43
9 14 20 32
4
51 2