// C Program to count the number of digits entered #include <stdio.h> //header file declaration int main() //main method { int p, count=0; // variable declaration printf("Input Number--"); //Display input number scanf("%d",&p); while(p!=0) { p=p/10; count++; } printf("\nThe number of digits are: %d",count); ...
// C Program to swap two numbers using + and - without third variable #include<stdio.h> //header file declaration int main() //main method { int p=25, q=50; //variable declaration printf("Before swapping values: p=%d q=%d\n",p,q); //Before swapping value p=p+q; q=p-q; //use of + and - p=p-q; printf("\nAfter swapping values: p=%d q=%d",p,q); // After swapping value return 0; } OUTPUT:
Comments
Post a Comment