Here's a simple C program to create a basic calculator using pointer variables:
#include <stdio.h>
void calculate(int *a, int *b, char op) {
switch(op) {
case '+': printf("Sum: %d\n", *a + *b); break;
case '-': printf("Difference: %d\n", *a - *b); break;
case '*': printf("Product: %d\n", *a * *b); break;
case '/':
if (*b != 0)
printf("Quotient: %d\n", *a / *b);
else
printf("Error: Division by zero.\n");
break;
default: printf("Invalid operator.\n");
}
}
int main() {
int num1, num2;
char operator;
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
printf("Enter operator (+, -, *, /): ");
scanf(" %c", &operator);
calculate(&num1, &num2, operator);
return 0;
}
This program takes two integers and an operator from the user, then uses pointers to perform the corresponding arithmetic operation.
Here is the algorithm of the algorithm to write an algorithm to access a pointer in a variable. Algorithmically.name_of_the_structure dot name_of_the _field,eg:mystruct.pointerfield
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
Use list assignment i.e. for two variables $a, $b: ($a,$b) = ($b,$a)
If you do not know then you cannot write a program. The compiler is not clairvoyant so it cannot do it for you.
pointer is a derived datatype which contains memory addresses as their values. program:- #include<stdio.h> #include<conio.h> void main() { int m=5,*p; clrscr(); p=&m; printf("address of variable m is %p",(void *)p); }
dcdfsadf
dim a input a
Here is the algorithm of the algorithm to write an algorithm to access a pointer in a variable. Algorithmically.name_of_the_structure dot name_of_the _field,eg:mystruct.pointerfield
Wr
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
c program is fast and efficient.And c programm can be write with vareity of type variables and operations.
To swap two variables without using a third variable, use exclusive or manipulation... a ^= b; b ^= a; a ^= b;
Use list assignment i.e. for two variables $a, $b: ($a,$b) = ($b,$a)
trytytytytytytytytrf 6 bcvvtgujhy6
If you do not know then you cannot write a program. The compiler is not clairvoyant so it cannot do it for you.
a=a^b; b=a^b; a=a^b;
This will depend on the type of calculator you have. This will depend on the type of calculator you have.