1. Write a c program to reverse any number.
2. Write a c program to find out sum of digit of given number.
2. Write a c program to find out sum of digit of given number.
10. Write a c program to find out NCR factor of given number.
11. How to convert string to int without using library functions in c
12. Program in c to print 1 to 100 without using loop
13. C program for swapping of two numbers
14. Program to find largest of n numbers in c
15. Split number into digits in c programming
16. C program to count number of digits in a number
11. How to convert string to int without using library functions in c
12. Program in c to print 1 to 100 without using loop
13. C program for swapping of two numbers
14. Program to find largest of n numbers in c
15. Split number into digits in c programming
16. C program to count number of digits in a number
21 comments:
the first program should have
b=temp;
logic: swapping
a=a+b;
b=a-b;
a=a-b;
in the program for swapping 2 nos. it should be *temp= *ptra
swapping without 3rd variable
a=a+b-a;
b=a+b-b;
swapping using ptr is wrong..
should be
int temp;
temp=*a;
its wnt work... :|
a=a^b;
b=a^b;
a=a^b;
there r lots of mistakes
yaa itz right
This is single line logic:
b = b + a - (a = b);
swapping in oneline is needed?
also use this
==========
a=a-(~b)-1
b=a+(~b)+1
a=a+(~b)+1
=========
here ~b=(-b-1)
need to keep * in temp assigning in swap function
Superb nice
Superb nice
Good logic for swapping of 2 nos
Excellent
This article is really helpful for every programmer
This article is really helpful for every programmer
The above program is not working try the below code
#include
int main(){
int a,b;
int *ptra,*ptrb;
int *temp;
printf("Enter any two integers: ");
scanf("%d%d",&a,&b);
printf("Before swapping: a = %d, b=%d",a,b);
ptra = &a;
ptrb = &b;
temp = *ptra;
*ptra = *ptrb;
*ptrb =temp;
printf("\nAfter swapping: a = %d, b=%d",*ptra,*ptrb);
return 0;
}
Post a Comment