You are on page 1of 7

NAME: SONU KUMAR KESHRI

ROLL:1904026
ASSIGNMENT 1 CSL3501

CODE 1, 2, 3
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

struct Student {

char* name ;

char* branch;

int roll_number, maths , drawing , physics;

};

int main()

int i = 0, n = 5;

struct Student student[n];

student[0].roll_number = 1;

student[0].name = "Abcd";

student[0].branch ="ECE";
student[0].maths =89;

student[0].drawing =86;

student[0].physics =84;

student[1].roll_number = 2;

student[1].name = "Acd";

student[1].branch ="ECE";

student[1].maths =81;

student[1].drawing =85;

student[1].physics =84;

student[2].roll_number = 3;

student[2].name = "Abd";

student[2].branch ="ECE";

student[2].maths =89;

student[2].drawing =66;

student[2].physics =84;

student[3].roll_number = 2;

student[3].name = "bcd";

student[3].branch ="ECE";

student[3].maths =89;

student[3].drawing =86;

student[3].physics =84;

student[4].roll_number = 5;

student[4].name = "Aud";

student[4].branch ="ECE";

student[4].maths =89;

student[4].drawing =86;

student[4].physics =84;
printf("Student Records:\n");

for (i = 0; i < n; i++) {

printf("Name = %s\n", student[i].name);

printf("Roll Number = %d\n", student[i].roll_number);

printf("Branch = %s\n", student[i].branch);

printf("Maths = %d\n", student[i].maths);

printf("Drawing = %d\n", student[i].drawing);

printf("Physics = %d\n", student[i].physics);

return 0;

OUTPUT:

Student Records:

Name = Abcd

Roll Number = 1

Branch = ECE

Maths = 89

Drawing = 86

Physics = 84

Name = Acd

Roll Number = 2

Branch = ECE

Maths = 81

Drawing = 85

Physics = 84

Name = Abd

Roll Number = 3
Branch = ECE

Maths = 89

Drawing = 66

Physics = 84

Name = bcd

Roll Number = 2

Branch = ECE

Maths = 89

Drawing = 86

Physics = 84

Name = Aud

Roll Number = 5

Branch = ECE

Maths = 89

Drawing = 86

Physics = 84

Process returned 0 (0x0) execution time : 0.061 s

Press any key to continue.

#include <stdio.h>

#include <stdlib.h>

int main()

int num1,num2,i,count=0,j;

printf("Enter a number 1\n");

scanf("%d",&num1);

printf("Enter a number 2\n");

scanf("%d",&num2);

printf("The prime number between the numbers are:");


for(i=num1; i<=num2;i++){

count=0;

for(j=1;j<=i;j++){

if(i%j==0){

count++;

if(count==2){

printf("%d\n",i);

return 0;

OUTPUT:

Enter a number 1

10

Enter a number 2

50

The prime number between the numbers are:11

13

17

19

23

29

31

37

41

43

47
Process returned 0 (0x0) execution time : 10.534 s

Press any key to continue.

#include<stdlib.h>

#include<stdio.h>

int f(int);

int main()

int n, i = 0, c;

printf("Enter the number upto which Fibonacci series must be shown:\n");

scanf("%d", &n);

printf("Fibonacci series terms are:\n");

for (c = 1; c <= n; c++)

printf("%d\n", f(i));

i++;

return 0;

int f(int n)

if (n == 0 || n == 1)

return n;

else

return (f(n-1) + f(n-2));

OUTPUT :
Enter the number upto which Fibonacci series must be shown:

15

Fibonacci series terms are:

13

21

34

55

89

144

233

377

Process returned 0 (0x0) execution time : 7.975 s

Press any key to continue.

You might also like