You are on page 1of 12
9:03 “til all as @ - ia Qf beginnersbook.com/20 #include /* Created a structure here. The name of * StudentData. */ struct StudentData{ char *stu_name; int stu_id; int stu_age; ¥; int main() { /* student is the variable of struct struct StudentData student; /*Assigning the values of each struc student.stu_name = "Steve"; student.stu_id = 1234; student.stu_age = 30; /* Displaying the values of struct m printf("Student Name is: %s", studen printf("\nStudent Id is: %d", studen printf("\nStudent Age is: %d", stude return 0; ie Output: Student Name is: Steve Student Id is: 1234 Student Age is: 30 Nested Structure in C: Struct 3:53 PM Fibonacci of given Num... map @lel aval A #include main() | int a=0,b=1,num,c,count; printf("Enter a number to obtain fibonacci series\n scanf("%d",&num) ; printf("The series is\n"); printf("%d \n%d\n",a,b); count=2; while(count int GetFactorial(int number); main() { int number, factorial; printf("Enter a number for knowing it's factorial\ scanf("%d",&number ); factorial=GetFactorial(number); printf ("%d!=%d\n",number , factorial); } int GetFactorial(int number ) { if (number>0) { return number*GetFactorial (number -1) ; } else { return 1; } } Enter a number for knowing it's factorial 6 6!=720 Explanation: |. This program starts with initializing : =» number — To store given number to get Factorial « factorial — Used to store output » int GetFactorial. Declaration of function printf("Enter a number for knowing it's factoria scanf("%d", &number ); 3:56 PM perm CHT Sort Array in Ascending PI PROGRAM: #include main() o int i,j,num,temp; printf("Enter number of elements\n"); scanf("%d",&num) ; int a[num]; printf( "Enter numbers\n"); for(i=0; ia[j]) { temp=a[i]; aliiqala, a[j]=temp; } } i printf( "Ascending oreder of given numbers is\n"); for(i=0;i main() o int i,j,num,temp; printf("Enter number of elements\n"); scanf("%d",&num) ; int a[num]; printf( "Enter numbers\n"); for(i=0; i main() | int i,j,rows,col; printf("Enter number of rows\n"); scanf("%d",&rows); printf("Enter number of columns\n"); scanf("%d",&col); int al[rows][col],a2[rows][col],add[rows][col]; //Taking input for 1st matrix printf("Enter Matrix 1\n"); for(i=0;i main() { int i,j,k,rows_1,col_1,rows_2,col_2,sum=0; printf("Enter number of rows and columns of matrix scanf("%d %d",&rows_1,&col_1); printf("Enter number of rows and columns of matrix scanf("%d %d",&rows_2,&col_2); int al[rows_1][col_1],a2[rows_2][col_2],mul[rows_1] if(col_1==rows_2) { //Taking input for 1st matrix printf("Enter Matrix 1\n"); for(i=0;i main() { int i,size,max=0,min=0; printf("Enter size to find largest and smallest scanf("%d",&size); int a[size]; printf("Enter numbers in array\n"); for(i=0;imax) { max=a[i]; } if(a[i] main() { int i,j,rows,col; printf("Enter number of rows\n"); scanf("%d",&rows); printf("Enter number of columns\n"); scanf("%d",&col); int al[rows][col],a2[rows][col],diff[rows][col]; //Taking input for 1st matrix printf("Enter Matrix 1\n"); for(i=0;1 void selectionsort(int a[],int size); main() { int i,j,size; printf("Enter number of elements\n"); scanf("%d",&size); int a[size]; printf("Enter numbers\n"); for(i=0;1a[j])//For descending--> chan { pointer=j; } if(pointer!=i) { temn=alnointer!: = © <

You might also like