SlideShare una empresa de Scribd logo
1 de 58
Descargar para leer sin conexión
C Programming Lab
BCA 105
/* C program to print Hello World! */
#include <stdio.h>
int main()
{
printf("Hello World!");
return 0;
}
/* C program to print Hello World using function */
#include <stdio.h>
// function to print Hello World!
void printMessage(void)
{
printf("Hello World!");
}
int main()
{
//calling function
printMessage();
return 0;
}
/* C Program to find sum of two numbers */
#include<stdio.h>
int main() {
int a, b, sum;
printf("n Enter two no: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum : %d", sum);
return(0);
}
/* Check Whether Number is Prime or not */
#include<stdio.h>
int main()
{
int num, i, count = 0;
printf("Enter a number:");
scanf("%d", &num);
for (i = 2; i <= num / 2; i++)
{
if (num % i == 0)
{
count++;
break;
}
}
if (count == 0)
printf("%d is a prime number", num);
else
printf("%d is not a prime number", num);
return 0;
}
/* Factorial of a Number*/
#include <stdio.h>
int main() {
int n, i;
unsigned long long fact = 1;
printf("Enter an integer: ");
scanf("%d", &n);
// shows error if the user enters a negative integer
if (n < 0)
printf("Error! Factorial of a negative number doesn't exist.");
else {
for (i = 1; i <= n; ++i) {
fact *= i;
}
printf("Factorial of %d = %llu", n, fact);
}
return 0;
}
/* Swap Numbers Using Temporary Variable*/
#include<stdio.h>
int main()
{
double first, second, temp;
printf("Enter first number: ");
scanf("%lf", &first);
printf("Enter second number: ");
scanf("%lf", &second);
// Value of first is assigned to temp
temp = first;
// Value of second is assigned to first
first = second;
// Value of temp (initial value of first) is assigned to second
second = temp;
printf("nAfter swapping, firstNumber = %.2lfn", first);
printf("After swapping, secondNumber = %.2lf", second);
return 0;
}
/* C Program to generate the Fibonacci Series starting from any two numbers*/
#include<stdio.h>
int main()
{
int first, second, sum, num, counter = 0;
printf("Enter the term : ");
scanf("%d", &num);
printf("n Enter First Number : ");
scanf("%d", &first);
printf("n Enter Second Number : ");
scanf("%d", &second);
printf("n Fibonacci Series : %d %d ", first, second);
while (counter < num)
{
sum = first + second;
printf("%d ", sum);
first = second;
second = sum;
counter++;
}
return (0);
}
/* C Program to find greatest in 3 numbers*/
#include<stdio.h>
int main()
{
int a, b, c;
printf("nEnter value of a, b & c : ");
scanf("%d %d %d", &a, &b, &c);
if ((a > b) && (a > c))
printf("na is greatest");
if ((b > c) && (b > a))
printf("nb is greatest");
if ((c > a) && (c > b))
printf("nc is greatest");
return(0);
}
•
/* Program to relate two integers using =, > or < symbol using C if...else Ladder*/
#include <stdio.h>
int main()
{
int number1, number2;
printf("Enter two integers: ");
scanf("%d %d", &number1, &number2);
//checks if the two integers are equal.
if(number1 == number2) {
printf("Result: %d = %d",number1,number2);
}
//checks if number1 is greater than number2.
else if (number1 > number2) {
printf("Result: %d > %d", number1, number2);
}
//checks if both test expressions are false
else {
printf("Result: %d < %d",number1, number2);
}
return 0;
}
/* Example of while loop*/
#include <stdio.h>
int main()
{
int count=1;
while (count <= 4)
{
printf("%d ", count);
count++;
}
return 0;
}
/* do...while loop in C*/
#include <stdio.h>
int main ()
{
/* local variable definition */
int a = 10;
/* do loop execution */
do {
printf("value of a: %dn", a);
a = a + 1;
}while( a < 20 );
return 0;
}
/* for loop in C*/
#include <stdio.h>
int main () {
int a;
/* for loop execution */
for( a = 10; a < 20; a = a + 1 ){
printf("value of a: %dn", a);
}
return 0;
}
/*Nested For Loop in C*/
#include <stdio.h>
int main()
{
for (int i=0; i<2; i++)
{
for (int j=0; j<4; j++)
{
printf("%d, %dn",i ,j);
}
}
return 0;
}
/* Switch Statement in C*/
1. #include <stdio.h>
2. int main ()
3. {
4. /* local variable definition */
5. char grade = 'B';
6. switch(grade) {
7. case 'A' :
8. printf("Excellent!n" );
9. break;
10. case 'B' :
11. case 'C' :
12. printf("Well donen" );
13. break;
14. case 'D' :
15. printf("You passedn" );
16. break;
17. case 'F' :
18. printf("Better try againn" );
19. break;
20. default :
21. printf("Invalid graden" );
22. }
23. printf("Your grade is %cn", grade );
24. return 0;
25. }
1. /* continue statement in C*/
2. #include <stdio.h>
3. int main ()
4. {
5. /* local variable definition */
6. int a = 10;
7.
8. /* do loop execution */
9. do {
10.
11. if( a == 15) {
12. /* skip the iteration */
13. a = a + 1;
14. continue;
15. }
16.
17. printf("value of a: %dn", a);
18. a++;
19.
20. } while( a < 20 );
21.
22. return 0;
23. }
/* Example of goto statement*/
1. #include <stdio.h>
2. int main()
3. {
4. int sum=0;
5. for(int i = 0; i<=10; i++){
6. sum = sum+i;
7. if(i==5){
8. goto addition;
9. }
10. }
11. addition:
12. printf("%d", sum);
13. return 0;
14. }
• Output:
• 15
• Explanation: In this example, we have a label addition and when the value of i
(inside loop) is equal to 5 then we are jumping to this label using goto. This is
reason the sum is displaying the sum of numbers till 5 even though the loop is set
to run from 0 to 10.
/* prime Numbers between Two Integers using function*/
1. #include <stdio.h>
2. int checkPrimeNumber(int n);
3. int main()
4. {
5. int n1, n2, i, flag;
6. printf("Enter two positive
integers: ");
7. scanf("%d %d", &n1, &n2);
8. printf("Prime numbers
between %d and %d are: ", n1,
n2);
9. for (i = n1 + 1; i < n2; ++i)
10. {
11. // flag will be equal to 1 if i
is prime
12. flag =
checkPrimeNumber(i);
13. if (flag == 1)
14. printf("%d ", i);
15. }
16. return 0;
17. }
18. // user-defined function to
check prime number
19. int checkPrimeNumber(int n)
20. {
21. int j, flag = 1;
22. for (j = 2; j <= n / 2; ++j) {
23. if (n % j == 0) {
24. flag = 0;
25. break;
26. }
27. }
28. return flag;
29. }
/* Sum of Natural Numbers Using Recursion*/
1. #include <stdio.h>
2. int sum(int n);
3. int main()
4. {
5. int number, result;
6. printf("Enter a positive integer: ");
7. scanf("%d", &number);
8. result = sum(number);
9. printf("sum = %d", result);
10. return 0;
11. }
12. int sum(int n)
13. {
14. if (n != 0)
15. // sum() function calls itself
16. return n + sum(n-1);
17. else
18. return n;
19. }
/* Function call by Value in C*/
1. #include <stdio.h>
2. /* function declaration */
3. void swap(int x, int y);
4. int main ()
5. {
6. /* local variable definition */
7. int a = 100;
8. int b = 200;
9. printf("Before swap, value of a : %dn", a );
10. printf("Before swap, value of b : %dn", b );
11. /* calling a function to swap the values */
12. swap(a, b);
13. printf("After swap, value of a : %dn", a );
14. printf("After swap, value of b : %dn", b );
15. return 0;
16. }
17. void swap(int x, int y)
18. {
19. int temp;
20. temp = x; /* save the value of x */
21. x = y; /* put y into x */
22. y = temp; /* put temp into y */
23. return;
24. }
• /* Function call by reference in C*/
1. #include <stdio.h>
2. int main ()
3. {
4. /* local variable definition */
5. int a = 100;
6. int b = 200;
7. printf("Before swap, value of a : %dn", a );
8. printf("Before swap, value of b : %dn", b );
9. /* calling a function to swap the values */
10. swap(&a, &b);
11. printf("After swap, value of a : %dn", a );
12. printf("After swap, value of b : %dn", b );
13.
14. return 0;
15. }
16. void swap(int *x, int *y)
17. {
18. int temp;
19. temp = *x; /* save the value of x */
20. *x = *y; /* put y into x */
21. *y = temp; /* put temp into y */
22. return;
23. }
• /* C - Arrays*/
1. #include <stdio.h>
2.
3. int main () {
4.
5. int n[ 10 ]; /* n is an array of 10 integers */
6. int i,j;
7.
8. /* initialize elements of array n to 0 */
9. for ( i = 0; i < 10; i++ ) {
10. n[ i ] = i + 100; /* set element at location i to i + 100 */
11. }
12.
13. /* output each array element's value */
14. for (j = 0; j < 10; j++ ) {
15. printf("Element[%d] = %dn", j, n[j] );
16. }
17.
18. return 0;
19. }
•
• /* Simple Two dimensional (2D) Array Example*/
1. #include<stdio.h>
2. int main()
3. { /* 2D array declaration*/
4. int disp[2][3];
5. /*Counter variables for the loop*/
6. int i, j;
7. for(i=0; i<2; i++) {
8. for(j=0;j<3;j++) {
9. printf("Enter value for disp[%d][%d]:", i, j);
10. scanf("%d", &disp[i][j]);
11. } }
12. //Displaying array elements
13. printf("Two Dimensional array elements:n");
14. for(i=0; i<2; i++) {
15. for(j=0;j<3;j++) {
16. printf("%d ", disp[i][j]);
17. if(j==2){
18. printf("n");
19. } } }
20. return 0;
21. }
/* Store Information in Structure and Display it*/
1. #include <stdio.h>
2. struct student {
3. char firstName[50];
4. int roll;
5. float marks; } s[10];
6. int main()
7. {
8. int i;
9. printf("Enter information of
students:n");
10. // storing information
11. for (i = 0; i < 5; ++i) {
12. s[i].roll = i + 1;
13. printf("nFor roll
number%d,n", s[i].roll);
14. printf("Enter first name: ");
15. scanf("%s", s[i].firstName);
16. printf("Enter marks: ");
17. scanf("%f", &s[i].marks);
18. }
19. printf("Displaying
Information:nn");
20. // displaying information
21. for (i = 0; i < 5; ++i) {
22. printf("nRoll number:
%dn", i + 1);
23. printf("First name: ");
24. puts(s[i].firstName);
25. printf("Marks: %.1f",
s[i].marks);
26. printf("n");
27. }
28. return 0;
29. }
Write a 'C' program to accept customer details such as: Account_no, Name, Balance using structure. Assume
3 customers in the bank. Write a function to print the account no. and name of each customer whose balance
< 100 Rs.
#include<stdio.h>
/* Defining Structre*/
struct bank
{
int acc_no;
char name[20];
int bal;
}b[3];
/*Function to find the details of customer whose
balance < 100.*/
void check(struct bank b[],int n)
/*Passing Array of structure to function*/
{
int i;
printf("nCustomer Details whose Balance < 100
Rs. n");
printf("----------------------------------------------n");
for(i=0;i<n;i++)
{
if(b[i].bal<100)
{
printf("Account Number :
%dn",b[i].acc_no);
printf("Name : %sn",b[i].name);
printf("Balance : %dn",b[i].bal);
printf("------------------------------n");
}
}
}
int main()
{
int i;
for(i=0;i<3;i++)
{
printf("Enter Details of Customer %dn",i+1);
printf("------------------------------n");
printf("Enter Account Number : ");
scanf("%d",&b[i].acc_no);
printf("Enter Name : ");
scanf("%s",b[i].name);
printf("Enter Balance : ");
scanf("%d",&b[i].bal);
printf("------------------------------n");
}
check(b,3); //call function check
return 0;
}
/* C - Unions*/
1. #include <stdio.h>
2. #include <string.h>
3. union Data
4. {
5. int i;
6. float f;
7. char str[20];
8. };
9. int main( )
10. {
11. union Data data;
12. printf( "Memory size occupied by data : %dn", sizeof(data));
13. return 0;
14. }
/* example to define union for an employee in c*/
1. #include <stdio.h>
2. #include <string.h>
3. union employee
4. { int id;
5. char name[50];
6. }e1; //declaring e1 variable for union
7. int main( )
8. {
9. //store first employee information
10. e1.id=101;
11. strcpy(e1.name, "Sonoo Jaiswal");//copying string into char
array
12. //printing first employee information
13. printf( "employee 1 id : %dn", e1.id);
14. printf( "employee 1 name : %sn", e1.name);
15. return 0;
16. }
/* C program to read name and marks of n number of students and store them in a file.*/
1. #include <stdio.h>
2. int main()
3. {
4. char name[50];
5. int marks, i, num;
6. printf("Enter number of students: ");
7. scanf("%d", &num);
8. FILE *fptr;
9. fptr = (fopen("C:student.txt", "w"));
10. if(fptr == NULL)
11. {
12. printf("Error!");
13. exit(1);
14. }
15. for(i = 0; i < num; ++i)
16. {
17. printf("For student%dnEnter name: ", i+1);
18. scanf("%s", name);
19. printf("Enter marks: ");
20. scanf("%d", &marks);
21. fprintf(fptr,"nName: %s nMarks=%d n", name, marks);
22. }
23. fclose(fptr);
24. return 0;
25. }
/* C program to read name and marks of n number of students from and store them in a file. If the file
previously exits, add the information to the file.*/
1. #include <stdio.h>
2. int main()
3. {
4. char name[50];
5. int marks, i, num;
6. printf("Enter number of students: ");
7. scanf("%d", &num);
8. FILE *fptr;
9. fptr = (fopen("C:student.txt", "a"));
10. if(fptr == NULL)
11. {
12. printf("Error!");
13. exit(1);
14. }
15. for(i = 0; i < num; ++i)
16. {
17. printf("For student%dnEnter name: ", i+1);
18. scanf("%s", name);
19. printf("Enter marks: ");
20. scanf("%d", &marks);
21. fprintf(fptr,"nName: %s nMarks=%d n", name, marks);
22. }
23. fclose(fptr);
24. return 0;
25. }
Thank You

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

c-programming-using-pointers
c-programming-using-pointersc-programming-using-pointers
c-programming-using-pointers
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
C lab-programs
C lab-programsC lab-programs
C lab-programs
 
Understanding storage class using nm
Understanding storage class using nmUnderstanding storage class using nm
Understanding storage class using nm
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
C program to check leap year
C program to check leap year C program to check leap year
C program to check leap year
 
C programs
C programsC programs
C programs
 
C Programming
C ProgrammingC Programming
C Programming
 
DataStructures notes
DataStructures notesDataStructures notes
DataStructures notes
 
C basics
C basicsC basics
C basics
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
C++ programs
C++ programsC++ programs
C++ programs
 
Program flowchart
Program flowchartProgram flowchart
Program flowchart
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
Pads lab manual final
Pads lab manual finalPads lab manual final
Pads lab manual final
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
Double linked list
Double linked listDouble linked list
Double linked list
 
Double linked list
Double linked listDouble linked list
Double linked list
 
Basic Programs of C++
Basic Programs of C++Basic Programs of C++
Basic Programs of C++
 

Similar a C lab programs (20)

C Programming Example
C Programming ExampleC Programming Example
C Programming Example
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
week-3x
week-3xweek-3x
week-3x
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
7 functions
7  functions7  functions
7 functions
 
Progr3
Progr3Progr3
Progr3
 
C file
C fileC file
C file
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
C programming function
C  programming functionC  programming function
C programming function
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
 
C lab
C labC lab
C lab
 
Tu1
Tu1Tu1
Tu1
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
B.Com 1year Lab programs
B.Com 1year Lab programsB.Com 1year Lab programs
B.Com 1year Lab programs
 
Data struture lab
Data struture labData struture lab
Data struture lab
 
L25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptxL25-L26-Parameter passing techniques.pptx
L25-L26-Parameter passing techniques.pptx
 
Najmul
Najmul  Najmul
Najmul
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 

Más de Dr. Prashant Vats

Financial fucntions in ms e xcel
Financial fucntions in ms e xcelFinancial fucntions in ms e xcel
Financial fucntions in ms e xcelDr. Prashant Vats
 
3. lookup functions in excel
3. lookup functions in excel3. lookup functions in excel
3. lookup functions in excelDr. Prashant Vats
 
2. date and time function in excel
2. date and time function in excel2. date and time function in excel
2. date and time function in excelDr. Prashant Vats
 
1. statistical functions in excel
1. statistical functions in excel1. statistical functions in excel
1. statistical functions in excelDr. Prashant Vats
 
3. subtotal function in excel
3. subtotal function in excel3. subtotal function in excel
3. subtotal function in excelDr. Prashant Vats
 
2. mathematical functions in excel
2. mathematical functions in excel2. mathematical functions in excel
2. mathematical functions in excelDr. Prashant Vats
 
RESOLVING CYBERSQUATTING DISPUTE IN INDIA
RESOLVING CYBERSQUATTING DISPUTE IN INDIARESOLVING CYBERSQUATTING DISPUTE IN INDIA
RESOLVING CYBERSQUATTING DISPUTE IN INDIADr. Prashant Vats
 
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An OverviewIndia: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An OverviewDr. Prashant Vats
 
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...Dr. Prashant Vats
 
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...Dr. Prashant Vats
 
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIAMETHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIADr. Prashant Vats
 
Computer Software and Related IPR Issues
Computer Software and Related IPR Issues Computer Software and Related IPR Issues
Computer Software and Related IPR Issues Dr. Prashant Vats
 
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000Dr. Prashant Vats
 
Trademark Issues in cyberspace
Trademark Issues in cyberspace Trademark Issues in cyberspace
Trademark Issues in cyberspace Dr. Prashant Vats
 
Trade-Related Aspects of Intellectual Property Rights (TRIPS)
Trade-Related Aspects of Intellectual Property Rights (TRIPS)Trade-Related Aspects of Intellectual Property Rights (TRIPS)
Trade-Related Aspects of Intellectual Property Rights (TRIPS)Dr. Prashant Vats
 
How to Copyright a Website to Protect It under IPR and copyright act
How to Copyright a Website to Protect It under IPR and copyright actHow to Copyright a Website to Protect It under IPR and copyright act
How to Copyright a Website to Protect It under IPR and copyright actDr. Prashant Vats
 
International Treaties for protection of IPR
International Treaties for protection of IPRInternational Treaties for protection of IPR
International Treaties for protection of IPRDr. Prashant Vats
 

Más de Dr. Prashant Vats (20)

Multiplexers
MultiplexersMultiplexers
Multiplexers
 
C lab programs
C lab programsC lab programs
C lab programs
 
Financial fucntions in ms e xcel
Financial fucntions in ms e xcelFinancial fucntions in ms e xcel
Financial fucntions in ms e xcel
 
4. text functions in excel
4. text functions in excel4. text functions in excel
4. text functions in excel
 
3. lookup functions in excel
3. lookup functions in excel3. lookup functions in excel
3. lookup functions in excel
 
2. date and time function in excel
2. date and time function in excel2. date and time function in excel
2. date and time function in excel
 
1. statistical functions in excel
1. statistical functions in excel1. statistical functions in excel
1. statistical functions in excel
 
3. subtotal function in excel
3. subtotal function in excel3. subtotal function in excel
3. subtotal function in excel
 
2. mathematical functions in excel
2. mathematical functions in excel2. mathematical functions in excel
2. mathematical functions in excel
 
RESOLVING CYBERSQUATTING DISPUTE IN INDIA
RESOLVING CYBERSQUATTING DISPUTE IN INDIARESOLVING CYBERSQUATTING DISPUTE IN INDIA
RESOLVING CYBERSQUATTING DISPUTE IN INDIA
 
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An OverviewIndia: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
India: Meta-Tagging Vis-À-Vis Trade Mark Misuse: An Overview
 
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
Trademark Cases Arise from Meta-Tags, Frames: Disputes Involve Search-Engine ...
 
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
Scheme for Notifying Examiner of Electronic Evidence Under section 79A of the...
 
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIAMETHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
METHODS OF RESOLVING CYBERSQUATTING DISPUTE IN INDIA
 
Computer Software and Related IPR Issues
Computer Software and Related IPR Issues Computer Software and Related IPR Issues
Computer Software and Related IPR Issues
 
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
Amendments to the Indian Evidence Act, 1872 with respect to IT ACT 2000
 
Trademark Issues in cyberspace
Trademark Issues in cyberspace Trademark Issues in cyberspace
Trademark Issues in cyberspace
 
Trade-Related Aspects of Intellectual Property Rights (TRIPS)
Trade-Related Aspects of Intellectual Property Rights (TRIPS)Trade-Related Aspects of Intellectual Property Rights (TRIPS)
Trade-Related Aspects of Intellectual Property Rights (TRIPS)
 
How to Copyright a Website to Protect It under IPR and copyright act
How to Copyright a Website to Protect It under IPR and copyright actHow to Copyright a Website to Protect It under IPR and copyright act
How to Copyright a Website to Protect It under IPR and copyright act
 
International Treaties for protection of IPR
International Treaties for protection of IPRInternational Treaties for protection of IPR
International Treaties for protection of IPR
 

Último

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Último (20)

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

C lab programs

  • 2. /* C program to print Hello World! */ #include <stdio.h> int main() { printf("Hello World!"); return 0; }
  • 3.
  • 4. /* C program to print Hello World using function */ #include <stdio.h> // function to print Hello World! void printMessage(void) { printf("Hello World!"); } int main() { //calling function printMessage(); return 0; }
  • 5.
  • 6. /* C Program to find sum of two numbers */ #include<stdio.h> int main() { int a, b, sum; printf("n Enter two no: "); scanf("%d %d", &a, &b); sum = a + b; printf("Sum : %d", sum); return(0); }
  • 7.
  • 8. /* Check Whether Number is Prime or not */ #include<stdio.h> int main() { int num, i, count = 0; printf("Enter a number:"); scanf("%d", &num); for (i = 2; i <= num / 2; i++) { if (num % i == 0) { count++; break; } } if (count == 0) printf("%d is a prime number", num); else printf("%d is not a prime number", num); return 0; }
  • 9.
  • 10. /* Factorial of a Number*/ #include <stdio.h> int main() { int n, i; unsigned long long fact = 1; printf("Enter an integer: "); scanf("%d", &n); // shows error if the user enters a negative integer if (n < 0) printf("Error! Factorial of a negative number doesn't exist."); else { for (i = 1; i <= n; ++i) { fact *= i; } printf("Factorial of %d = %llu", n, fact); } return 0; }
  • 11.
  • 12. /* Swap Numbers Using Temporary Variable*/ #include<stdio.h> int main() { double first, second, temp; printf("Enter first number: "); scanf("%lf", &first); printf("Enter second number: "); scanf("%lf", &second); // Value of first is assigned to temp temp = first; // Value of second is assigned to first first = second; // Value of temp (initial value of first) is assigned to second second = temp; printf("nAfter swapping, firstNumber = %.2lfn", first); printf("After swapping, secondNumber = %.2lf", second); return 0; }
  • 13.
  • 14. /* C Program to generate the Fibonacci Series starting from any two numbers*/ #include<stdio.h> int main() { int first, second, sum, num, counter = 0; printf("Enter the term : "); scanf("%d", &num); printf("n Enter First Number : "); scanf("%d", &first); printf("n Enter Second Number : "); scanf("%d", &second); printf("n Fibonacci Series : %d %d ", first, second); while (counter < num) { sum = first + second; printf("%d ", sum); first = second; second = sum; counter++; } return (0); }
  • 15.
  • 16. /* C Program to find greatest in 3 numbers*/ #include<stdio.h> int main() { int a, b, c; printf("nEnter value of a, b & c : "); scanf("%d %d %d", &a, &b, &c); if ((a > b) && (a > c)) printf("na is greatest"); if ((b > c) && (b > a)) printf("nb is greatest"); if ((c > a) && (c > b)) printf("nc is greatest"); return(0); } •
  • 17.
  • 18. /* Program to relate two integers using =, > or < symbol using C if...else Ladder*/ #include <stdio.h> int main() { int number1, number2; printf("Enter two integers: "); scanf("%d %d", &number1, &number2); //checks if the two integers are equal. if(number1 == number2) { printf("Result: %d = %d",number1,number2); } //checks if number1 is greater than number2. else if (number1 > number2) { printf("Result: %d > %d", number1, number2); } //checks if both test expressions are false else { printf("Result: %d < %d",number1, number2); } return 0; }
  • 19.
  • 20. /* Example of while loop*/ #include <stdio.h> int main() { int count=1; while (count <= 4) { printf("%d ", count); count++; } return 0; }
  • 21.
  • 22. /* do...while loop in C*/ #include <stdio.h> int main () { /* local variable definition */ int a = 10; /* do loop execution */ do { printf("value of a: %dn", a); a = a + 1; }while( a < 20 ); return 0; }
  • 23.
  • 24. /* for loop in C*/ #include <stdio.h> int main () { int a; /* for loop execution */ for( a = 10; a < 20; a = a + 1 ){ printf("value of a: %dn", a); } return 0; }
  • 25.
  • 26. /*Nested For Loop in C*/ #include <stdio.h> int main() { for (int i=0; i<2; i++) { for (int j=0; j<4; j++) { printf("%d, %dn",i ,j); } } return 0; }
  • 27.
  • 28. /* Switch Statement in C*/ 1. #include <stdio.h> 2. int main () 3. { 4. /* local variable definition */ 5. char grade = 'B'; 6. switch(grade) { 7. case 'A' : 8. printf("Excellent!n" ); 9. break; 10. case 'B' : 11. case 'C' : 12. printf("Well donen" ); 13. break; 14. case 'D' : 15. printf("You passedn" ); 16. break; 17. case 'F' : 18. printf("Better try againn" ); 19. break; 20. default : 21. printf("Invalid graden" ); 22. } 23. printf("Your grade is %cn", grade ); 24. return 0; 25. }
  • 29.
  • 30. 1. /* continue statement in C*/ 2. #include <stdio.h> 3. int main () 4. { 5. /* local variable definition */ 6. int a = 10; 7. 8. /* do loop execution */ 9. do { 10. 11. if( a == 15) { 12. /* skip the iteration */ 13. a = a + 1; 14. continue; 15. } 16. 17. printf("value of a: %dn", a); 18. a++; 19. 20. } while( a < 20 ); 21. 22. return 0; 23. }
  • 31.
  • 32. /* Example of goto statement*/ 1. #include <stdio.h> 2. int main() 3. { 4. int sum=0; 5. for(int i = 0; i<=10; i++){ 6. sum = sum+i; 7. if(i==5){ 8. goto addition; 9. } 10. } 11. addition: 12. printf("%d", sum); 13. return 0; 14. } • Output: • 15 • Explanation: In this example, we have a label addition and when the value of i (inside loop) is equal to 5 then we are jumping to this label using goto. This is reason the sum is displaying the sum of numbers till 5 even though the loop is set to run from 0 to 10.
  • 33.
  • 34. /* prime Numbers between Two Integers using function*/ 1. #include <stdio.h> 2. int checkPrimeNumber(int n); 3. int main() 4. { 5. int n1, n2, i, flag; 6. printf("Enter two positive integers: "); 7. scanf("%d %d", &n1, &n2); 8. printf("Prime numbers between %d and %d are: ", n1, n2); 9. for (i = n1 + 1; i < n2; ++i) 10. { 11. // flag will be equal to 1 if i is prime 12. flag = checkPrimeNumber(i); 13. if (flag == 1) 14. printf("%d ", i); 15. } 16. return 0; 17. } 18. // user-defined function to check prime number 19. int checkPrimeNumber(int n) 20. { 21. int j, flag = 1; 22. for (j = 2; j <= n / 2; ++j) { 23. if (n % j == 0) { 24. flag = 0; 25. break; 26. } 27. } 28. return flag; 29. }
  • 35.
  • 36. /* Sum of Natural Numbers Using Recursion*/ 1. #include <stdio.h> 2. int sum(int n); 3. int main() 4. { 5. int number, result; 6. printf("Enter a positive integer: "); 7. scanf("%d", &number); 8. result = sum(number); 9. printf("sum = %d", result); 10. return 0; 11. } 12. int sum(int n) 13. { 14. if (n != 0) 15. // sum() function calls itself 16. return n + sum(n-1); 17. else 18. return n; 19. }
  • 37.
  • 38. /* Function call by Value in C*/ 1. #include <stdio.h> 2. /* function declaration */ 3. void swap(int x, int y); 4. int main () 5. { 6. /* local variable definition */ 7. int a = 100; 8. int b = 200; 9. printf("Before swap, value of a : %dn", a ); 10. printf("Before swap, value of b : %dn", b ); 11. /* calling a function to swap the values */ 12. swap(a, b); 13. printf("After swap, value of a : %dn", a ); 14. printf("After swap, value of b : %dn", b ); 15. return 0; 16. } 17. void swap(int x, int y) 18. { 19. int temp; 20. temp = x; /* save the value of x */ 21. x = y; /* put y into x */ 22. y = temp; /* put temp into y */ 23. return; 24. }
  • 39.
  • 40. • /* Function call by reference in C*/ 1. #include <stdio.h> 2. int main () 3. { 4. /* local variable definition */ 5. int a = 100; 6. int b = 200; 7. printf("Before swap, value of a : %dn", a ); 8. printf("Before swap, value of b : %dn", b ); 9. /* calling a function to swap the values */ 10. swap(&a, &b); 11. printf("After swap, value of a : %dn", a ); 12. printf("After swap, value of b : %dn", b ); 13. 14. return 0; 15. } 16. void swap(int *x, int *y) 17. { 18. int temp; 19. temp = *x; /* save the value of x */ 20. *x = *y; /* put y into x */ 21. *y = temp; /* put temp into y */ 22. return; 23. }
  • 41.
  • 42. • /* C - Arrays*/ 1. #include <stdio.h> 2. 3. int main () { 4. 5. int n[ 10 ]; /* n is an array of 10 integers */ 6. int i,j; 7. 8. /* initialize elements of array n to 0 */ 9. for ( i = 0; i < 10; i++ ) { 10. n[ i ] = i + 100; /* set element at location i to i + 100 */ 11. } 12. 13. /* output each array element's value */ 14. for (j = 0; j < 10; j++ ) { 15. printf("Element[%d] = %dn", j, n[j] ); 16. } 17. 18. return 0; 19. } •
  • 43.
  • 44. • /* Simple Two dimensional (2D) Array Example*/ 1. #include<stdio.h> 2. int main() 3. { /* 2D array declaration*/ 4. int disp[2][3]; 5. /*Counter variables for the loop*/ 6. int i, j; 7. for(i=0; i<2; i++) { 8. for(j=0;j<3;j++) { 9. printf("Enter value for disp[%d][%d]:", i, j); 10. scanf("%d", &disp[i][j]); 11. } } 12. //Displaying array elements 13. printf("Two Dimensional array elements:n"); 14. for(i=0; i<2; i++) { 15. for(j=0;j<3;j++) { 16. printf("%d ", disp[i][j]); 17. if(j==2){ 18. printf("n"); 19. } } } 20. return 0; 21. }
  • 45.
  • 46. /* Store Information in Structure and Display it*/ 1. #include <stdio.h> 2. struct student { 3. char firstName[50]; 4. int roll; 5. float marks; } s[10]; 6. int main() 7. { 8. int i; 9. printf("Enter information of students:n"); 10. // storing information 11. for (i = 0; i < 5; ++i) { 12. s[i].roll = i + 1; 13. printf("nFor roll number%d,n", s[i].roll); 14. printf("Enter first name: "); 15. scanf("%s", s[i].firstName); 16. printf("Enter marks: "); 17. scanf("%f", &s[i].marks); 18. } 19. printf("Displaying Information:nn"); 20. // displaying information 21. for (i = 0; i < 5; ++i) { 22. printf("nRoll number: %dn", i + 1); 23. printf("First name: "); 24. puts(s[i].firstName); 25. printf("Marks: %.1f", s[i].marks); 26. printf("n"); 27. } 28. return 0; 29. }
  • 47.
  • 48. Write a 'C' program to accept customer details such as: Account_no, Name, Balance using structure. Assume 3 customers in the bank. Write a function to print the account no. and name of each customer whose balance < 100 Rs. #include<stdio.h> /* Defining Structre*/ struct bank { int acc_no; char name[20]; int bal; }b[3]; /*Function to find the details of customer whose balance < 100.*/ void check(struct bank b[],int n) /*Passing Array of structure to function*/ { int i; printf("nCustomer Details whose Balance < 100 Rs. n"); printf("----------------------------------------------n"); for(i=0;i<n;i++) { if(b[i].bal<100) { printf("Account Number : %dn",b[i].acc_no); printf("Name : %sn",b[i].name); printf("Balance : %dn",b[i].bal); printf("------------------------------n"); } } } int main() { int i; for(i=0;i<3;i++) { printf("Enter Details of Customer %dn",i+1); printf("------------------------------n"); printf("Enter Account Number : "); scanf("%d",&b[i].acc_no); printf("Enter Name : "); scanf("%s",b[i].name); printf("Enter Balance : "); scanf("%d",&b[i].bal); printf("------------------------------n"); } check(b,3); //call function check return 0; }
  • 49.
  • 50. /* C - Unions*/ 1. #include <stdio.h> 2. #include <string.h> 3. union Data 4. { 5. int i; 6. float f; 7. char str[20]; 8. }; 9. int main( ) 10. { 11. union Data data; 12. printf( "Memory size occupied by data : %dn", sizeof(data)); 13. return 0; 14. }
  • 51.
  • 52. /* example to define union for an employee in c*/ 1. #include <stdio.h> 2. #include <string.h> 3. union employee 4. { int id; 5. char name[50]; 6. }e1; //declaring e1 variable for union 7. int main( ) 8. { 9. //store first employee information 10. e1.id=101; 11. strcpy(e1.name, "Sonoo Jaiswal");//copying string into char array 12. //printing first employee information 13. printf( "employee 1 id : %dn", e1.id); 14. printf( "employee 1 name : %sn", e1.name); 15. return 0; 16. }
  • 53.
  • 54. /* C program to read name and marks of n number of students and store them in a file.*/ 1. #include <stdio.h> 2. int main() 3. { 4. char name[50]; 5. int marks, i, num; 6. printf("Enter number of students: "); 7. scanf("%d", &num); 8. FILE *fptr; 9. fptr = (fopen("C:student.txt", "w")); 10. if(fptr == NULL) 11. { 12. printf("Error!"); 13. exit(1); 14. } 15. for(i = 0; i < num; ++i) 16. { 17. printf("For student%dnEnter name: ", i+1); 18. scanf("%s", name); 19. printf("Enter marks: "); 20. scanf("%d", &marks); 21. fprintf(fptr,"nName: %s nMarks=%d n", name, marks); 22. } 23. fclose(fptr); 24. return 0; 25. }
  • 55.
  • 56. /* C program to read name and marks of n number of students from and store them in a file. If the file previously exits, add the information to the file.*/ 1. #include <stdio.h> 2. int main() 3. { 4. char name[50]; 5. int marks, i, num; 6. printf("Enter number of students: "); 7. scanf("%d", &num); 8. FILE *fptr; 9. fptr = (fopen("C:student.txt", "a")); 10. if(fptr == NULL) 11. { 12. printf("Error!"); 13. exit(1); 14. } 15. for(i = 0; i < num; ++i) 16. { 17. printf("For student%dnEnter name: ", i+1); 18. scanf("%s", name); 19. printf("Enter marks: "); 20. scanf("%d", &marks); 21. fprintf(fptr,"nName: %s nMarks=%d n", name, marks); 22. } 23. fclose(fptr); 24. return 0; 25. }
  • 57.