Hello Program
#include <stdio.h> #include <stdio.h> int main() { printf("Hello!,\nWelcome To crackcoderrank\n"); return 0; } Run Code
Output :
Sum Of Two Numbers
#include <stdio.h> int main() { int num1,num2,sum=0; printf("Enter the first Number: \n"); scanf("%d",&num1); printf("Enter the second Number: \n"); scanf("%d",&num2); sum=num1+num2; printf("Sum of the two Numbers is: %d",sum); return 0; } RunCode
Output :
Swap Of Two Numbers
#include<stdio.h> int main() { int a; int b; int c; printf("Type value of A : "); scanf("%i",&a); printf("\nType value of b : "); scanf("%i",&b); c=a; a=b; b=c; printf("A : %i",a); printf("\nb : %i",b); return 0; } Run Code
Output :
Swap Of Two Numbers Using Of XOR
#include<stdio.h> int main() { int a; int b; printf("Type value of A : "); scanf("%i",&a); printf("\nType value of b : "); scanf("%i",&b); a ^= b; b ^= a; a ^= b; printf("\nA : %i",a); printf("\nB : %i",b); return 0; } Run Code
Output :
Swap Of Two Numbers Without Third Variable
#include<stdio.h> int main() { int a; int b; printf("Type value of A : "); scanf("%i",&a); printf("\nType value of b : "); scanf("%i",&b); a = a + b; b = a - b; a = a - b ; printf("A : %i",a); printf("\nB : %i",b); return 0; } Run Code
Output :
Even Number
#include<stdio.h> void main(){ int num; printf("Enter any number: "); scanf("%d",&num); if(num%2==0) { printf("is Even"); } } Run Code
Outpu :
Odd Number
#include<stdio.h> void main() { int num; printf("Enter any number: "); scanf("%d",&num); if(num%2!=0) { printf("is Odd"); } } Odd NumberL
Output :
Write the program to print the Even Or Odd
Input :
16
Input :
16
#include<stdio.h>
void main()
{
int num;
printf("Enter any number: ");
scanf("%d",&num);
if(num%2==0)
{
printf("is Even");
}
else
{
printf("is Odd");
}
} Run Code
Output :
Enter any number: is Even
Convert the number decimal to hexa?
Input :
16
Input :
16
#include <stdio.h> int main(){ int num=65; int i=0,base,r,sum=0; while(num!=0) { r=num%16; num/=16; base=pow(100,i); sum+=base*r; i++; } if(sum<10){ r+=48; sum=sum+base*r; } else{ r+=55; sum+=base*r; } printf("%d",sum); } Run Code
Output:
6301
Convert the number decimal to binary?
Intput:
16
Intput:
16
#include <stdio.h>
int main()
{
int num;
scanf("%d",&num);
int i=0,base,r,sum=0;
while(num!=0){
r=num%2;
num/=2;
base=pow(10,i);
sum+=base*r;
i++;
}
printf("%d",sum);
return 0;
} Run Code
Output:
10000
10000
No comments:
Post a Comment