Professional Documents
Culture Documents
#include <stdio.h>
void main()
int n = 4;
int m1[4],i;
int m2[4][4] = {
{1,2,3,4},
{5,6,7,8},
{9,10,11,12},
{13,14,15,16}
};
int multiplied_matrix[4][1] = {
{0},
{0},
{0},
{0}
};
for(i=0;i<n;i++)
scanf("%d",&m1[i]);
{FILE *FP=fopen("vec.txt","w");
int i, j;
f printf(fp,"%4i", A[j][0]);
printf("\n");
printf("\n");
fprintf(fp,"%4i\n", A[i][0]);
fclose(fp);
2] What does the keyword static mean? Write a function that increases an internal
counter by one each time and retains its value until the next function call. Prior to
the increase of the counter, the old counter value should be saved in a variable and
returned at the end of the function. Write a main program, in which the function is
called multiple times and the value is returned on the screen.
static is used with global variables and functions to set their scope to the containing
file. In local variables, static is used to store the variable in the statically allocated
memory instead of the automatically allocated memory.
#include<stdio.h>
int fun()
count++;
return count;
int main()
return 0;
3] write a function func with two integer input parameters and one double
returnvalue. What the function func does is not relevant. Write a main program to
the function func deklare a suitable pointer for func and allocate to the pointer,the
function func . Use only the pointer for a function call.
#include <stdio.h>
// #include <conio.h>
return (m/n);
void main()
int a,b;
double ans;
fun_pntr = &func;
scanf("%d%d",&a,&b);
ans=(*fun_pntr)(a,b);
#include<stdio.h>
#include<conio.h>
struct pardetail
char firname[30];
char secname[30];
int accno;
int roomno;
struct address
char country[20],city[30],street[50;
int pscd,houseno;
int main()
char ch;
int chi=1;
FILE *fp=fopen("detail.txt","w");
while(chi==1)
scanf("%s",&det.firname);
scanf("%s",&det.secname);
scanf("%d %d",&det.accno,&det.roomno);
scanf("%s%s%s%d
%d",&addr.country,&addr.city,&addr.street,&addr.houseno,&addr.pscd");
fprintf("firstname: %s secondname: %s accno: %d roomno: %d country: %s
city: %s street: %s houseno:%d postalcode:
%d",det.firname,det.secname,det.roono,addr.country,addr.city,addr.street,addr.hous
eno,addr.pscd);
scanf("%c",ch);
if(ch=='y')
chi=1;
else
chi=0;
}}
#include<stdio.h>
#include<conio.h>
#include<math.h>
val =(cos(b1)*cos(a1))/(b1-a1);
return val;
void main()
double a=0.0,b=0.5;
double *y;
y=slope(a,b);
#include <stdio.h>
#include <stdlib.h>
// #include <conio.h>
int get_matrix(){
int **mat,m,n;
scanf("%d%d",&m,&n);
scanf("%d",&mat[i][j]);
return **mat;
int row=(sizeof(mat)/sizeof(mat[0]));
int col=(sizeof(mat)/sizeof(mat[0][0]))/row;
printf("%d\n",mat[i][j]);
printf("\n");
int **ans;
int a_row=(sizeof(a)/sizeof(a[0]));
int a_col=(sizeof(a)/sizeof(a[0][0]))/a_row;
int b_row=(sizeof(b)/sizeof(b[0]));
int b_col=(sizeof(b)/sizeof(b[0][0]))/b_row;
ans[i][j] = a[i][j]*b[k][l];
return **ans;
}
int row=(sizeof(mat)/sizeof(mat[0]));
free(mat[i]);
free(mat);
void main(){
int **a,**b,**ans;
a = get_matrix();
b = get_matrix();
display(a);
display(b);
printf("Executing Kronecker......\n");
ans = Kronecker(a,b);
free_mat(a);
free_mat(b);