Print Four Powers of Numbers 1 to 9 Using Nested For Loop in C

Bhanu Priya
Updated on 01-Sep-2021 12:52:49

642 Views

Nested loops consist of one loop placed inside another loop.An example of a nested for loop is as follows −for (initialization; condition; operation){    for (initialization; condition; operation){       statement;    }    statement; }In this example, the inner loop runs through its full range of iterations for each single iteration of the outer loop.ExampleFollowing is the C program to print the table of first four powers of numbers 1 to 9 by using nested for loop − Live Demo#include void main(){    int i, j, k, temp, I=1;    printf("I\tI^2\tI^3\tI^4 ");    printf("--------------------------------");    for ( i ... Read More

Printf Conversion Characters and Their Types

Bhanu Priya
Updated on 01-Sep-2021 12:48:48

1K+ Views

The use of printf is to print out a string with no blank fields to be filled.For example, printf ("An ordinary string.."); printf ("Testing 1, 2, 3...");The next simplest case that has been used before now is to print out a single integer number.int number = 48; printf ("%d", number);The two can be combined as shown below −int number = 48; printf ("Some number = %d", number);The result of this last example is to print out the following on the screen −Some number = 48Here is a list of the different letters for printf −d − signed denary integeru − ... Read More

Convert Decimal Fraction to Binary Fraction in C

Bhanu Priya
Updated on 01-Sep-2021 12:46:02

1K+ Views

Consider the examples given below to understand how to convert a decimal fraction to binary fraction in C programming language.Example 1 − Conversions of 25 to binary.Step 1 − 25 / 2 Rem : 1 , Quo : 12Step 2 − 12 / 2 Rem : 0 , Quo : 6Step 3 − 6 / 2 Rem : 0 , Quo: 3Step 4 − 3 / 2 Rem : 1 , Quo: 1Step 5 − 1 / 2 Rem : 1 , Quo: 0So equivalent binary number is: 11001Example 2 − Conversions of 0.7 to binary.Step 1 − 0.7 * ... Read More

Implement Euclid's Algorithm in C

Bhanu Priya
Updated on 01-Sep-2021 12:42:54

1K+ Views

ProblemImplement Euclid’ s algorithm to find the greatest common divisor (GCD) and least common multiple (LCM) of two integers and to output the results along with the given integers.SolutionThe solution to implement Euclid’ s algorithm to find the greatest common divisor (GCD) and least common multiple (LCM) of two integers is as follows −The logic used to find GCD and LCM is as follows −if(firstno*secondno!=0){    gcd=gcd_rec(firstno, secondno);    printf("The GCD of %d and %d is %d", firstno, secondno, gcd);    printf("The LCM of %d and %d is %d", firstno, secondno, (firstno*secondno)/gcd); }The called function is as follows −int gcd_rec(int ... Read More

Compute Polynomial Regression Algorithm in C

Bhanu Priya
Updated on 01-Sep-2021 12:37:39

3K+ Views

Regression is a predictive modelling technique that investigates the relationship between a dependent and non-dependent variable.Polynomial regressionIt is a form of regression analysis that shows the relationship between an independent variable x and the dependent variable y that is modelled a nth degree polynomial in x.ExampleFollowing is the C program to compute the polynomial regression algorithm −#include #include #include main(){    int i,j,k,m,n;    float x[20],y[20],u,a[10],c[20][20],power,r;    printf("enter m,n:");    scanf("%d%d",&m,&n);    for(i=1;i

Get Load Balancers Connected to Azure VM Using PowerShell

Chirag Nagrekar
Updated on 01-Sep-2021 09:52:41

566 Views

To get the load balancers attached to the Azure VM using PowerShell, we first need to retrieve the Azure VM network settings. For example, we have an Azure VM name “TestVM” and we willPS C:\> $vm = Get-AzVM -Name TestVM $nic = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]Once we have the network interface name, we need to retrieve the load balancer settings, and to get the Load Balancer settings we need to use the Get-AzNetworkInterface command.PS C:\> $nicsettings = Get-AzNetworkInterface -Name $nicThe below command will retrieve the load balancer name.(($nicsettings.IpConfigurations.LoadBalancerBackendAddressPools.id).Split('/'))[-3]To get the Load Balancer backend pool name, use the below command.(($nicsettings.IpConfigurations.LoadBalancerBackendAddressPools.id).Split('/'))[-1]Overall Script −$vm = Get-AzVM ... Read More

Get Azure VM Virtual Network and Subnet Name Using PowerShell

Chirag Nagrekar
Updated on 01-Sep-2021 09:51:41

2K+ Views

To retrieve the Azure VM virtual network and subnet name, we first need to retrieve the AzureVM NIC information. To get the Azure VM NIC information, we need to use the Get-AzVM command, and then we can use the NetworkProfile property to retrieve the NIC name as shown below.PS C:\> $vm = Get-AzVM -Name TestVM $vmnic = ($vm.NetworkProfile.NetworkInterfaces.id).Split('/')[-1]Once we have the NIC name stored from the above command in the $vmnic variable, we can retrieve the NIC information using the Get-AzNetworkInterface command as shown below.$vmnicinfo = Get-AzNetworkInterface -Name $vmnicTo get the Virtual Network name attached to the VM use the ... Read More

Retrieve Azure VM NIC Name Using Azure CLI in PowerShell

Chirag Nagrekar
Updated on 01-Sep-2021 09:49:50

492 Views

To get the Azure VM NIC name using Azure CLI, use the below command but before running the command make sure that you are connected to the Azure Account and the proper Azure subscription using Azure CLI.az vm show -n AzureVM -g ResourceGroup --query '[networkProfile.networkInterfaces][].id' -otsvWe need the NIC name from this. If you are running the Azure CLI in the PowerShell terminal then use the command below.PS C:\> $nicinfo = az vm show -n VMname -g RGName --query '[networkProfile.networkInterfaces][].id' -otsv PS C:\> ($nicinfo.Split('/'))[-1]

Get Currently Logged-in User Account with Azure CLI in PowerShell

Chirag Nagrekar
Updated on 01-Sep-2021 09:35:09

12K+ Views

To get the connected user account with the Azure CLI, you need to use the below command.PS C:\> az account showOnce you type the command, you will get the output in JSON format as shown below.PS C:\> az account show {    "environmentName": "AzureCloud",    "homeTenantId": "Your tenant ID",    "id": "Subscriptio ID",    "isDefault": true,    "managedByTenants": [],    "name": "Subscription Name",    "state": "Enabled",    "tenantId": "tenant ID",    "user": {     "name": "user logged in email id or username",     "type": "user"    } }To get the output in the table format, use the -otable or –output tablePS C:\> az account show -otable

Install Azure CLI on Windows Using PowerShell

Chirag Nagrekar
Updated on 01-Sep-2021 09:32:31

7K+ Views

To install the Azure CLI, you can download it from the location below,https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli/To install the Azure CLI using PowerShell, use the below command.Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows - OutFile .\AzureCLI.msi Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet' rm .\AzureCLI.msiTo check if the Az CLI is installed successfully run the Az in the cmd or the PowerShell.

Advertisements