Csci 5332/5332g data Comm and Networking



Download 104.18 Kb.
Date21.11.2023
Size104.18 Kb.
#62663
CSF101-S(P1)SAPID-1000021236
SYLLABUS1, CSF101-S(P1)sapid-1000021236




Laboratory Assignment Sheet
Graded Lab Assignment 4 – CSF101 Programming for Problem Solving, 2023 – ODD Semester 2023


Your Name: Kesahv Rawat SAP ID:1000021236 Major: BtechCSE ‘S’



Assignment ID (as per the policy guidelines)

Assignment Title:

Submission Mode:

Assessment Method

Group/
Individual


Weightage:

Date of Release:

Submission Deadline (Date and time)

Graded Lab

Graded Lab-4

Online [In word file]




Individual

5

21/11/2023, 11AM

21/11/2023, 12:50PM

Instructions:



  • In this graded lab assignment, you will solve the problem(s) based on what you have learned in Unit 3-5

  • There are 2 questions in this assignment.

  • Email/paper/other modes of submission will not be accepted.

  • Upload a pdf version of this document.

  • Do not copy the code of other students.



Due Date: 21/11/2023, 12:50PM


Submitting this Assignment
You will submit (upload) this assignment in MS Teams. Name this document as CSF101_SAP-ID_John_Doe.doc in case your name is John Doe. Paste your code and snapshot of output after the question, and save and upload the document.


Grading: 5 points (out of your total 100 points in the course). Full marks will be awarded only when the correct code with a screenshot of your output as desired is submitted.
Problems:

  1. Write a program to print Fibonacci series using recursion.

Code:

  1. #include

  2. int main()

  3. {

  4.  int n1=0,n2=1,n3,i,number;

  5.  printf("Enter the number of elements:");

  6.  scanf("%d",&number);

  7.  printf("\n%d %d",n1,n2);

  8.  for(i=2;i

  9.  {

  10. n3=n1+n2;

  11. printf(" %d",n3);

  12. n1=n2;

  13. n2=n3;

  14.  }

  15. return 0;

  16.  }


Output:



  1. Write a program to create a structure named book and store book information such as book name, title, author, publisher, price and edition of 5 books using structure. Note: Use the concept of Structures and array of structure.

Code:

#include


struct Book {
char name[300];
char title[300];
char author[300];
char publisher[300];
float price;
int edition;
};
int main() {
struct Book books[5];
for (int i = 0; i < 5; i++) {
printf("Enter details for Book %d:\n", i + 1);
printf("Name: ");
scanf("%s", books[i].name);
printf("Title: ");
scanf("%s", books[i].title);
printf("Author: ");
scanf("%s", books[i].author);
printf("Publisher: ");
scanf("%s", books[i].publisher);
printf("Price: ");
scanf("%f", &books[i].price);
printf("Edition: ");
scanf("%d", &books[i].edition);
printf("\n");
}
printf("Details of 5 books:\n");
for (int i = 0; i < 5; i++) {
printf("Book %d:\n", i + 1);
printf("Name: %s\n", books[i].name);
printf("Title: %s\n", books[i].title);
printf("Author: %s\n", books[i].author);
printf("Publisher: %s\n", books[i].publisher);
printf("Price: %.2f\n", books[i].price);
printf("Edition: %d\n", books[i].edition);
printf("\n");
}
return 0;
}
Output:


Download 104.18 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page