yt

Header Ads

What is typecasting and pointer? Explain with an example

In this post learn explain what is typecasting and pointer suitable difition and an example,So don't forget Subscribe to you channel, So let's go start now.




Q1. What is typecasting? Explain with an example

Ans:- changing an value from one data type to another data type is known as data type conversion i.e. assigning a value of one type of a variable of another type is known as type casting.

Example:-

#include<stdio.h>

Int main()

{

float height,base,area;

Printf(“Enter the height:”);

Scanf(“%f”, &height);

Printf(“Enter the base:”);

Scanf(“%f”, &height);

Area=(float)1/2*height*base;

Printf(“area of triangle=%f.2”,area);

return 0;

}

Very important topic for you


Q2. What is pointer ? How can be access variables using pointer

Pointer :- A pointer is a variable that stores a memory address. Pointer are used to store the address of other variables items.

Pointer are very useful for another type of parameter passing, usually referred to as pass By Address. Pointer are essential for dynamic memory allocation.

Example:-

#include<stdio.h>

Int main()

{

Int *ptr , q;

q=50;

ptr = &q;

printf(“%d”,*ptr);

return 0;

}


Thanks for watching this post, I hope this post is helpful for you so don't forget follow me. 

No comments

Theme images by Dizzo. Powered by Blogger.