OSA B5

B5:C/C++ program to identify the available memory in the system.



Program:
#include<sys/sysinfo.h>
#include<unistd.h>
#include<stdio.h>
#include<iostream>

using namespace std;

int main()
{
structsysinfo a;
unsigned long tot;
sysinfo(&a);
cout<<"\n memory units "<<a.mem_unit<<"Units";

cout<<"\n total Ram "<<a.totalram;

tot=a.mem_unit*a.totalram;
cout<<"\n Total useable main memory units "<<tot;

            return 0;
}


Output:

cl2@Inspiron-1545:~$ g++ a.cpp
cl2@Inspiron-1545:~$ ./a.out

memory units 1Units
total Ram 3118276608
 Total useable main memory units 3118276608cl2@Inspiron-1545:~$

0 comments:

Post a Comment