C program to work with storage in filesystems

7:40 AM
------------------------------------------------------
#include
int g = 10; \\ A
main()
{
int i =0; \\ B
void f1(); \\ C
f1(); \\ D
printf(" after first call \n");
f1(); \\ E
printf("after second call \n");
f1(); \\ F
printf("after third call \n");

}
void f1()
{
static int k=0; \\ G
int j = 10; \\ H
printf("value of k %d j %d",k,j);
k=k+10;
}
------------------------------------------------------
\\ Program in file extern1.c

#include \\ A
#include \\ B
extern int i; \\ C
main()
{
i =0; \\ D
printf("value of i %d\n",i);
}

\\ Program in file f1.cpp

int i =7; \\ E

------------------------------------------------------
#include
main()
{
register int i = 0; \\ A

for( i=0;i<2;i++) { printf("value of i is %d\n",i); } }



 ------------------------------------------------------ 


#include
main()
{ \\ Block 1
int i = 10; \\ A

{ \\ Block 2
int i = 0; \\ B
for( i=0;i<2;i++) \\ C { printf("value of i is %d\n",i); } \\ End of block 2 } printf("the value of i is %d\n",i); \\ D } \\ End of block 1 



 ------------------------------------------------------


 #include
main()
{
int k = 10;

{
for(int i=0;i<2;i++) \\ A { \\ B printf("value of i is %d\n",i); \\ C } \\ D } printf("the value of i is %d\n",i); \\ E } 



 ------------------------------------------------------ 
#include
#include
main()
{
int *base; \\ A
int i;
int cnt=0;
int sum=0;
printf("how many integers you have to store \n");
scanf("%d",&cnt); \\ B
base = (int *)malloc(cnt * sizeof(int)); \\ C
printf("the base of allocation is %16lu \n",base); \\ D
if(!base) \\ E
printf("unable to allocate size \n");
else
{
for(int j=0;j *(base+j)=5;
}
sum = 0;
for(int j=0;j sum = sum + *(base+j);
printf("total sum is %d\n",sum);
free(base); \\ H
printf("the base of allocation is %16lu \n",base);
base = (int *)malloc(cnt * sizeof(int));
printf("the base of allocation is %16lu \n",base);
base = (int *)malloc(cnt * sizeof(int)); \\ I
printf("the base of allocation is %16lu \n",base);
base = (int *)calloc(10,2); \\ H
printf("the base of allocation is %16lu \n",base);


}
------------------------------------------------------


0 Comments