Submitted by yogesh on Mon, 19/12/2011 - 13:37
C program to convert decimal to binary: c language code to convert an integer from decimal number system(base-10) to binary number system(base-2). Size of integer is assumed to be 32 bits. We use bitwise operators to perform the desired task. We right shift the original number by 31, 30, 29, ..., 1, 0 bits using a loop and bitwise AND the number obtained with 1(one), if the result is 1 then that bit is 1 otherwise it is 0(zero).
C programming code
#include <stdio.h>
int main()
{
int n, c, k;
printf("Enter an integer in decimal number system\n");
Submitted by yogesh on Fri, 02/12/2011 - 22:22
c program to insert substring into a string: This code inserts the target string into the source string. For example if the source string is "c programming" and target string is " is amazing" (please note there is space at beginning) and if we add target string to source string at position 14 then we obtain the string "c programming is amazing". In our c code we will make a function which perform the desired task and we pass three arguments to it the source string, target string and position. You can insert the string at any valid position.
C programming code
Submitted by yogesh on Wed, 16/11/2011 - 00:22
c program to find area of circle: c programming code to calculate area of circle.
Submitted by yogesh on Wed, 16/11/2011 - 00:09
C program to find area of triangle: c programming code to calculate area of a triangle using Heron's or Hero's formula. User will enter the lengths of sides of triangle. Remember for a triangle to exist the sum of any two sides of a triangle must be greater than third side.
C programming code
/* Assuming Triangle exists - valid input from user */
#include<stdio.h>
#include<math.h>
main()
{
double a, b, c, s, area;
printf("Enter the sides of triangle\n");
scanf("%lf%lf%lf",&a,&b,&c);
s = (a+b+c)/2;
Submitted by yogesh on Tue, 15/11/2011 - 10:30
c program to check odd or even: We will determine whether a number is odd or even by using different methods all are provided with a code in c language. As you have study in mathematics that in decimal number system even numbers are divisible by 2 while odd are not so we may use modulus operator(%) which returns remainder, For example 4%3 gives 1 ( remainder when four is divided by three). Even numbers are of the form 2*p and odd are of the form (2*p+1) where p is is an integer.
Pages